Skip to content
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

fix(sdk-trace-base): don't load envs top level #5233

Merged

Conversation

lucacasonato
Copy link
Contributor

@lucacasonato lucacasonato commented Dec 4, 2024

Which problem is this PR solving? / Short description of the changes

Right now @opentelemetry/sdk-trace-base loads OTEL_* env vars when it is loaded, regardless of if loadDefaultConfig is ever called. In runtimes with a permission model like Deno, this may cause a bunch of permission prompts right on startup. This PR changes the env vars to all be loaded when loadDefaultConfig is called.

Interestingly, previously only buildSamplerFromEnv used the "global" env vars. For all other options the env vars are re-read on every call to loadDefaultConfig.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

I have tested locally that Deno does not prompt for env vars on startup anymore when @opentelemetry/sdk-trace-base is loaded.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added N/A
  • Documentation has been updated N/A

@lucacasonato lucacasonato requested a review from a team as a code owner December 4, 2024 17:52
Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

Looks good, thanks 👍
Please also add an entry in CHANGELOG.md 🙂

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.60%. Comparing base (85dcbc7) to head (ffe6c22).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5233      +/-   ##
==========================================
- Coverage   94.60%   94.60%   -0.01%     
==========================================
  Files         315      315              
  Lines        8012     8011       -1     
  Branches     1617     1617              
==========================================
- Hits         7580     7579       -1     
  Misses        432      432              
Files with missing lines Coverage Δ
...ackages/opentelemetry-sdk-trace-base/src/config.ts 88.37% <100.00%> (-0.27%) ⬇️

Right now `@opentelemetry/sdk-trace-base` loads `OTEL_*` env vars when it is loaded, regardless of if `loadDefaultConfig` is ever called. In runtimes with a permission model like Deno, this may cause a bunch of permission prompts right on startup. This PR changes the env vars to all be loaded when `loadDefaultConfig` is called.

Interestingly, previously only `buildSamplerFromEnv` used the "global" env vars. For all other options the env vars are re-read on every call to `loadDefaultConfig`.
@lucacasonato lucacasonato force-pushed the dont_load_env_top_level branch from b31a8cd to ffe6c22 Compare December 4, 2024 18:28
@pichlermarc pichlermarc enabled auto-merge December 4, 2024 18:52
@pichlermarc pichlermarc disabled auto-merge December 4, 2024 19:24
@pichlermarc pichlermarc added this pull request to the merge queue Dec 4, 2024
Merged via the queue into open-telemetry:main with commit 97dff5b Dec 4, 2024
21 checks passed
@lucacasonato lucacasonato deleted the dont_load_env_top_level branch December 4, 2024 22:24
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