Skip to content

Override mappings for context from the shim#56813

Merged
harsimar merged 12 commits intoAzure:mainfrom
harsimar:harskaur/mappingsForAllContext
Mar 23, 2026
Merged

Override mappings for context from the shim#56813
harsimar merged 12 commits intoAzure:mainfrom
harsimar:harskaur/mappingsForAllContext

Conversation

@harsimar
Copy link
Copy Markdown
Member

@harsimar harsimar commented Mar 5, 2026

Related to: microsoft/ApplicationInsights-dotnet#3137
This PR is to ensure that context set from the shim shows up as tags (not custom dimensions) in most telemetry types (not including metrics)

@github-actions github-actions bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Mar 5, 2026
@harsimar harsimar marked this pull request as ready for review March 17, 2026 21:13
Copilot AI review requested due to automatic review settings March 17, 2026 21:13
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 extends the Azure Monitor OpenTelemetry Exporter to treat additional Application Insights shim context values as envelope tags (instead of custom dimensions), aiming for consistent behavior across telemetry types (including metrics), and adds an environment-variable override for application/component version.

Changes:

  • Adds support for overriding ai.application.ver via APPLICATIONINSIGHTS_COMPONENT_VERSION.
  • Introduces new shim context tag attribute constants and mapping paths (Activity tags, log attributes, and metric tags) to populate TelemetryItem.Tags.
  • Updates/extends E2E and unit tests to validate the new context-tag-to-envelope-tag behavior.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/TelemetryItem.cs Adds environment variable override for component version; copies/mapping of additional context tags into envelope tags.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/ActivityTagsProcessor.cs Extends the set of recognized Activity semantic attributes for shim context tags.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/LogsHelper.cs Extends log attribute extraction into LogContextInfo for mapping into envelope tags.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/LogContextInfo.cs Adds new extracted context fields for logs.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/MetricHelper.cs Adds metric-tag-to-envelope-tag mapping hook for metrics.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/SemanticConventions.cs Adds constants for shim context attributes.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/SchemaConstants.cs Adds max-length constants for newly mapped envelope tags.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/Platform/EnvironmentVariableConstants.cs Adds APPLICATIONINSIGHTS_COMPONENT_VERSION constant and includes it in override-related environment variable sets.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/**/TelemetryItemTests.cs Adds unit test for APPLICATIONINSIGHTS_COMPONENT_VERSION override.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/**/LogsHelperTests.cs Removes user-agent log-context test coverage and updates combined-context tests accordingly.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/**/E2ETelemetryItemValidation/TracesTests.cs Adds E2E validation that shim context attributes map to envelope tags and not custom dimensions for traces.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/**/E2ETelemetryItemValidation/LogsTests.cs Adds E2E validation that shim context attributes map to envelope tags and not custom dimensions for logs.
sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/**/E2ETelemetryItemValidation/MetricsTests.cs Adds an Internals using (currently unused).

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

@harsimar harsimar merged commit 260a80d into Azure:main Mar 23, 2026
22 checks passed
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 to harsimar/azure-sdk-for-net that referenced this pull request Mar 27, 2026
…ure#56813 from changelog

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