Skip to content

Conversation

robsunday
Copy link
Contributor

Until now the resource stored as a property of AutoConfiguredOpenTelemetrySdk object was always a resource obtained by calling Resource.getDefault(), which means it was not set up basing on content of YAML config file.
This PR is a proposal of fix for this issue.

Copy link

codecov bot commented Jun 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.01%. Comparing base (cfb959b) to head (08fe64e).
⚠️ Report is 124 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #7418   +/-   ##
=========================================
  Coverage     90.01%   90.01%           
- Complexity     7080     7083    +3     
=========================================
  Files           803      803           
  Lines         21417    21432   +15     
  Branches       2086     2086           
=========================================
+ Hits          19278    19293   +15     
  Misses         1477     1477           
  Partials        662      662           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

return AutoConfiguredOpenTelemetrySdk.create(
sdk, Resource.getDefault(), null, configProvider);

Resource configuredResource = createResourceFromModel(model, componentLoader);
Copy link
Member

Choose a reason for hiding this comment

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

This means that we are calling ResourceFactory twice, but the alternative is for DeclarativeConfiguration#create to return a tuple of OpenTelemetrySdk and Resource such that the resource is accessible, which isn't great either.

I actually want to get rid of the incubating API to access the autoconfigured resource. Its come up in a variety of conversations (including this comment), but the TL;DR is:

The problem with accessing the autoconfigured resource is that in all the cases I've seen so far, its always been the wrong thing to do.

Copy link
Contributor Author

@robsunday robsunday Jun 13, 2025

Choose a reason for hiding this comment

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

Returning tuple from DeclarativeConfiguration#create would actually require updates of OpenTelemetryConfigurationFactory#create. This would also require some additional classes and maybe reane of OpenTelemetryConfigurationFactory.
I think instantiating resource twice is good enough solution.

Regarding the change you mentioned:

I actually want to get rid of the incubating API to access the autoconfigured resource

Do you plan to get rid of the resource property and getResource metod from AutoConfiguredOpenTelemetrySdk class?
If yes, then it may cause lots of issues in some vendor's code. We use it in our code in few places.

Copy link
Member

Choose a reason for hiding this comment

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

If yes, then it may cause lots of issues in some vendor's code. We use it in our code in few places.

I know, but why? I'm still searching for a compelling reason vendors do this. Every instance I've seen so far has been dubious.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@robsunday robsunday marked this pull request as ready for review July 8, 2025 11:05
@robsunday robsunday requested a review from a team as a code owner July 8, 2025 11:05
@zeitlinger
Copy link
Member

I've create an alternative PR that doesn't expose Resource more than already - which addresses @jack-berg 's point.

It also runs the customizers - which is a bug in this PR.

@robsunday robsunday closed this Sep 26, 2025
@robsunday
Copy link
Contributor Author

More refined solution to the issue provided in #7639

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.

3 participants