Skip to content

Resource in AutoConfiguredOpenTelemetrySdk object is configured from the 'resource' YAML node #7418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

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 89.75%. Comparing base (2eb84bf) to head (14f0b08).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #7418   +/-   ##
=========================================
  Coverage     89.75%   89.75%           
- Complexity     6980     6983    +3     
=========================================
  Files           797      797           
  Lines         21165    21180   +15     
  Branches       2057     2057           
=========================================
+ Hits          18996    19011   +15     
  Misses         1505     1505           
  Partials        664      664           

☔ 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.

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.

2 participants