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
Delay evaluation of resource.Default to first call #2371
Conversation
|
Codecov Report
@@ Coverage Diff @@
## main #2371 +/- ##
=======================================
- Coverage 73.8% 73.8% -0.1%
=======================================
Files 175 175
Lines 12430 12439 +9
=======================================
+ Hits 9184 9185 +1
- Misses 3012 3017 +5
- Partials 234 237 +3
|
/easycla |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks good to me. Can you add an entry to the changelog describing the changed behavior to the end user?
Thanks very much, all. Cheers! 👍 |
Currently
defaultResource
(which includes data calculated by parsing env varOTEL_RESOURCE_ATTRIBUTES
) is evaluated as an import side effect. Some applications might want to update that variable with go code (eg to load extra env vars from a configuration file, for example using https://github.com/joho/godotenv). By only evaluating it the first timeresource.Default()
is called, we can allow those applications an opportunity to setOTEL_RESOURCE_ATTRIBUTES
first, while still only calculating the value once.