Skip to content

Commit

Permalink
feat(core): drop getEnv(), getEnvWithoutDefaults()
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc committed Feb 17, 2025
1 parent e4381fc commit 0ce2c04
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 619 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se
* (user-facing): all configuration previously possible via `window.OTEL_*` is now not supported anymore
* If you have been using the `envDetector` in browser environments, please migrate to manually creating a resource.
* Note: Node.js environment variable configuration continues to work as-is.
* feat(core)!: drop `getEnv()`, `getEnvWithoutDefaults()` [#????](https://github.com/open-telemetry/opentelemetry-js/pull/????) @pichlermarc
* (user-facing): `getEnv()` has been replaced by `getStringFromEnv()`, `getNumberFromEnv()`, `getBooleanFromEnv()`, `getStringListFromEnv()`
* these new functions do not include defaults, please inline any defaults if necessary (example: `getStringFromEnv("OTEL_FOO") ?? "my-default"`)
* (user-facing): `getEnvWithoutDefaults()` has been replaced by `getStringFromEnv()`, `getNumberFromEnv()`, `getBooleanFromEnv()`, `getStringListFromEnv()`
* (user-facing): `DEFAULT_ENVIRONMENT` has been removed, please inline any defaults from now on
* (user-facing): `ENVIRONMENT` has been removed without replacement
* (user-facing): `RAW_ENVIRONMENT` has been removed without replacement
* (user-facing): `parseEnvironment` has been removed without replacement

### :rocket: (Enhancement)

Expand Down
6 changes: 0 additions & 6 deletions packages/opentelemetry-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export { parseKeyPairsIntoRecord } from './baggage/utils';
export {
SDK_INFO,
_globalThis,
getEnv,
getEnvWithoutDefaults,
getStringFromEnv,
getBooleanFromEnv,
getNumberFromEnv,
Expand Down Expand Up @@ -77,12 +75,8 @@ export { TraceState } from './trace/TraceState';
export {
DEFAULT_ATTRIBUTE_COUNT_LIMIT,
DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,
DEFAULT_ENVIRONMENT,
DEFAULT_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT,
DEFAULT_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT,
ENVIRONMENT,
RAW_ENVIRONMENT,
parseEnvironment,
} from './utils/environment';
export { merge } from './utils/merge';
export { TimeoutError, callWithTimeout } from './utils/timeout';
Expand Down
22 changes: 0 additions & 22 deletions packages/opentelemetry-core/src/platform/browser/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,6 @@
* limitations under the License.
*/

import {
DEFAULT_ENVIRONMENT,
ENVIRONMENT,
RAW_ENVIRONMENT,
parseEnvironment,
} from '../../utils/environment';
import { _globalThis } from './globalThis';

/**
* Gets the environment variables
*/
export function getEnv(): Required<ENVIRONMENT> {
const globalEnv = parseEnvironment(
_globalThis as typeof globalThis & RAW_ENVIRONMENT
);
return Object.assign({}, DEFAULT_ENVIRONMENT, globalEnv);
}

export function getStringFromEnv(_: string): string | undefined {
return undefined;
}
Expand All @@ -47,7 +29,3 @@ export function getNumberFromEnv(_: string): boolean | undefined {
export function getStringListFromEnv(_: string): string[] | undefined {
return undefined;
}

export function getEnvWithoutDefaults(): ENVIRONMENT {
return parseEnvironment(_globalThis as typeof globalThis & RAW_ENVIRONMENT);
}
2 changes: 0 additions & 2 deletions packages/opentelemetry-core/src/platform/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/

export {
getEnvWithoutDefaults,
getEnv,
getStringFromEnv,
getBooleanFromEnv,
getNumberFromEnv,
Expand Down
2 changes: 0 additions & 2 deletions packages/opentelemetry-core/src/platform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
export {
SDK_INFO,
_globalThis,
getEnv,
getEnvWithoutDefaults,
otperformance,
unrefTimer,
getBooleanFromEnv,
Expand Down
18 changes: 0 additions & 18 deletions packages/opentelemetry-core/src/platform/node/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,9 @@
* limitations under the License.
*/

import {
DEFAULT_ENVIRONMENT,
ENVIRONMENT,
RAW_ENVIRONMENT,
parseEnvironment,
} from '../../utils/environment';
import { diag } from '@opentelemetry/api';
import { inspect } from 'util';

/**
* Gets the environment variables
*/
export function getEnv(): Required<ENVIRONMENT> {
const processEnv = parseEnvironment(process.env as RAW_ENVIRONMENT);
return Object.assign({}, DEFAULT_ENVIRONMENT, processEnv);
}

/**
* Retrieves a number from an environment variable.
* - Returns `undefined` if the environment variable is empty, unset, contains only whitespace, or is not a number.
Expand Down Expand Up @@ -117,7 +103,3 @@ export function getStringListFromEnv(key: string): string[] | undefined {
.map(v => v.trim())
.filter(s => s !== '');
}

export function getEnvWithoutDefaults(): ENVIRONMENT {
return parseEnvironment(process.env as RAW_ENVIRONMENT);
}
2 changes: 0 additions & 2 deletions packages/opentelemetry-core/src/platform/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/

export {
getEnvWithoutDefaults,
getEnv,
getStringFromEnv,
getBooleanFromEnv,
getNumberFromEnv,
Expand Down
Loading

0 comments on commit 0ce2c04

Please # to comment.