fix(core): align inconsistent behavior of getEnv() and getEnvWithoutDefaults() when a process polyfill is used (#4649)
* fix(core): align inconsistent behavior of getEnv() and getEnvWithoutDefaults() when a process polyfill is used * Update CHANGELOG.md
This commit is contained in:
parent
8079fd6880
commit
141b457b85
|
|
@ -13,6 +13,11 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
|
||||||
|
|
||||||
### :bug: (Bug Fix)
|
### :bug: (Bug Fix)
|
||||||
|
|
||||||
|
* fix(core): align inconsistent behavior of `getEnv()` and `getEnvWithoutDefaults()` when a `process` polyfill is used [#4648](https://github.com/open-telemetry/opentelemetry-js/pull/4648) @pichlermarc
|
||||||
|
* `getEnvWithoutDefaults()` would use `process.env` if it was defined when running in a browser, while `getEnv()` would always use `_globalThis`. Now both use `_globalThis` when running in a browser.
|
||||||
|
* fix(resources): prevent circular import (resource -> detector -> resource -> ...) [#4653](https://github.com/open-telemetry/opentelemetry-js/pull/4653) @pichlermarc
|
||||||
|
* fixes a circular import warning which would appear in rollup when bundling `@opentelemetry/resources`
|
||||||
|
|
||||||
### :books: (Refine Doc)
|
### :books: (Refine Doc)
|
||||||
|
|
||||||
### :house: (Internal)
|
### :house: (Internal)
|
||||||
|
|
@ -29,8 +34,6 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
|
||||||
|
|
||||||
* fix(sdk-trace-web): fix invalid timings in span events [#4486](https://github.com/open-telemetry/opentelemetry-js/pull/4486) @Abinet18
|
* fix(sdk-trace-web): fix invalid timings in span events [#4486](https://github.com/open-telemetry/opentelemetry-js/pull/4486) @Abinet18
|
||||||
* fix(resources): ensure BrowserDetector does not think Node.js v21 is a browser [#4561](https://github.com/open-telemetry/opentelemetry-js/issues/4561) @trentm
|
* fix(resources): ensure BrowserDetector does not think Node.js v21 is a browser [#4561](https://github.com/open-telemetry/opentelemetry-js/issues/4561) @trentm
|
||||||
* fix(resources): prevent circular import (resource -> detector -> resource -> ...) [#4653](https://github.com/open-telemetry/opentelemetry-js/pull/4653) @pichlermarc
|
|
||||||
* fixes a circular import warning which would appear in rollup when bundling `@opentelemetry/resources`
|
|
||||||
|
|
||||||
## 1.23.0
|
## 1.23.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,3 +31,7 @@ export function getEnv(): Required<ENVIRONMENT> {
|
||||||
);
|
);
|
||||||
return Object.assign({}, DEFAULT_ENVIRONMENT, globalEnv);
|
return Object.assign({}, DEFAULT_ENVIRONMENT, globalEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getEnvWithoutDefaults(): ENVIRONMENT {
|
||||||
|
return parseEnvironment(_globalThis as typeof globalThis & RAW_ENVIRONMENT);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './environment';
|
export { getEnvWithoutDefaults, getEnv } from './environment';
|
||||||
export * from './globalThis';
|
export * from './globalThis';
|
||||||
export * from './hex-to-base64';
|
export * from './hex-to-base64';
|
||||||
export * from './RandomIdGenerator';
|
export * from './RandomIdGenerator';
|
||||||
|
|
|
||||||
|
|
@ -28,3 +28,7 @@ export function getEnv(): Required<ENVIRONMENT> {
|
||||||
const processEnv = parseEnvironment(process.env as RAW_ENVIRONMENT);
|
const processEnv = parseEnvironment(process.env as RAW_ENVIRONMENT);
|
||||||
return Object.assign({}, DEFAULT_ENVIRONMENT, processEnv);
|
return Object.assign({}, DEFAULT_ENVIRONMENT, processEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getEnvWithoutDefaults(): ENVIRONMENT {
|
||||||
|
return parseEnvironment(process.env as RAW_ENVIRONMENT);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './environment';
|
export { getEnvWithoutDefaults, getEnv } from './environment';
|
||||||
export * from './globalThis';
|
export * from './globalThis';
|
||||||
export * from './hex-to-base64';
|
export * from './hex-to-base64';
|
||||||
export * from './RandomIdGenerator';
|
export * from './RandomIdGenerator';
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
import { DiagLogLevel } from '@opentelemetry/api';
|
import { DiagLogLevel } from '@opentelemetry/api';
|
||||||
import { TracesSamplerValues } from './sampling';
|
import { TracesSamplerValues } from './sampling';
|
||||||
import { _globalThis } from '../platform/browser/globalThis';
|
|
||||||
|
|
||||||
const DEFAULT_LIST_SEPARATOR = ',';
|
const DEFAULT_LIST_SEPARATOR = ',';
|
||||||
|
|
||||||
|
|
@ -369,13 +368,3 @@ export function parseEnvironment(values: RAW_ENVIRONMENT): ENVIRONMENT {
|
||||||
|
|
||||||
return environment;
|
return environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get environment in node or browser without
|
|
||||||
* populating default values.
|
|
||||||
*/
|
|
||||||
export function getEnvWithoutDefaults(): ENVIRONMENT {
|
|
||||||
return typeof process !== 'undefined' && process && process.env
|
|
||||||
? parseEnvironment(process.env as RAW_ENVIRONMENT)
|
|
||||||
: parseEnvironment(_globalThis as typeof globalThis & RAW_ENVIRONMENT);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue