Skip to content

New - Prefer detected service name to service key one in azure app service#540

Open
cleverchuk wants to merge 1 commit into
mainfrom
cc/NH-138965
Open

New - Prefer detected service name to service key one in azure app service#540
cleverchuk wants to merge 1 commit into
mainfrom
cc/NH-138965

Conversation

@cleverchuk

@cleverchuk cleverchuk commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Centralizes service name resolution into ResourceCustomizer and 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 ResourceCustomizer

The service name synchronization logic was previously duplicated in both ConfigurationLoader and LambdaConfigurationLoader. 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 in ResourceCustomizer.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 getServiceName method applies this rule:

  • Default (non-Azure, no explicit otel.service.name): service key name wins.
  • Azure App Service (cloud.platform = azure.app_service): detected name wins, unless it is null or starts with unknown_ (i.e., the OTel SDK fallback placeholder), in which case the service key name is used.
  • Explicit otel.service.name set: 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-sampler

Guava and protobuf are now excluded from the opentelemetry-cel-sampler transitive 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 proper info log ("Resolved service name: ...") and the smoke test assertions referencing the old line have been removed.

HttpSettingsReader debug log enriched

The debug log now includes serviceName and hostname alongside the fetched settings, making it easier to correlate settings fetches with the service identity at the time of the call.

Copilot AI review requested due to automatic review settings July 17, 2026 17:25
@cleverchuk
cleverchuk requested review from a team as code owners July 17, 2026 17:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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/azure resource providers and adjust detector/provider ordering so upstream cloud attributes win on merge.
  • Trim HostIdResourceUtil down 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.

@cleverchuk
cleverchuk force-pushed the cc/NH-138965 branch 2 times, most recently from 71881d3 to 60ace60 Compare July 20, 2026 18:08
@cleverchuk cleverchuk changed the title New - Enable upstream resource detectors for Azure and AWS and defer to upstream service name New - Prefer detected service name to service key one in azure app service Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants