Skip to content

[CONFIGURATION] Complete resource detection support in SdkBuilder - #4424

Merged
dbarker merged 9 commits into
open-telemetry:mainfrom
mateenali66:feat/4411-sdkbuilder-resource-detection
Aug 15, 2026
Merged

[CONFIGURATION] Complete resource detection support in SdkBuilder#4424
dbarker merged 9 commits into
open-telemetry:mainfrom
mateenali66:feat/4411-sdkbuilder-resource-detection

Conversation

@mateenali66

@mateenali66 mateenali66 commented Aug 13, 2026

Copy link
Copy Markdown
Member

Fixes #4411

Changes

Implements the remaining resource detection support in SdkBuilder::SetResource, per the required behavior on the issue:

  • Detector dispatch: a ResourceDetectorBuilder visitor (same pattern as SpanExporterBuilder) resolves container, host, process and service to their registry builders, and any other name to an extension detector builder looked up by name. A missing builder throws UnsupportedException, consistent with the other Create* methods.
  • Attribute filter: the merged detected resource is filtered with detection.attributes using sdk::common::WildcardMatch. Absent included passes all keys, excluded is applied after included and wins. The filter applies to detected attributes only.
  • Merge priority, lowest first: Resource::GetDefault(), detected resource (filtered), attributes_list, then attributes with schema_url from the model. Merging relies on the documented behavior that the updating resource wins on key conflicts and an empty updating schema url preserves the current one.

Behavior note, called out in the changelog: SetResource no longer goes through Resource::Create(), so it no longer runs OTELResourceDetector (the OTEL_RESOURCE_ATTRIBUTES env var) and no longer injects a default service.name. Neither is part of the configuration model, and Resource::Create() cannot express the required merge order.

The example yaml files listed detectors that nothing registers (they were ignored until now), which the new error behavior turns into SDK build failures. Those entries move to comments until the example registers builders for them; the my_custom_detector entry comes back with #4419 (PR #4423), which registers the extension builder.

Tests cover the dispatch (typed and extension, with a spy builder), the unregistered-detector failure, the filter semantics (wildcard include, excluded-beats-included, default resource untouched), the four-level merge priority on a conflicting key, and the schema url.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
@mateenali66
mateenali66 requested a review from a team as a code owner August 13, 2026 08:05
…elog

Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.70707% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.62%. Comparing base (895f49f) to head (62ff397).

Files with missing lines Patch % Lines
sdk/src/configuration/sdk_builder.cc 70.71% 29 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4424      +/-   ##
==========================================
+ Coverage   82.59%   82.62%   +0.04%     
==========================================
  Files         511      511              
  Lines       20039    20132      +93     
==========================================
+ Hits        16550    16633      +83     
- Misses       3489     3499      +10     
Files with missing lines Coverage Δ
...lude/opentelemetry/sdk/configuration/sdk_builder.h 100.00% <ø> (ø)
sdk/src/configuration/sdk_builder.cc 61.11% <70.71%> (+2.12%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

… builder

A configured detector without a registered builder now fails the SDK
build by design, so the aspirational detector entries in the example
yaml files move to comments until the example registers builders for
them. The my_custom_detector entry returns with open-telemetry#4419.

Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
Signed-off-by: Mateen Anjum <mateenali66@gmail.com>

@dbarker dbarker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you! Please see non blocking feedback below.

Comment thread examples/configuration/kitchen-sink.yaml Outdated
Comment thread examples/configuration/sdk-default.yaml Outdated
Comment thread sdk/test/configuration/sdk_builder_test.cc
mateenali66 and others added 4 commits August 13, 2026 10:10
Per review: kitchen-sink keeps the container and process detectors
enabled (the yaml maintainer CI job now builds with
WITH_RESOURCE_DETECTORS_PREVIEW so their builders are registered),
sdk-default exercises the detection node with the attribute filter and
no detectors, plus attributes_list and schema_url, and a test verifies
the filter does not apply to attributes and attributes_list.

Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
…eview

The example yaml tests also run in the OS matrix jobs, which enable
WITH_CONFIGURATION without WITH_RESOURCE_DETECTORS_PREVIEW, so the
kitchen-sink detectors have no registered builders there. The test now
runs only where the preview flag registers them, which includes the
yaml maintainer job.

Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
…r-resource-detection

# Conflicts:
#	CHANGELOG.md
#	examples/configuration/extensions.yaml

@marcalff marcalff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the contribution.

@dbarker
dbarker merged commit 60c3d11 into open-telemetry:main Aug 15, 2026
73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CONFIGURATION] Complete resource detection support in SdkBuilder

3 participants