Skip to content
New issue

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

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

Already on GitHub? # to your account

feat(sdk-trace-base)!: do not read environment variables from window #5455

Conversation

pichlermarc
Copy link
Member

@pichlermarc pichlermarc commented Feb 12, 2025

Which problem is this PR solving?

Migrates from getEnv() to using the new get*FromEnv() methods added in #5443. Also inlines the defaults. This drops
"env var configuration" (via window.OTEL_* ) in browser environments. As such I had to move some tests to different places to ensure they only run in the correct context.

This breaking change now will enable us to split the env var config code completely in a non-breaking feature release later.

Refs #5217

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • Unit tests

Copy link

codecov bot commented Feb 12, 2025

Codecov Report

Attention: Patch coverage is 92.30769% with 2 lines in your changes missing coverage. Please review.

Project coverage is 94.97%. Comparing base (cc7aa3c) to head (0f331dc).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...kages/opentelemetry-sdk-trace-base/karma.worker.js 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5455      +/-   ##
==========================================
+ Coverage   94.94%   94.97%   +0.02%     
==========================================
  Files         309      309              
  Lines        8016     8016              
  Branches     1699     1704       +5     
==========================================
+ Hits         7611     7613       +2     
+ Misses        405      403       -2     
Files with missing lines Coverage Δ
...ackages/opentelemetry-sdk-trace-base/src/config.ts 93.33% <100.00%> (+4.96%) ⬆️
...dk-trace-base/src/export/BatchSpanProcessorBase.ts 95.27% <100.00%> (-0.04%) ⬇️
...ckages/opentelemetry-sdk-trace-base/src/utility.ts 100.00% <100.00%> (ø)
...kages/opentelemetry-sdk-trace-base/karma.worker.js 0.00% <0.00%> (ø)

@pichlermarc pichlermarc force-pushed the feat/migrate-from-getenv-sdk-trace-base branch from f80a79e to 245c6f8 Compare February 12, 2025 14:22
@pichlermarc pichlermarc added target:next-major-release This PR targets the next major release (`next` branch) pkg:sdk-trace-base labels Feb 12, 2025
@pichlermarc pichlermarc marked this pull request as ready for review February 12, 2025 14:23
@pichlermarc pichlermarc requested a review from a team as a code owner February 12, 2025 14:23
});
default:
diag.error(
`OTEL_TRACES_SAMPLER value "${environment.OTEL_TRACES_SAMPLER} invalid, defaulting to ${FALLBACK_OTEL_TRACES_SAMPLER}".`
`OTEL_TRACES_SAMPLER value "${sampler} invalid, defaulting to ${FALLBACK_OTEL_TRACES_SAMPLER}".`
);
return new AlwaysOnSampler();
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to this PR: it strikes me as wrong that ParentBasedAlwaysOn is the default if not specified, but a different value (AlwaysOnSampler) is the fallback if the given value is unknown.

I opened #5476 for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

that is indeed wrong - thank you for opening the issue.

@pichlermarc pichlermarc added this pull request to the merge queue Feb 17, 2025
Merged via the queue into open-telemetry:main with commit e4381fc Feb 17, 2025
18 checks passed
@pichlermarc pichlermarc deleted the feat/migrate-from-getenv-sdk-trace-base branch February 17, 2025 11:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
pkg:sdk-trace-base target:next-major-release This PR targets the next major release (`next` branch)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants