[Monitor] Generate exporter with TypeSpec#44442
Merged
hectorhdzg merged 28 commits intoAzure:mainfrom Mar 6, 2026
Merged
Conversation
cd26a71 to
b658113
Compare
Member
|
@pvaneck I can create a separate PR that runs the black format checks on the existing exporter code. I will share it once it is ready for review. |
Member
Author
|
@rads-1996 Thanks, but I believe it was already formatted with #44462. I just need to rebase off of main. |
8ee495f to
20fc16d
Compare
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
20fc16d to
bc3ca46
Compare
rads-1996
reviewed
Jan 22, 2026
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_base_customer_sdkstats.py
Outdated
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the Azure Monitor OpenTelemetry Exporter’s generated ingestion client/models from the legacy AutoRest output to TypeSpec (tsp-client) output, and updates the hand-written exporter code + tests to align with the new generated surface and serialization behaviors.
Changes:
- Add TypeSpec batch generation configuration and record TypeSpec source metadata under
_generated/. - Update exporter implementations/tests to use the new generated module path (
_generated.exporter...) and to explicitly set domain schemaversion. - Align telemetry time handling/tests to use
datetimeobjects (and validate properties-as-strings behavior forMetricsData.properties).
Reviewed changes
Copilot reviewed 55 out of 56 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/monitor/azure-monitor-opentelemetry-exporter/tsp-location.yaml | Adds batch generation output configuration for TypeSpec. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/tsp-location.yaml | Records the TypeSpec source repo/commit metadata for the generated output. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_constants.py | Introduces _EXPORTER_DOMAIN_SCHEMA_VERSION used when constructing domain models. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py | Updates telemetry item creation to use datetime for TelemetryItem.time and switches generated model imports. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py | Updates storage deserialization/formatting for dpcodegen models and adjusts retry/drop tracking flow. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_exporter.py | Updates generated imports, normalizes resource properties as Dict[str, str], and sets domain version on data models. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/metrics/_exporter.py | Updates generated imports and sets domain version on MetricsData. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/logs/_exporter.py | Updates generated imports, sets domain version on log data models, and adjusts tags handling for dpcodegen model semantics. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/statsbeat/customer/_utils.py | Updates generated imports to new TypeSpec-generated module path. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_manager.py | Updates generated imports to new TypeSpec-generated module path. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/trace/test_trace.py | Updates imports to new generated path; updates expectations for datetime envelope times; adds JSON-serialization test using SdkJSONEncoder; updates resource attribute expectations to stringified values. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_utils.py | Updates import path and adjusts _create_telemetry_item test to expect a datetime time value. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_base_exporter.py | Updates generated imports; aligns storage formatting tests with dpcodegen model construction; adjusts mock response behavior. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_base_customer_sdkstats.py | Updates generated imports; updates mock response behavior; tightens expectations for track_dropped_items calls. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_manager.py | Updates generated imports to new TypeSpec-generated module path. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/metrics/test_metrics.py | Updates imports and changes expected envelope time values to datetime. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/logs/test_logs.py | Updates imports, env var setup, and changes expected envelope time values to datetime. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/customer_sdk_stats/test_utlities.py | Updates generated imports to new TypeSpec-generated module path. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/init.py | Repoints _generated.AzureMonitorClient to the new TypeSpec-generated client package. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/apiview-properties.json | Adds APIView mapping metadata for the new generated surface. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/_metadata.json | Adds generated metadata (e.g., apiVersion). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/operations/_azure_monitor_client_operations.py | Removes legacy AutoRest operations mixin (replaced by TypeSpec output). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/aio/operations/_azure_monitor_client_operations.py | Removes legacy AutoRest aio operations mixin (replaced by TypeSpec output). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/_azure_monitor_client.py | Removes legacy AutoRest client (replaced by TypeSpec output). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/aio/_azure_monitor_client.py | Removes legacy AutoRest async client (replaced by TypeSpec output). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/_vendor.py | Removes legacy AutoRest vendor request conversion helper. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/_patch.py | Removes legacy AutoRest patch hook (replaced by new patch structure under exporter/). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/aio/_patch.py | Removes legacy AutoRest aio patch hook (replaced by new patch structure under exporter/aio/). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/models/init.py | Removes legacy AutoRest models package init (replaced by TypeSpec output). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/models/_models.py | Removes legacy AutoRest models definitions (replaced by TypeSpec output). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/models/_models_py3.py | Removes legacy AutoRest py3 models definitions (replaced by TypeSpec output). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/aio/init.py | Removes legacy AutoRest aio init (replaced by TypeSpec output). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/init.py | Adds new TypeSpec-generated synchronous client package init. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/_client.py | Adds new TypeSpec-generated synchronous client implementation. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/_configuration.py | Adds new TypeSpec-generated sync configuration handling (including optional credential). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/_operations/init.py | Adds new TypeSpec-generated operations package init. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/_operations/_operations.py | Adds new TypeSpec-generated sync operations implementation (uses SdkJSONEncoder). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/_patch.py | Adds new TypeSpec-generated patch hook for sync client package. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/_utils/init.py | Updates generated utils init to TypeSpec generator output. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/_utils/model_base.py | Adds dpcodegen model base + SdkJSONEncoder used for serialization/deserialization. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/_utils/utils.py | Adds dpcodegen internal typing helper for client mixins. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/_version.py | Adds generated version constant for the new client package. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/py.typed | Adds PEP 561 marker for the generated package. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/models/init.py | Adds new TypeSpec-generated models package init. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/models/_enums.py | Adds/updates generated enums (including MonitorDomainKind and Versions). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/models/_patch.py | Adds new TypeSpec-generated models patch hook. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/aio/init.py | Adds new TypeSpec-generated async client package init. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/aio/_client.py | Adds new TypeSpec-generated async client implementation. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/aio/_configuration.py | Adds new TypeSpec-generated async configuration handling (including optional credential). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/aio/_operations/init.py | Adds new TypeSpec-generated async operations package init. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/aio/_operations/_operations.py | Adds new TypeSpec-generated async operations implementation (uses SdkJSONEncoder). |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/aio/_operations/_patch.py | Adds new TypeSpec-generated async operations patch hook. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/aio/_patch.py | Adds new TypeSpec-generated async client package patch hook. |
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py
Show resolved
Hide resolved
rads-1996
reviewed
Feb 9, 2026
...monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/logs/_exporter.py
Show resolved
Hide resolved
rads-1996
reviewed
Feb 9, 2026
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_base_exporter.py
Outdated
Show resolved
Hide resolved
rads-1996
reviewed
Feb 9, 2026
...or/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py
Outdated
Show resolved
Hide resolved
rads-1996
reviewed
Feb 11, 2026
...exporter/azure/monitor/opentelemetry/exporter/_generated/exporter/_operations/_operations.py
Outdated
Show resolved
Hide resolved
rads-1996
reviewed
Feb 12, 2026
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_base_customer_sdkstats.py
Outdated
Show resolved
Hide resolved
rads-1996
reviewed
Feb 19, 2026
...or/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py
Show resolved
Hide resolved
hectorhdzg
approved these changes
Feb 20, 2026
Use the merged commit hash from the specs repo and regen using an updated Python emitter version. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
hectorhdzg
approved these changes
Mar 6, 2026
aprilk-ms
pushed a commit
that referenced
this pull request
Mar 11, 2026
* [Monitor] Generate exporter with TypeSpec Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> * Fix resource envelope serialization for OTel resource attributes * Update tests * Update log exporter * Update * Regenerate exporter typespec models * Regenerate exporter typespec models and fix renames * Fix _generated/__init__.py to re-export AzureMonitorClient from exporter subpackage * Add trailing newline to _generated/__init__.py * Added tracing false in autogenerated code definition * Update * Update * Remove unused model imports from _base.py and fix lint * Update tsp-location.yml and regen Use the merged commit hash from the specs repo and regen using an updated Python emitter version. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> --------- Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> Co-authored-by: Hector Hernandez <39923391+hectorhdzg@users.noreply.github.com>
singankit
pushed a commit
that referenced
this pull request
Mar 16, 2026
* [Monitor] Generate exporter with TypeSpec Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> * Fix resource envelope serialization for OTel resource attributes * Update tests * Update log exporter * Update * Regenerate exporter typespec models * Regenerate exporter typespec models and fix renames * Fix _generated/__init__.py to re-export AzureMonitorClient from exporter subpackage * Add trailing newline to _generated/__init__.py * Added tracing false in autogenerated code definition * Update * Update * Remove unused model imports from _base.py and fix lint * Update tsp-location.yml and regen Use the merged commit hash from the specs repo and regen using an updated Python emitter version. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> --------- Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> Co-authored-by: Hector Hernandez <39923391+hectorhdzg@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generation from TypeSpec from the branch in this PR: Azure/azure-rest-api-specs#38795
Noteable changes
timefield inTelemetryItemseems to have always been typed asdatetime.datetime, but was being set as a ISO8601 date string. I have adjusted the tests and the_create_telemetry_itemmethod to set thetimeto adatetimeobject and have adjusted the tests accordingly. The datetime objects will be serialized to the ISO8601 formatted strings (e.g.2025-12-15T13:45:30.0000000Zwhen sent in a request anyway, so this should be fine.versionproperty in theDomainmodel has a default of 2, however, the generated code does not include this as a default. The code was updated to explicitly set theversionargument when constructing subclasses ofDomain.Notes:
tsp-clientwhere the Exporter project will be emitted intoazure/monitor/opentelemetry/exporter/_generated. LiveMetrics will be emitted toazure/monitor/opentelemetry/exporter/_quickpulse/_generatedin the future.tests/trace/test_trace.py::TestAzureTraceExporter::test_get_otel_resource_envelope, was failing after the regeneration. It is comparing OTelResourceattributes withMetricsData.properties, but thepropertiesfield is type and serialized asDict[str, str]. Thus, all values end up as strings when checking the values ofproperties.Asks for team
datetimeobjects instead of strings when creatingTelemetryItemsis acceptable.MetricsDatais acceptable.