-
Notifications
You must be signed in to change notification settings - Fork 827
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
[core] make browser-implementation of getEnv() return only defaults, getEnvWithoutDefaults() an empty object #5217
Comments
@pichlermarc do you feel confident that all the configs currently settable via If you currently set one of the Some variables have no obvious replacement (that I could find). For example, #4897 plan on using the So if we are going ahead with this, I think we'd have to:
That seems like a pretty significant lift to me, but perhaps it feels more tractable to someone with more context. Alternatively, here is a counterproposal that would capture most of the same benefits, but less aggressive:
Benefits:
As far as reducing the test and code complexity, so far I am not sure that would be the case anyway. As you pointed out, most of the code consuming Part of the issue I ran into when implementing this is precisely that – the current tests are written to both 1. test that setting the ENV variable has the desired effect, and 2. test the functionality of said "desired effect". Since even under the original proposal, this should continue to work in Node, we still need the tests for (1) in Node, but it's hard to test that without actually test the functionality, so it ends up requiring the tests to be duplicated (plus a lot of adaptation to the existing test that resulted in more elaborate setup). |
@chancancode thanks for the detailed write-up - yes you're right it's a pretty significant change with lots of moving parts, I think this needs some more thought so I'll apply the The long-term goal is to remove "automatic configuration" via environment variables (or env-var like config in the case of the web implementations) from the plain SDK packages I'll put this on ice right now since there are some other changes I'm thinking of (and that I did not write down yet) which may make this change here significantly easier. |
I'll update the issue once we've come up with a more comprehensive plan. |
Description
Important
Only actionable for
next
branch. Any PRs opened for this MUST be based on and targeted at thenext
branch.The
@opentelemetry/core
package contains a browser implementation ofgetEnv()
that attempts to get the configuration from the_globalThis
(similar to getting env vars fromprocess.env
in Node.js). This behvaiorSince removing
getEnv()
completely would be quite an undertaking and would result in a large, difficult to review PR, this issue focuses on:getEnv()
andgetEnvWithoutDefaults()
so that it does not extract config from_globalThis
npm run test:browser
script) that tested this behavior.Since the behavior is then not present anymore when we release 2.0, removing
getEnv()
usage for browser code can be a non-breaking change and can be done in a feature-release. We can remove usages ofgetEnv()
andgetEnvWithoutDefaults()
step-by-step throughout the code base as a clean-up in feature releases. This should yield bundle-size improvements and an eventual further reduction of code-complexity.This issue is considered done when:
getEnv()
has been changed returns a copy ofDEFAULT_ENVIRONMENT
for the browser implementationgetEnvWithoutDefaults()
has been changed to return a new empty object for the browser implementationcommon
directories) - you may have to adapt some tests and move them to different directories so that the only run on Node.jsgetEnv()
andgetEnvWithoutDefaults()
in a feature release has been createdCode location
opentelemetry-js/packages/opentelemetry-core/src/platform/browser/environment.ts
Lines 28 to 37 in 141b457
The text was updated successfully, but these errors were encountered: