fix: ReferenceError when OTEL_TRACES_SAMPLER used without OTEL_TRACES_SAMPLER_ARG#2434
Merged
obecny merged 1 commit intoopen-telemetry:mainfrom Aug 27, 2021
Merged
Conversation
When OTEL_TRACES_SAMPLER is used without OTEL_TRACES_SAMPLER_ARG there would be a ReferenceError due to getSamplerProbabilityFromEnv being called above the definition of DEFAULT_RATIO.
```
ReferenceError: Cannot access 'DEFAULT_RATIO' before initialization
at null.getSamplerProbabilityFromEnv (/app/node_modules/@opentelemetry/tracing/src/config.ts:91:58)
at null.buildSamplerFromEnv (/app/node_modules/@opentelemetry/tracing/src/config.ts:71:44)
at Object.<anonymous> (/app/node_modules/@opentelemetry/tracing/src/config.ts:38:12)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:784:16)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (/app/node_modules/@opentelemetry/tracing/src/utility.ts:17:1)```
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
Signed the CLA. Please recheck. |
Flarna
approved these changes
Aug 27, 2021
Codecov Report
@@ Coverage Diff @@
## main #2434 +/- ##
==========================================
- Coverage 92.70% 92.55% -0.15%
==========================================
Files 137 134 -3
Lines 4990 4865 -125
Branches 1054 1033 -21
==========================================
- Hits 4626 4503 -123
+ Misses 364 362 -2 |
dyladan
approved these changes
Aug 27, 2021
This comment has been minimized.
This comment has been minimized.
obecny
approved these changes
Aug 27, 2021
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
When OTEL_TRACES_SAMPLER is used without OTEL_TRACES_SAMPLER_ARG there would be a ReferenceError due to getSamplerProbabilityFromEnv being called above the definition of DEFAULT_RATIO.
Short description of the changes
Moving constant higher up in the code.