Skip to content

New - Enable upstream resource detectors for Azure and AWS#541

Merged
cleverchuk merged 1 commit into
mainfrom
cc/NH-143670
Jul 20, 2026
Merged

New - Enable upstream resource detectors for Azure and AWS#541
cleverchuk merged 1 commit into
mainfrom
cc/NH-143670

Conversation

@cleverchuk

Copy link
Copy Markdown
Contributor

Summary

Removes custom AWS and Azure metadata collection from HostIdResourceUtil and delegates that work to the upstream OpenTelemetry resource detectors instead. Upstream detectors are explicitly enabled via configuration properties and are ordered after SWO detectors so their cloud attributes win under last-writer-wins merge semantics. Also fixes a subtle null-initialization bug in ResourceComponentProvider that could cause a NPE when merge is called with the detectors are reordered.


What changed and why

Delegating AWS/Azure detection to upstream OTel

The agent was manually querying AWS EC2 and Azure VM metadata endpoints inside HostIdResourceUtil and mapping the results to OTel semantic-convention attributes (cloud.*, host.*, etc.). The upstream OTel Java agent already ships resource detectors that do exactly this. Maintaining a parallel implementation creates a divergence risk as the OTel semconv evolves.

The detectors are now enabled unconditionally via two properties added to SolarwindsPropertiesSupplier:

otel.resource.providers.azure.enabled = true
otel.resource.providers.aws.enabled   = true

All AWS- and Azure-specific attribute writes were removed from HostIdResourceUtil. What remains are attributes the upstream detectors don't cover: MAC addresses, Heroku dyno ID, and UAMS client ID.

Detector ordering and merge semantics

OTel resource merging is last-writer-wins. To let upstream cloud attributes (from the now-enabled AWS/Azure detectors) override any overlapping host-id attributes from SWO, SWO detectors must run before upstream ones.

CustomConfigCustomizerProvider previously built the detector list as new ArrayList<>(detectors) (upstream first) and then prepended SWO entries — meaning SWO attributes won the merge. The list construction is now inverted: SWO detectors are inserted first, then detectors (the upstream list) is appended. Upstream cloud attributes now overwrite SWO's when there is a conflict.

HostIdResourceProvider.order() returns Integer.MIN_VALUE so that, in the non-declarative config path, the SWO provider is also sorted to run earliest.

ResourceComponentProvider null-safety

The static resource field was initialized to null. create() called resource.merge(...), which would NPE on first invocation. Changed the initializer to Resource.getDefault() so the merge chain starts from a safe baseline.

Dependency exclusions

Excluded guava and protobuf from the opentelemetry-cel-sampler transitive graph to prevent version conflicts with dependencies already provided by the agent.

Debug logging

HttpSettingsReader now includes serviceName and hostname alongside fetched settings in the debug log, making it easier to correlate settings fetches with the reporting identity during troubleshooting.

Test services data

  1. e-1712644058766987264
  2. e-1712643928659124224
  3. e-1742334541200846848
  4. e-1777406072376840192

@cleverchuk
cleverchuk requested a review from a team as a code owner July 20, 2026 14:43
Copilot AI review requested due to automatic review settings July 20, 2026 14:43
@cleverchuk
cleverchuk requested a review from a team as a code owner July 20, 2026 14:43

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 AWS/Azure resource attribute detection from SolarWinds’ custom HostIdResourceUtil implementation to upstream OpenTelemetry resource detectors, and adjusts detector ordering so upstream cloud attributes win under last-writer-wins resource merge semantics. It also fixes an initialization issue in declarative-config resource accumulation and updates build/dependency hygiene and logging to support the change.

Changes:

  • Enable upstream AWS/Azure resource detectors via default OTel properties and remove AWS/Azure attribute population from HostIdResourceUtil.
  • Reorder declarative-config resource detectors (and set HostIdResourceProvider.order()) so SWO detectors run before upstream detectors.
  • Fix ResourceComponentProvider baseline initialization and adjust merge behavior; add dependency excludes and a small debug-log enhancement.

Reviewed changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
libs/shared/build.gradle.kts Excludes guava/protobuf transitives from opentelemetry-cel-sampler to avoid dependency conflicts.
custom/src/test/java/com/solarwinds/opentelemetry/extensions/config/HostIdResourceUtilTest.java Updates unit test expectations after removing PID/host attribute assertions from HostIdResourceUtil.
custom/src/main/java/com/solarwinds/opentelemetry/extensions/SolarwindsPropertiesSupplier.java Adds default properties to enable upstream AWS/Azure resource detectors.
custom/src/main/java/com/solarwinds/opentelemetry/extensions/HostIdResourceProvider.java Forces SWO host-id resource provider to sort earliest via order().
custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/provider/ResourceComponentProvider.java Initializes accumulated resource safely and merges into it instead of replacing.
custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/provider/CustomConfigCustomizerProvider.java Changes declarative-config detector list construction to append upstream detectors after SWO detectors.
custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/HttpSettingsReader.java Adds serviceName and hostname to debug logging for settings fetch correlation.
custom/src/main/java/com/solarwinds/opentelemetry/extensions/config/HostIdResourceUtil.java Removes AWS/Azure-specific attribute writes; keeps MAC/Heroku/UAMS/K8s/hostname attributes.
build.gradle.kts Bumps agent version from 3.2.0 to 3.2.1.
.gitignore Ignores buildSrc/.kotlin/ artifacts.

@cheempz cheempz 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.

LGTM with the note that HTTP getSettings API no longer requires hostname, spec was recently updated accordingly.

@cleverchuk
cleverchuk merged commit 6274e5e into main Jul 20, 2026
18 checks passed
@cleverchuk
cleverchuk deleted the cc/NH-143670 branch July 20, 2026 20:26
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.

3 participants