Skip to content

[AzureMonitorExporter] Migrate Azure Monitor OpenTelemetry Exporter from swagger to TypeSpec#56891

Merged
rajkumar-rangaraj merged 6 commits intomainfrom
rajrang/typespec
Mar 17, 2026
Merged

[AzureMonitorExporter] Migrate Azure Monitor OpenTelemetry Exporter from swagger to TypeSpec#56891
rajkumar-rangaraj merged 6 commits intomainfrom
rajrang/typespec

Conversation

@rajkumar-rangaraj
Copy link
Copy Markdown
Member

Purpose

Migrate the Azure Monitor OpenTelemetry Exporter code generation from AutoRest (swagger) to TypeSpec, aligning with the broader Azure SDK migration effort.

Changes

TypeSpec client customizations (client.tsp)

  • Added @@clientName(AzureMonitorExporter, "ApplicationInsightsRestClient", "csharp") to preserve the existing C# client class name
  • Added @@access(AzureMonitorExporter, Access.internal, "csharp") to keep the generated client and options classes internal
  • Existing model renames and access controls for other languages are unchanged

Generated code (src/Generated/) Important changes

  • Replaced ApplicationInsightsRestClient.cs (swagger) with TypeSpec-generated ApplicationInsightsRestClient.cs + ApplicationInsightsRestClient.RestClient.cs
  • Generated ApplicationInsightsRestClientOptions (internal) — does not conflict with handwritten AzureMonitorExporterOptions

Code updates

  • Customizations/ApplicationInsightsRestClient.cs: Added internal constructor (ClientDiagnostics, HttpPipeline, string) to bridge old API shape; updated _pipelinePipeline, _host_endpoint
  • Internals/HttpPipelineHelper.cs: Added ModelReaderWriterOptions parameter to DeserializeTrackResponse() call
  • Customizations/AzureMonitorOpenTelemetryExporterContext.Custom.cs: Deleted — source generator now handles Default property
  • API baselines (api/*.cs): Removed AzureMonitorOpenTelemetryExporterContext (now internal)
  • ApiCompatBaseline.txt: Added suppression for intentional removal of AzureMonitorOpenTelemetryExporterContext from public API

…s and improve serialization

- Updated StackFrame class to include additional binary data properties.
- Enhanced TelemetryErrorDetails and TelemetryEventData classes with new serialization methods and additional properties.
- Refactored TelemetryExceptionData to include improved handling of exceptions and properties.
- Removed outdated autorest.md file and added tsp-location.yaml for TypeSpec configuration.
… Support

- Updated TelemetryExceptionDetails to include a dictionary for additional binary data properties.
- Modified TelemetryItem to support additional binary data properties and improved serialization methods.
- Enhanced TrackResponse to handle additional properties and improved JSON serialization/deserialization.
- Introduced UnknownMonitorDomain class to manage unknown telemetry data types with appropriate serialization.
- Updated HttpPipelineHelper to utilize new serialization methods for TrackResponse.
Copilot AI review requested due to automatic review settings March 10, 2026 00:11
@github-actions github-actions bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Mar 10, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates Azure.Monitor.OpenTelemetry.Exporter code generation from AutoRest (swagger) to TypeSpec, updating the generated REST client/models/serialization stack while preserving the existing internal client surface and updating API baselines accordingly.

Changes:

  • Introduces TypeSpec generation configuration (tsp-location.yaml, metadata.json) and removes the legacy autorest.md flow.
  • Replaces/updates generated client + model serialization to the TypeSpec/System.ClientModel pattern (new split rest client, MRW context, additional-properties handling).
  • Updates handwritten glue code and tests to align with the new generated shapes and adjusts API baselines / compat suppressions.

Reviewed changes

Copilot reviewed 12 out of 75 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tsp-location.yaml Adds TypeSpec source location + entrypoint for generation.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/metadata.json Adds package metadata mapping for API versions.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/autorest.md Removes swagger/AutoRest generation configuration.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Azure.Monitor.OpenTelemetry.Exporter.csproj Removes AutoRest dependency flag for the project.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/ApiCompatBaseline.txt Adds ApiCompat suppression for context type no longer in public API.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/api/Azure.Monitor.OpenTelemetry.Exporter.netstandard2.0.cs Updates public API baseline (removes exporter context).
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/api/Azure.Monitor.OpenTelemetry.Exporter.net8.0.cs Updates public API baseline (removes exporter context).
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/api/Azure.Monitor.OpenTelemetry.Exporter.net10.0.cs Updates public API baseline (removes exporter context).
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/AzureMonitorTraceExporterTests.cs Updates reflection field name _host_endpoint.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/HttpPipelineHelper.cs Updates TrackResponse deserialization call to pass wire options.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/ApplicationInsightsRestClient.cs Adds bridge ctor + updates request building to match new generated fields/pipeline shape.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/AzureMonitorOpenTelemetryExporterContext.Custom.cs Removes handwritten context; relies on source generation.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/ApplicationInsightsRestClient.cs TypeSpec-generated client implementation + protocol method pattern.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/ApplicationInsightsRestClient.RestClient.cs Adds generated request creation method for Track.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/ApplicationInsightsRestClientOptions.cs Adds generated client options with service version mapping.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/AzureMonitorOpenTelemetryExporterContext.cs Adds MRW buildable context for source-generated serialization.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/MonitorDomainKind.cs Adds discriminator-like kind type for MonitorDomain polymorphism.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/UnknownMonitorDomain.cs Adds unknown polymorphic fallback type.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/UnknownMonitorDomain.Serialization.cs Adds serialization/deserialization for unknown domain fallback.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/MonitorDomain.cs Updates base model to new additional-properties + kind handling.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/MonitorDomain.Serialization.cs Adds polymorphic deserialization + MRW persistence hooks.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/MonitorBase.cs Updates monitor base model to new additional-properties pattern.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/MonitorBase.Serialization.cs Updates serialization to MRW/IJsonModel pattern.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/TrackResponse.cs Updates response model to include additional-properties tracking and new collection types.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/TrackResponse.Serialization.cs Updates deserialization to accept MRW options and adds explicit operator from Response.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/TelemetryItem.cs Updates telemetry item model for additional-properties tracking.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/TelemetryItem.Serialization.cs Moves to IJsonModel/MRW and adds full deserialize implementation.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/TelemetryErrorDetails.cs Updates error details model for additional-properties tracking.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/TelemetryErrorDetails.Serialization.cs Updates to IJsonModel/MRW and captures unknown JSON properties.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/TelemetryExceptionDetails.cs Updates exception details shape (mutability + additional-properties tracking).
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/TelemetryExceptionDetails.Serialization.cs Updates to IJsonModel/MRW and adds deserialize implementation.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/TelemetryExceptionData.cs Updates derived domain constructor signatures to new base(kind/additionalProps) pattern.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/TelemetryEventData.cs Updates derived domain model shape (mutability + new base ctor).
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/TelemetryEventData.Serialization.cs Updates to MonitorDomain + IJsonModel and adds deserialize implementation.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/StackFrame.cs Updates stack frame model (mutability + additional-properties tracking).
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/StackFrame.Serialization.cs Updates to IJsonModel/MRW and adds deserialize implementation.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/SeverityLevel.cs Updates enum-like struct conversions/docs and adds nullable implicit conversion.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/DataPointType.cs Updates enum-like struct conversions/docs and adds nullable implicit conversion.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/MetricDataPoint.cs Updates metric point model (mutability + additional-properties tracking).
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/MetricsData.cs Updates derived domain to new base ctor + doc formatting.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/MetricsData.Serialization.cs Updates to MonitorDomain + IJsonModel and adds deserialize implementation.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/MessageData.cs Updates derived domain model to new base ctor and mutability.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/MessageData.Serialization.cs Updates to MonitorDomain + IJsonModel and adds deserialize implementation.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/RequestData.cs Updates derived domain model to new base ctor and mutability.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/RequestData.Serialization.cs Updates to MonitorDomain + IJsonModel and adds deserialize implementation.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/RemoteDependencyData.cs Updates derived domain model to new base ctor and mutability.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/RemoteDependencyData.Serialization.cs Updates to MonitorDomain + IJsonModel and adds deserialize implementation.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/PageViewData.cs Updates derived domain model to new base ctor and mutability.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/PageViewData.Serialization.cs Updates to MonitorDomain + IJsonModel and adds deserialize implementation.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/PageViewPerfData.cs Updates derived domain model to new base ctor and mutability.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/AvailabilityData.cs Updates derived domain model to new base ctor and mutability.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Models/AvailabilityData.Serialization.cs Updates to MonitorDomain + IJsonModel and adds deserialize implementation.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/TypeFormatters.cs Adds TypeSpec-generated formatting helpers used by request building/serialization.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/SerializationFormat.cs Adds serialization format enum used by TypeFormatters/helpers.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/RequestContextExtensions.cs Adds parsing helper for RequestContext into token/error options.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/RawRequestUriBuilderExtensions.cs Adds query update/delimited helpers.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/ClientPipelineExtensions.cs Adds pipeline send helpers respecting RequestContext options.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/ErrorResult.cs Adds Response wrapper that throws on Value access.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/CancellationTokenExtensions.cs Adds CancellationToken → RequestContext helper.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/Utf8JsonRequestContent.cs Makes request content partial and adds docs.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/BinaryContentHelper.cs Updates JSON RequestContent construction to use MRW wire options.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/Optional.cs Updates Optional helpers (partial + method ordering/formatting).
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/Argument.cs Updates Argument helpers (partial + removes unused helpers).
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/ChangeTrackingList.cs Makes change-tracking list partial + adds docs.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/ChangeTrackingDictionary.cs Makes change-tracking dictionary partial + adds docs.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/MultipartFormDataRequestContent.cs Removes unused multipart request content helper.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/CodeGenTypeAttribute.cs Adds TypeSpec customization attribute stubs.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/CodeGenSuppressAttribute.cs Adds TypeSpec suppression attribute stubs.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/CodeGenSerializationAttribute.cs Adds TypeSpec serialization-hook attribute stubs.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Generated/Internal/CodeGenMemberAttribute.cs Adds TypeSpec member-rename attribute stub.

You can also share your feedback on Copilot code review. Take the survey.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 10, 2026

API Change Check

APIView identified API level changes in this PR and created the following API reviews

Azure.Monitor.OpenTelemetry.Exporter

Copy link
Copy Markdown
Member

@mattsains-msft mattsains-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you managed to test this using the integration tests?

Also, I'd like to see a second review because I had a lot of influence on this PR

@rajkumar-rangaraj rajkumar-rangaraj merged commit a05166e into main Mar 17, 2026
22 checks passed
@rajkumar-rangaraj rajkumar-rangaraj deleted the rajrang/typespec branch March 17, 2026 00:15
@rajkumar-rangaraj
Copy link
Copy Markdown
Member Author

have you managed to test this using the integration tests?

yes, it works without any issues.

harsimar added a commit to harsimar/azure-sdk-for-net that referenced this pull request Mar 27, 2026
…1 release

Added PR links to existing entries and new changelog items:
- Azure#57194: Gen-ai attribute truncation (256KB limit)
- Azure#56813: Classic TelemetryContext tag mapping
- Azure#56368: AOT warning regression fix
- Azure#56891: ApplicationInsightsRestClientSettings PR link

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
harsimar added a commit that referenced this pull request Mar 27, 2026
* Update Azure.Monitor.OpenTelemetry.Exporter CHANGELOG for 1.7.0-beta.1 release

Added PR links to existing entries and new changelog items:
- #57194: Gen-ai attribute truncation (256KB limit)
- #56813: Classic TelemetryContext tag mapping
- #56368: AOT warning regression fix
- #56891: ApplicationInsightsRestClientSettings PR link

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Update Azure.Monitor.OpenTelemetry.Exporter to 1.7.0 GA and remove #56813 from changelog

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants