Add ApplicationVersionResourceDetector for service.version#3124
Add ApplicationVersionResourceDetector for service.version#3124rajkumar-rangaraj merged 3 commits intomainfrom
Conversation
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.
There was a problem hiding this comment.
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
ApplicationVersionResourceDetectorto emitservice.versionbased onApplicationInsightsServiceOptions.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.
harsimar
left a comment
There was a problem hiding this comment.
- What happens if the customer does not explicitly set the version?
- Please double check in the breaking changes & migration guidance docs that any references to ApplicationVersion or ComponentVersion are up to date with this change.
We have default set from the code using
Will check this out. |
A minor adjustment is required for ComponentVersion from the DI perspective. However, we should plan to address it after we resolve the TelemetryContext issue. |
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