Skip to content

Add ApplicationVersionResourceDetector for service.version#3124

Merged
rajkumar-rangaraj merged 3 commits intomainfrom
rajrang/fixAppVersion
Feb 20, 2026
Merged

Add ApplicationVersionResourceDetector for service.version#3124
rajkumar-rangaraj merged 3 commits intomainfrom
rajrang/fixAppVersion

Conversation

@rajkumar-rangaraj
Copy link
Copy Markdown
Member

Fix Issue #3111 .

Changes

Introduced ApplicationVersionResourceDetector to set the application version as the service.version resource attribute in OpenTelemetry. Registered the detector in both ASP.NET Core and WorkerService ApplicationInsights extension flows. Added unit tests to verify correct behavior for valid, null, and empty version values.

Checklist

  • I ran Unit Tests locally.
  • CHANGELOG.md updated with one line description of the fix, and a link to the original issue if available.

Introduced ApplicationVersionResourceDetector to set the application version as the service.version resource attribute in OpenTelemetry. Registered the detector in both ASP.NET Core and WorkerService ApplicationInsights extension flows. Added unit tests to verify correct behavior for valid, null, and empty version values.
Copilot AI review requested due to automatic review settings February 20, 2026 17:46
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 addresses Issue #3111 by ensuring ApplicationInsightsServiceOptions.ApplicationVersion is propagated into OpenTelemetry as the service.version resource attribute, so the application version is no longer ignored in v3.

Changes:

  • Introduces ApplicationVersionResourceDetector to emit service.version based on ApplicationInsightsServiceOptions.ApplicationVersion.
  • Registers the detector in both ASP.NET Core and WorkerService OpenTelemetry resource configuration flows.
  • Adds unit tests validating detector output for valid, null, and empty version values.

Reviewed changes

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

Show a summary per file
File Description
NETCORE/test/Shared/ConfigurationTests.cs Adds unit tests for the new resource detector behavior.
NETCORE/src/Shared/Shared.projitems Includes the new detector source file in the shared compilation items.
NETCORE/src/Shared/ApplicationVersionResourceDetector.cs Implements a resource detector that sets service.version from ApplicationVersion.
NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs Registers the new detector in the WorkerService OpenTelemetry resource pipeline.
NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs Registers the new detector in the ASP.NET Core OpenTelemetry resource pipeline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@harsimar harsimar left a comment

Choose a reason for hiding this comment

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

  1. What happens if the customer does not explicitly set the version?
  2. Please double check in the breaking changes & migration guidance docs that any references to ApplicationVersion or ComponentVersion are up to date with this change.

@rajkumar-rangaraj
Copy link
Copy Markdown
Member Author

What happens if the customer does not explicitly set the version?

https://github.com/microsoft/ApplicationInsights-dotnet/blob/main/NETCORE/src/Shared/Extensions/ApplicationInsightsServiceOptions.cs#L48

We have default set from the code using public string ApplicationVersion { get; set; } = Assembly.GetEntryAssembly()?.GetName().Version.ToString(); value of it will be 1.0.0.

Please double check in the breaking changes & migration guidance docs that any references to ApplicationVersion or ComponentVersion are up to date with this change.

Will check this out.

@rajkumar-rangaraj
Copy link
Copy Markdown
Member Author

Please double check in the breaking changes & migration guidance docs that any references to ApplicationVersion or ComponentVersion are up to date with this change.

A minor adjustment is required for ComponentVersion from the DI perspective. However, we should plan to address it after we resolve the TelemetryContext issue.

@rajkumar-rangaraj rajkumar-rangaraj enabled auto-merge (squash) February 20, 2026 21:29
@rajkumar-rangaraj rajkumar-rangaraj merged commit 92a6154 into main Feb 20, 2026
18 checks passed
@rajkumar-rangaraj rajkumar-rangaraj deleted the rajrang/fixAppVersion branch February 20, 2026 21:33
This was referenced Apr 2, 2026
This was referenced Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants