-
Notifications
You must be signed in to change notification settings - Fork 805
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
Add platform agnostic way to read environment variables #1191
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1191 +/- ##
=======================================
Coverage 93.29% 93.29%
=======================================
Files 124 126 +2
Lines 3567 3597 +30
Branches 715 724 +9
=======================================
+ Hits 3328 3356 +28
- Misses 239 241 +2
|
packages/opentelemetry-core/src/platform/browser/environment.ts
Outdated
Show resolved
Hide resolved
@open-telemetry/javascript-maintainers @open-telemetry/javascript-approvers ^^ |
* Gets the environment variables | ||
*/ | ||
export function getEnv(): ENVIRONMENT { | ||
const globalEnv = parseEnvironment((window as unknown) as ENVIRONMENT_MAP); |
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.
instead of asserting window
twice can we do const _window = window as typeof window & ENVIRONMENT_MAP
like we did in the API package for global?
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.
ENVIRONMENT_MAP should be made partial. The types will not force you to check if a value exists in this current setup.
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.
not sure if I understand correctly your last sentence about partial ?
* fix(restify): upgrade package to fix type problem * fix(restify): updated so types are not leaking through open-telemetry#1132 * fix(restify): lint fix * fix(restify): final fix up for linter * style: avoid checking in manually edited package.json * test: require restify again for every test * test: differenciate between thorwing and failing gracefully * test: use custom error * feat: support restify@5 * feat: support restify@7 * feat: support restify@8 * test: cleanup * test: anyfy arguments on the anonymous handler * chore: add tav + update supported versions * fix: turn off tests on node@18 which is not supported for restify * refactor: remove the import to after setting up instrumentation Co-authored-by: jscherer92 <jscherer92@gmail.com>
Which problem is this PR solving?
Short description of the changes