Prioritize deployment environment set in OTEL_RESOURCE_ATTRIBUTES#3405
Prioritize deployment environment set in OTEL_RESOURCE_ATTRIBUTES#3405scottrudy wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the isolated worker OpenTelemetry FunctionsResourceDetector so that deployment.environment.name is not overwritten when a higher-priority value is already provided via OTEL_RESOURCE_ATTRIBUTES, aligning behavior with the intended priority order in Azure environments.
Changes:
- Skip adding
deployment.environment.namefromWEBSITE_SLOT_NAMEwhenOTEL_RESOURCE_ATTRIBUTEScontainsdeployment.environment.nameordeployment.environment. - Add a semantic convention constant for
deployment.environmentto support the new priority check. - Add/adjust tests and update OpenTelemetry package release notes for the behavior change.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/DotNetWorker.OpenTelemetry.Tests/EndToEndTests.cs | Adds test coverage for skipping deployment.environment.name when configured via OTEL_RESOURCE_ATTRIBUTES (currently contains issues). |
| src/DotNetWorker.OpenTelemetry/ResourceSemanticConventions.cs | Adds deployment.environment constant to support priority checking. |
| src/DotNetWorker.OpenTelemetry/release_notes.md | Documents the updated detector behavior and references #3404. |
| src/DotNetWorker.OpenTelemetry/FunctionsResourceDetector.cs | Implements the priority/skip logic for deployment environment attributes (Azure-only). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| attributes.Add(new(ResourceSemanticConventions.DeploymentEnvironmentName, slot)); | ||
| attributes.Add(new(ResourceSemanticConventions.DeploymentEnvironmentName, slot)); |
| public static IEnumerable<object[]> EnvironmentNameSkippedData => | ||
| [ | ||
| // OTEL_RESOURCE_ATTRIBUTES[deployment.environment.name] set in Azure | ||
| [new Dictionary<string, string> { { "WEBSITE_SITE_NAME", "appName" }, { "WEBSITE_SLOT_NAME", "staging" }, { "OTEL_RESOURCE_ATTRIBUTES", "deployment.environment.name=custom-name,other.key=value" } }], |
There was a problem hiding this comment.
Add tests for deployment.environment.name and deployment.environment with empty values. If a user accidentally sets an empty value, the slot name gets silently skipped.
There was a problem hiding this comment.
Good call out. Explicit tests have been added.
|
@scottrudy, thanks for putting in the time to create this PR. Really appreciate you doing it. |
… detector when set in OTEL_RESOURCE_ATTRIBUTES
516597c to
c828b52
Compare
Further enhances the isolated worker's FunctionsResourceDetector and the changes made in #3362.
FunctionsResourceDetector
The attribute deployment.environment.name now follows priority order (Azure only):
WEBSITE_SLOT_NAME.
Issue describing the changes in this PR
resolves #3404
Pull request checklist
release_notes.md