opentelemetry-js
opentelemetry-js copied to clipboard
Feat get env memo
Which problem is this PR solving?
- node
getEnv()is invoked every time an env var is accessed. This causes parsing of allDEFAULT_ENVIRONMENTevery invocation. HOSTNAMEwas set byos.hostname()and then immediately overwritten by theDEFAULT_ENVIRONMENT.
Fixes # (issue)
- Use module-level cache for the env.
- Remove the setting of
HOSTNAMEviaos.hostname().
Short description of the changes
getEnv() will use module-level cache.
calculateEnv() is separated from getEnv() for better separation and for testing purposes.
os.hostname() removed from getEnv().
Type of change
- [ ] New feature (non-breaking change which adds functionality)
How Has This Been Tested?
- [ ] First(no cache) and second(with cache) invocation results are using the same object.
Thank you for your work on this!
Codecov Report
Merging #3496 (6a52c25) into main (47444f2) will increase coverage by
0.01%. The diff coverage is100.00%.
:exclamation: Current head 6a52c25 differs from pull request most recent head 1b3db7e. Consider uploading reports for the commit 1b3db7e to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## main #3496 +/- ##
==========================================
+ Coverage 94.01% 94.03% +0.01%
==========================================
Files 268 268
Lines 7920 7927 +7
Branches 1641 1642 +1
==========================================
+ Hits 7446 7454 +8
+ Misses 474 473 -1
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...pentelemetry-core/src/platform/node/environment.ts | 100.00% <100.00%> (ø) |
|
| ...-trace-base/src/platform/node/RandomIdGenerator.ts | 93.75% <0.00%> (+6.25%) |
:arrow_up: |
@RazGvili was excited to see this but the tests weren't passing and i haven't seen anything in a while. are you still working on this?
@dyladan I think I can finish it this week.
The env memo requires a clear afterEach test, for all the repos using the getEnv.
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.