[core] make browser-implementation of getEnv() return only defaults, getEnvWithoutDefaults() an empty object #5217
Labels
needs:code-contribution
This feature/bug is ready to implement
pkg:core
target:next-major-release
This PR targets the next major release (`next` branch)
type:feature
A feature with no sub-issues to address
Milestone
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: