New - Prefer detected service name to service key one in azure app service - #540
Conversation
There was a problem hiding this comment.
Pull request overview
This PR shifts cloud/host resource detection to upstream OpenTelemetry AWS/Azure resource detectors, simplifies the agent’s own host-id resource attributes accordingly, and centralizes service.name / service-key reconciliation into the shared ResourceCustomizer so a single path controls the resolved service identity.
Changes:
- Enable upstream
aws/azureresource providers and adjust detector/provider ordering so upstream cloud attributes win on merge. - Trim
HostIdResourceUtildown to agent-specific attributes and seed resource accumulation from the OTel SDK default resource. - Move service-name reconciliation into
ResourceCustomizer, update tests/smoke-tests, and bump agent version to 3.3.0.
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| smoke-tests/src/test/java/com/solarwinds/SmokeTestV2.java | Removes validation-only log assertion for service name. |
| smoke-tests/src/test/java/com/solarwinds/SmokeTest.java | Removes validation-only log assertion for service name. |
| smoke-tests/src/test/java/com/solarwinds/containers/SpringBootWebMvcContainer.java | Sets OTEL_SERVICE_NAME explicitly for smoke-test container. |
| smoke-tests/src/test/java/com/solarwinds/containers/PetClinicRestContainer.java | Sets OTEL_SERVICE_NAME explicitly for smoke-test container. |
| libs/shared/src/test/java/com/solarwinds/opentelemetry/extensions/ResourceCustomizerTest.java | Adds service-name/service-key reconciliation test coverage and resets config between tests. |
| libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/ResourceCustomizer.java | Implements centralized service-name resolution and service-key rewrite during resource customization. |
| libs/shared/build.gradle.kts | Excludes Guava/Protobuf from CEL sampler dependency to avoid duplication. |
| libs/lambda/src/main/java/com/solarwinds/opentelemetry/extensions/LambdaConfigurationLoader.java | Removes duplicated service-name/service-key reconciliation logic. |
| custom/src/test/java/com/solarwinds/opentelemetry/extensions/config/HostIdResourceUtilTest.java | Updates host-id test to reflect reduced attribute responsibility. |
| custom/src/test/java/com/solarwinds/opentelemetry/extensions/config/ConfigurationLoaderTest.java | Removes service-name/service-key reconciliation tests (logic moved). |
| custom/src/main/java/com/solarwinds/opentelemetry/extensions/SolarwindsPropertiesSupplier.java | Enables upstream AWS/Azure resource detectors by default (when agent enabled). |
| custom/src/main/java/com/solarwinds/opentelemetry/extensions/HostIdResourceProvider.java | Forces host-id resource provider to run early via order(). |
| custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/provider/ResourceComponentProvider.java | Seeds static accumulated resource from Resource.getDefault() and merges agent attrs into it. |
| custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/provider/CustomConfigCustomizerProvider.java | Enforces detector ordering so upstream detectors run after SWO detectors. |
| custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/HttpSettingsReader.java | Extends debug logging context for fetched settings. |
| custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/HostIdResourceUtil.java | Removes AWS/Azure/container/pid/etc attributes now owned by upstream detectors. |
| custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/ConfigurationLoader.java | Removes duplicated service-name/service-key reconciliation logic. |
| build.gradle.kts | Bumps agent version to 3.3.0. |
| .gitignore | Ignores buildSrc/.kotlin/ output. |
71881d3 to
60ace60
Compare
cheempz
left a comment
There was a problem hiding this comment.
LGTM thanks @cleverchuk! To confirm, resource detection already prioritizes the OTEL_SERVICE_NAME if set, so the only place it needs to be considered in our distro is the special azure case?
| @@ -0,0 +1,45 @@ | |||
| # Prefer detected service name to service key name in Azure App Service | |||
There was a problem hiding this comment.
Don't need this file checked in? ;)
Summary
Centralizes service name resolution into
ResourceCustomizerand introduces environment-aware precedence: on Azure App Service, the OTel-detected service name takes priority over the name embedded in the service key. For all other environments, the service key name continues to win. The service key is then updated to stay in sync with the resolved name.What changed and why
Service name resolution moved to
ResourceCustomizerThe service name synchronization logic was previously duplicated in both
ConfigurationLoaderandLambdaConfigurationLoader. It ran during config loading — before OTel resource detection — which meant it could not see Azure-injected resource attributes. Both copies have been removed, and the logic now lives entirely inResourceCustomizer.apply(), which runs after resource detection.Azure App Service gets detected name precedence
Azure App Service uses OTel resource detection to inject a meaningful
service.name(the app name). The old logic always overwrote this with the service key name.The new
getServiceNamemethod applies this rule:otel.service.name): service key name wins.cloud.platform = azure.app_service): detected name wins, unless it isnullor starts withunknown_(i.e., the OTel SDK fallback placeholder), in which case the service key name is used.otel.service.nameset: detected/config name wins in all environments.Service key kept in sync
After resolving the final service name,
updateServiceKey()rewrites the service key as{apiKey}:{resolvedName}. This ensures the collector receives a consistent key regardless of which name source won.Dependency exclusions for
opentelemetry-cel-samplerGuava and protobuf are now excluded from the
opentelemetry-cel-samplertransitive dependency tree. Both are already on the classpath via the agent and were causing version conflicts at runtime.Smoke test validation log removed
The old debug log line (
"This log line is used for validation only: service.name: ...") has been replaced with a properinfolog ("Resolved service name: ...") and the smoke test assertions referencing the old line have been removed.HttpSettingsReaderdebug log enrichedThe debug log now includes
serviceNameandhostnamealongside the fetched settings, making it easier to correlate settings fetches with the service identity at the time of the call.