From 229cc7536fbfb77da42671e51283870e48322daf Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Tue, 28 Jun 2022 17:52:51 -0500 Subject: [PATCH 01/15] chore(sdk-trace-base): update span attribute length and count to consider valued defined in env Signed-off-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> --- .../src/utility.ts | 34 ++++++++-- .../test/common/BasicTracerProvider.test.ts | 63 +++++++++++++++++++ 2 files changed, 93 insertions(+), 4 deletions(-) diff --git a/packages/opentelemetry-sdk-trace-base/src/utility.ts b/packages/opentelemetry-sdk-trace-base/src/utility.ts index 3492f3b050..b044fe1f60 100644 --- a/packages/opentelemetry-sdk-trace-base/src/utility.ts +++ b/packages/opentelemetry-sdk-trace-base/src/utility.ts @@ -17,6 +17,10 @@ import { Sampler } from '@opentelemetry/api'; import { buildSamplerFromEnv, DEFAULT_CONFIG } from './config'; import { SpanLimits, TracerConfig, GeneralLimits } from './types'; +import { + DEFAULT_ATTRIBUTE_COUNT_LIMIT, + DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT +} from '@opentelemetry/core'; /** * Function to merge Default configuration (as specified in './config') with @@ -65,16 +69,38 @@ export function reconfigureLimits(userConfig: TracerConfig): TracerConfig { * When span attribute count limit is not defined, but general attribute count limit is defined * Then, span attribute count limit will be same as general one */ - if (spanLimits.attributeCountLimit == null && userConfig.generalLimits?.attributeCountLimit != null) { - spanLimits.attributeCountLimit = userConfig.generalLimits.attributeCountLimit; + if ( + spanLimits.attributeCountLimit == null && + (DEFAULT_CONFIG.spanLimits.attributeCountLimit === DEFAULT_ATTRIBUTE_COUNT_LIMIT) && + ( + userConfig.generalLimits?.attributeCountLimit != null || + DEFAULT_CONFIG.generalLimits.attributeCountLimit !== DEFAULT_ATTRIBUTE_COUNT_LIMIT + ) + ) { + const attributeCountLimit = + userConfig.generalLimits?.attributeCountLimit ?? + DEFAULT_CONFIG.generalLimits.attributeCountLimit; + + spanLimits.attributeCountLimit = attributeCountLimit; } /** * When span attribute value length limit is not defined, but general attribute value length limit is defined * Then, span attribute value length limit will be same as general one */ - if (spanLimits.attributeValueLengthLimit == null && userConfig.generalLimits?.attributeValueLengthLimit != null) { - spanLimits.attributeValueLengthLimit = userConfig.generalLimits.attributeValueLengthLimit; + if ( + spanLimits.attributeValueLengthLimit == null && + (DEFAULT_CONFIG.spanLimits.attributeValueLengthLimit === DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT) && + ( + userConfig.generalLimits?.attributeValueLengthLimit != null || + DEFAULT_CONFIG.generalLimits.attributeValueLengthLimit !== DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT + ) + ) { + const attributeValueLengthLimit = + userConfig.generalLimits?.attributeValueLengthLimit ?? + DEFAULT_CONFIG.generalLimits.attributeValueLengthLimit; + + spanLimits.attributeValueLengthLimit = attributeValueLengthLimit; } return Object.assign({}, userConfig, { spanLimits }); diff --git a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts index e2b17bb561..613fd18629 100644 --- a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts +++ b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts @@ -634,3 +634,66 @@ describe('BasicTracerProvider', () => { }); }); }); + + +describe.skip('when attribute value length limit is defined via env', () => { + const envSource = process.env; + it('should have general attribute value length limits value as defined with env', () => { + envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '115'; + const tracer = new BasicTracerProvider().getTracer('default'); + const generalLimits = tracer.getGeneralLimits(); + assert.strictEqual(generalLimits.attributeValueLengthLimit, 115); + delete envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT; + }); + it('should have span attribute value length limits value same as general limit value', () => { + envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '125'; + const tracer = new BasicTracerProvider().getTracer('default'); + const generalLimits = tracer.getGeneralLimits(); + const spanLimits = tracer.getSpanLimits(); + assert.strictEqual(generalLimits.attributeValueLengthLimit, 125); + assert.strictEqual(spanLimits.attributeValueLengthLimit, 125); + delete envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT; + }); + it('should have span and general attribute value length limits as defined in env', () => { + envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '125'; + envSource.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT = '109'; + const tracer = new BasicTracerProvider().getTracer('default'); + const spanLimits = tracer.getSpanLimits(); + const generalLimits = tracer.getGeneralLimits(); + assert.strictEqual(generalLimits.attributeValueLengthLimit, 125); + assert.strictEqual(spanLimits.attributeValueLengthLimit, 109); + delete envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT; + delete envSource.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT; + }); +}); + +describe.skip('when attribute count limit is defined via env', () => { + const envSource = process.env; + it('should general attribute count limit as defined with env', () => { + envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '25'; + const tracer = new BasicTracerProvider({}).getTracer('default'); + const generalLimits = tracer.getGeneralLimits(); + assert.strictEqual(generalLimits.attributeCountLimit, 25); + delete envSource.OTEL_ATTRIBUTE_COUNT_LIMIT; + }); + it('should have span attribute countlimits value same as general limit value', () => { + envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '20'; + const tracer = new BasicTracerProvider().getTracer('default'); + const generalLimits = tracer.getGeneralLimits(); + const spanLimits = tracer.getSpanLimits(); + assert.strictEqual(generalLimits.attributeCountLimit, 20); + assert.strictEqual(spanLimits.attributeCountLimit, 20); + delete envSource.OTEL_ATTRIBUTE_COUNT_LIMIT; + }); + it('should have span and general attribute count limits as defined in env', () => { + envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '20'; + envSource.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = '35'; + const tracer = new BasicTracerProvider().getTracer('default'); + const spanLimits = tracer.getSpanLimits(); + const generalLimits = tracer.getGeneralLimits(); + assert.strictEqual(generalLimits.attributeCountLimit, 20); + assert.strictEqual(spanLimits.attributeCountLimit, 35); + delete envSource.OTEL_ATTRIBUTE_COUNT_LIMIT; + delete envSource.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT; + }); +}); From 98b96bc73fc82a11d76037a7e6811b140051d47c Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Wed, 29 Jun 2022 11:10:01 -0500 Subject: [PATCH 02/15] chore(sdk-trace-base): fix envs loading before tests Signed-off-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> --- .../src/BasicTracerProvider.ts | 4 +- .../src/config.ts | 35 ++--- .../src/utility.ts | 6 +- .../test/common/BasicTracerProvider.test.ts | 125 +++++++++--------- 4 files changed, 89 insertions(+), 81 deletions(-) diff --git a/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts b/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts index a964de5840..5fff77c5c5 100644 --- a/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts +++ b/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts @@ -31,7 +31,7 @@ import { } from '@opentelemetry/core'; import { Resource } from '@opentelemetry/resources'; import { SpanProcessor, Tracer } from '.'; -import { DEFAULT_CONFIG } from './config'; +import { loadDefaultConfig } from './config'; import { MultiSpanProcessor } from './MultiSpanProcessor'; import { NoopSpanProcessor } from './export/NoopSpanProcessor'; import { SDKRegistrationConfig, TracerConfig } from './types'; @@ -74,7 +74,7 @@ export class BasicTracerProvider implements TracerProvider { readonly resource: Resource; constructor(config: TracerConfig = {}) { - const mergedConfig = merge({}, DEFAULT_CONFIG, reconfigureLimits(config)); + const mergedConfig = merge({}, loadDefaultConfig(), reconfigureLimits(config)); this.resource = mergedConfig.resource ?? Resource.empty(); this.resource = Resource.default().merge(this.resource); this._config = Object.assign({}, mergedConfig, { diff --git a/packages/opentelemetry-sdk-trace-base/src/config.ts b/packages/opentelemetry-sdk-trace-base/src/config.ts index 4b364b3718..7895514597 100644 --- a/packages/opentelemetry-sdk-trace-base/src/config.ts +++ b/packages/opentelemetry-sdk-trace-base/src/config.ts @@ -30,25 +30,30 @@ const FALLBACK_OTEL_TRACES_SAMPLER = TracesSamplerValues.AlwaysOn; const DEFAULT_RATIO = 1; /** - * Default configuration. For fields with primitive values, any user-provided + * Load default configuration. For fields with primitive values, any user-provided * value will override the corresponding default value. For fields with * non-primitive values (like `spanLimits`), the user-provided value will be * used to extend the default value. */ -export const DEFAULT_CONFIG = { - sampler: buildSamplerFromEnv(env), - forceFlushTimeoutMillis: 30000, - generalLimits: { - attributeValueLengthLimit: getEnv().OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT, - attributeCountLimit: getEnv().OTEL_ATTRIBUTE_COUNT_LIMIT, - }, - spanLimits: { - attributeValueLengthLimit: getEnv().OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, - attributeCountLimit: getEnv().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, - linkCountLimit: getEnv().OTEL_SPAN_LINK_COUNT_LIMIT, - eventCountLimit: getEnv().OTEL_SPAN_EVENT_COUNT_LIMIT, - }, -}; + +// object needs to be wrapped in this function and called when needed otherwise +// envs are parsed before tests are ran - causes tests using these envs to fail +export function loadDefaultConfig() { + return { + sampler: buildSamplerFromEnv(env), + forceFlushTimeoutMillis: 30000, + generalLimits: { + attributeValueLengthLimit: getEnv().OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT, + attributeCountLimit: getEnv().OTEL_ATTRIBUTE_COUNT_LIMIT, + }, + spanLimits: { + attributeValueLengthLimit: getEnv().OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, + attributeCountLimit: getEnv().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, + linkCountLimit: getEnv().OTEL_SPAN_LINK_COUNT_LIMIT, + eventCountLimit: getEnv().OTEL_SPAN_EVENT_COUNT_LIMIT, + }, + }; +} /** * Based on environment, builds a sampler, complies with specification. diff --git a/packages/opentelemetry-sdk-trace-base/src/utility.ts b/packages/opentelemetry-sdk-trace-base/src/utility.ts index b044fe1f60..fd85844c28 100644 --- a/packages/opentelemetry-sdk-trace-base/src/utility.ts +++ b/packages/opentelemetry-sdk-trace-base/src/utility.ts @@ -15,7 +15,7 @@ */ import { Sampler } from '@opentelemetry/api'; -import { buildSamplerFromEnv, DEFAULT_CONFIG } from './config'; +import { buildSamplerFromEnv, loadDefaultConfig } from './config'; import { SpanLimits, TracerConfig, GeneralLimits } from './types'; import { DEFAULT_ATTRIBUTE_COUNT_LIMIT, @@ -35,6 +35,8 @@ export function mergeConfig(userConfig: TracerConfig): TracerConfig & { sampler: buildSamplerFromEnv(), }; + const DEFAULT_CONFIG = loadDefaultConfig(); + const target = Object.assign( {}, DEFAULT_CONFIG, @@ -65,6 +67,8 @@ export function mergeConfig(userConfig: TracerConfig): TracerConfig & { export function reconfigureLimits(userConfig: TracerConfig): TracerConfig { const spanLimits = Object.assign({}, userConfig.spanLimits); + const DEFAULT_CONFIG = loadDefaultConfig(); + /** * When span attribute count limit is not defined, but general attribute count limit is defined * Then, span attribute count limit will be same as general one diff --git a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts index 613fd18629..8e51a1f448 100644 --- a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts +++ b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts @@ -182,6 +182,68 @@ describe('BasicTracerProvider', () => { }); }); + describe('when attribute value length limit is defined via env', () => { + const envSource = process.env; + it('should have general attribute value length limits value as defined with env', () => { + envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '115'; + const tracer = new BasicTracerProvider().getTracer('default'); + const generalLimits = tracer.getGeneralLimits(); + assert.strictEqual(generalLimits.attributeValueLengthLimit, 115); + delete envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT; + }); + it('should have span attribute value length limits value same as general limit value', () => { + envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '125'; + const tracer = new BasicTracerProvider().getTracer('default'); + const generalLimits = tracer.getGeneralLimits(); + const spanLimits = tracer.getSpanLimits(); + assert.strictEqual(generalLimits.attributeValueLengthLimit, 125); + assert.strictEqual(spanLimits.attributeValueLengthLimit, 125); + delete envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT; + }); + it('should have span and general attribute value length limits as defined in env', () => { + envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '125'; + envSource.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT = '109'; + const tracer = new BasicTracerProvider().getTracer('default'); + const spanLimits = tracer.getSpanLimits(); + const generalLimits = tracer.getGeneralLimits(); + assert.strictEqual(generalLimits.attributeValueLengthLimit, 125); + assert.strictEqual(spanLimits.attributeValueLengthLimit, 109); + delete envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT; + delete envSource.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT; + }); + }); + + describe('when attribute count limit is defined via env', () => { + const envSource = process.env; + it('should general attribute count limit as defined with env', () => { + envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '25'; + const tracer = new BasicTracerProvider({}).getTracer('default'); + const generalLimits = tracer.getGeneralLimits(); + assert.strictEqual(generalLimits.attributeCountLimit, 25); + delete envSource.OTEL_ATTRIBUTE_COUNT_LIMIT; + }); + it('should have span attribute countlimits value same as general limit value', () => { + envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '20'; + const tracer = new BasicTracerProvider().getTracer('default'); + const generalLimits = tracer.getGeneralLimits(); + const spanLimits = tracer.getSpanLimits(); + assert.strictEqual(generalLimits.attributeCountLimit, 20); + assert.strictEqual(spanLimits.attributeCountLimit, 20); + delete envSource.OTEL_ATTRIBUTE_COUNT_LIMIT; + }); + it('should have span and general attribute count limits as defined in env', () => { + envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '20'; + envSource.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = '35'; + const tracer = new BasicTracerProvider().getTracer('default'); + const spanLimits = tracer.getSpanLimits(); + const generalLimits = tracer.getGeneralLimits(); + assert.strictEqual(generalLimits.attributeCountLimit, 20); + assert.strictEqual(spanLimits.attributeCountLimit, 35); + delete envSource.OTEL_ATTRIBUTE_COUNT_LIMIT; + delete envSource.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT; + }); + }); + describe('when "eventCountLimit" is defined', () => { it('should have tracer with defined value', () => { const tracer = new BasicTracerProvider({ @@ -634,66 +696,3 @@ describe('BasicTracerProvider', () => { }); }); }); - - -describe.skip('when attribute value length limit is defined via env', () => { - const envSource = process.env; - it('should have general attribute value length limits value as defined with env', () => { - envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '115'; - const tracer = new BasicTracerProvider().getTracer('default'); - const generalLimits = tracer.getGeneralLimits(); - assert.strictEqual(generalLimits.attributeValueLengthLimit, 115); - delete envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT; - }); - it('should have span attribute value length limits value same as general limit value', () => { - envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '125'; - const tracer = new BasicTracerProvider().getTracer('default'); - const generalLimits = tracer.getGeneralLimits(); - const spanLimits = tracer.getSpanLimits(); - assert.strictEqual(generalLimits.attributeValueLengthLimit, 125); - assert.strictEqual(spanLimits.attributeValueLengthLimit, 125); - delete envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT; - }); - it('should have span and general attribute value length limits as defined in env', () => { - envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '125'; - envSource.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT = '109'; - const tracer = new BasicTracerProvider().getTracer('default'); - const spanLimits = tracer.getSpanLimits(); - const generalLimits = tracer.getGeneralLimits(); - assert.strictEqual(generalLimits.attributeValueLengthLimit, 125); - assert.strictEqual(spanLimits.attributeValueLengthLimit, 109); - delete envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT; - delete envSource.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT; - }); -}); - -describe.skip('when attribute count limit is defined via env', () => { - const envSource = process.env; - it('should general attribute count limit as defined with env', () => { - envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '25'; - const tracer = new BasicTracerProvider({}).getTracer('default'); - const generalLimits = tracer.getGeneralLimits(); - assert.strictEqual(generalLimits.attributeCountLimit, 25); - delete envSource.OTEL_ATTRIBUTE_COUNT_LIMIT; - }); - it('should have span attribute countlimits value same as general limit value', () => { - envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '20'; - const tracer = new BasicTracerProvider().getTracer('default'); - const generalLimits = tracer.getGeneralLimits(); - const spanLimits = tracer.getSpanLimits(); - assert.strictEqual(generalLimits.attributeCountLimit, 20); - assert.strictEqual(spanLimits.attributeCountLimit, 20); - delete envSource.OTEL_ATTRIBUTE_COUNT_LIMIT; - }); - it('should have span and general attribute count limits as defined in env', () => { - envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '20'; - envSource.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = '35'; - const tracer = new BasicTracerProvider().getTracer('default'); - const spanLimits = tracer.getSpanLimits(); - const generalLimits = tracer.getGeneralLimits(); - assert.strictEqual(generalLimits.attributeCountLimit, 20); - assert.strictEqual(spanLimits.attributeCountLimit, 35); - delete envSource.OTEL_ATTRIBUTE_COUNT_LIMIT; - delete envSource.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT; - }); -}); From 9cd974bd776154b939ac6989cd75de1b8cf353fa Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Wed, 29 Jun 2022 12:04:10 -0500 Subject: [PATCH 03/15] chore(sdk-trace-base): remove duplicate process.env from used in browser tests Signed-off-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> --- .../test/common/BasicTracerProvider.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts index 8e51a1f448..5eef491861 100644 --- a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts +++ b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts @@ -183,7 +183,6 @@ describe('BasicTracerProvider', () => { }); describe('when attribute value length limit is defined via env', () => { - const envSource = process.env; it('should have general attribute value length limits value as defined with env', () => { envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '115'; const tracer = new BasicTracerProvider().getTracer('default'); @@ -214,7 +213,6 @@ describe('BasicTracerProvider', () => { }); describe('when attribute count limit is defined via env', () => { - const envSource = process.env; it('should general attribute count limit as defined with env', () => { envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '25'; const tracer = new BasicTracerProvider({}).getTracer('default'); From 51b071516ef051fdaae783879dc69863384694af Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Wed, 29 Jun 2022 12:07:05 -0500 Subject: [PATCH 04/15] chore(sdk-trace-base): add changelog Signed-off-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f381cad891..fe5f9358e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. * fix(resources): fix browser compatibility for host and os detectors [#3004](https://github.com/open-telemetry/opentelemetry-js/pull/3004) @legendecas * fix(sdk-trace-base): fix crash on environments without global document [#3000](https://github.com/open-telemetry/opentelemetry-js/pull/3000) @legendecas +* chore(sdk-trace-base): fix spanLimits attribute length/count to consider env values [#3068](https://github.com/open-telemetry/opentelemetry-js/pull/3068) @svetlanabrennan ### :books: (Refine Doc) From d3a6bb01f7c4b55e98949ce676819b9c066c8d75 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Fri, 22 Jul 2022 15:26:01 -0500 Subject: [PATCH 05/15] Update packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts Co-authored-by: Marc Pichler --- .../test/common/BasicTracerProvider.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts index 5eef491861..4000810fe4 100644 --- a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts +++ b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts @@ -220,7 +220,7 @@ describe('BasicTracerProvider', () => { assert.strictEqual(generalLimits.attributeCountLimit, 25); delete envSource.OTEL_ATTRIBUTE_COUNT_LIMIT; }); - it('should have span attribute countlimits value same as general limit value', () => { + it('should have span attribute count limit value same as general limit value', () => { envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '20'; const tracer = new BasicTracerProvider().getTracer('default'); const generalLimits = tracer.getGeneralLimits(); From 10ce6fccc2ecd8c156f1ef309663c3cb309a86d9 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Fri, 22 Jul 2022 15:26:16 -0500 Subject: [PATCH 06/15] Update packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts Co-authored-by: Marc Pichler --- .../test/common/BasicTracerProvider.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts index 4000810fe4..b42f038090 100644 --- a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts +++ b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts @@ -190,7 +190,7 @@ describe('BasicTracerProvider', () => { assert.strictEqual(generalLimits.attributeValueLengthLimit, 115); delete envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT; }); - it('should have span attribute value length limits value same as general limit value', () => { + it('should have span attribute value length limit value same as general limit value', () => { envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '125'; const tracer = new BasicTracerProvider().getTracer('default'); const generalLimits = tracer.getGeneralLimits(); From 41ccdba9a2f3c3ceb77e62dbd300ea3cfefbd100 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Fri, 22 Jul 2022 16:16:54 -0500 Subject: [PATCH 07/15] chore(sdk-trace-base): add comments Signed-off-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> --- packages/opentelemetry-sdk-trace-base/src/utility.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/opentelemetry-sdk-trace-base/src/utility.ts b/packages/opentelemetry-sdk-trace-base/src/utility.ts index fd85844c28..2b92504385 100644 --- a/packages/opentelemetry-sdk-trace-base/src/utility.ts +++ b/packages/opentelemetry-sdk-trace-base/src/utility.ts @@ -70,8 +70,10 @@ export function reconfigureLimits(userConfig: TracerConfig): TracerConfig { const DEFAULT_CONFIG = loadDefaultConfig(); /** - * When span attribute count limit is not defined, but general attribute count limit is defined - * Then, span attribute count limit will be same as general one + * If span attribute count limit is not defined programatically and through the env variable + * And general attribute count limit was either defined programatically or through the env variable + * Then set the span attribute count limit to be equal to the general attribute value length limit + * that was set programitcally or through the env variable. */ if ( spanLimits.attributeCountLimit == null && @@ -89,8 +91,10 @@ export function reconfigureLimits(userConfig: TracerConfig): TracerConfig { } /** - * When span attribute value length limit is not defined, but general attribute value length limit is defined - * Then, span attribute value length limit will be same as general one + * If span attribute value length limit is not defined programatically and through the env variable + * And general attribute value length limit was either defined programatically or through the env variable + * Then set the span attribute value length limit to be equal to the general attribute value length limit + * that was set programitcally or through the env variable. */ if ( spanLimits.attributeValueLengthLimit == null && From 9075be27bebc199ebd35b32a2357e3d274bfe4a9 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Fri, 22 Jul 2022 16:19:05 -0500 Subject: [PATCH 08/15] Update pr name in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe5f9358e1..8f28b55c29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ All notable changes to this project will be documented in this file. * fix(resources): fix browser compatibility for host and os detectors [#3004](https://github.com/open-telemetry/opentelemetry-js/pull/3004) @legendecas * fix(sdk-trace-base): fix crash on environments without global document [#3000](https://github.com/open-telemetry/opentelemetry-js/pull/3000) @legendecas -* chore(sdk-trace-base): fix spanLimits attribute length/count to consider env values [#3068](https://github.com/open-telemetry/opentelemetry-js/pull/3068) @svetlanabrennan +* fix(sdk-trace-base): fix spanLimits attribute length/count to consider env values [#3068](https://github.com/open-telemetry/opentelemetry-js/pull/3068) @svetlanabrennan ### :books: (Refine Doc) From b42ac6a60e7e82c6851c79514abbfeb5a1dac2fd Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Mon, 25 Jul 2022 11:40:11 -0500 Subject: [PATCH 09/15] fix(sdk-trace-base): refactor if statement to nullish check Signed-off-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> --- .../src/utility.ts | 55 ++++++------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/packages/opentelemetry-sdk-trace-base/src/utility.ts b/packages/opentelemetry-sdk-trace-base/src/utility.ts index 2b92504385..2bdf95e461 100644 --- a/packages/opentelemetry-sdk-trace-base/src/utility.ts +++ b/packages/opentelemetry-sdk-trace-base/src/utility.ts @@ -19,7 +19,9 @@ import { buildSamplerFromEnv, loadDefaultConfig } from './config'; import { SpanLimits, TracerConfig, GeneralLimits } from './types'; import { DEFAULT_ATTRIBUTE_COUNT_LIMIT, - DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT + DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT, + parseEnvironment, + RAW_ENVIRONMENT } from '@opentelemetry/core'; /** @@ -66,50 +68,29 @@ export function mergeConfig(userConfig: TracerConfig): TracerConfig & { */ export function reconfigureLimits(userConfig: TracerConfig): TracerConfig { const spanLimits = Object.assign({}, userConfig.spanLimits); - - const DEFAULT_CONFIG = loadDefaultConfig(); + const parsedEnvConfig = parseEnvironment(process.env as RAW_ENVIRONMENT); /** - * If span attribute count limit is not defined programatically and through the env variable - * And general attribute count limit was either defined programatically or through the env variable - * Then set the span attribute count limit to be equal to the general attribute value length limit - * that was set programitcally or through the env variable. + * Reassign span attribute count limit to use first non null value defined by user or use default value */ - if ( - spanLimits.attributeCountLimit == null && - (DEFAULT_CONFIG.spanLimits.attributeCountLimit === DEFAULT_ATTRIBUTE_COUNT_LIMIT) && - ( - userConfig.generalLimits?.attributeCountLimit != null || - DEFAULT_CONFIG.generalLimits.attributeCountLimit !== DEFAULT_ATTRIBUTE_COUNT_LIMIT - ) - ) { - const attributeCountLimit = - userConfig.generalLimits?.attributeCountLimit ?? - DEFAULT_CONFIG.generalLimits.attributeCountLimit; - spanLimits.attributeCountLimit = attributeCountLimit; - } + spanLimits.attributeCountLimit = + userConfig.spanLimits?.attributeCountLimit ?? + userConfig.generalLimits?.attributeCountLimit ?? + parsedEnvConfig.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT ?? + parsedEnvConfig.OTEL_ATTRIBUTE_COUNT_LIMIT ?? + DEFAULT_ATTRIBUTE_COUNT_LIMIT; /** - * If span attribute value length limit is not defined programatically and through the env variable - * And general attribute value length limit was either defined programatically or through the env variable - * Then set the span attribute value length limit to be equal to the general attribute value length limit - * that was set programitcally or through the env variable. + * Reassign span attribute value length limit to use first non null value defined by user or use default value */ - if ( - spanLimits.attributeValueLengthLimit == null && - (DEFAULT_CONFIG.spanLimits.attributeValueLengthLimit === DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT) && - ( - userConfig.generalLimits?.attributeValueLengthLimit != null || - DEFAULT_CONFIG.generalLimits.attributeValueLengthLimit !== DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT - ) - ) { - const attributeValueLengthLimit = - userConfig.generalLimits?.attributeValueLengthLimit ?? - DEFAULT_CONFIG.generalLimits.attributeValueLengthLimit; - spanLimits.attributeValueLengthLimit = attributeValueLengthLimit; - } + spanLimits.attributeValueLengthLimit = + userConfig.spanLimits?.attributeValueLengthLimit ?? + userConfig.generalLimits?.attributeValueLengthLimit ?? + parsedEnvConfig.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT ?? + parsedEnvConfig.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT ?? + DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT; return Object.assign({}, userConfig, { spanLimits }); } From 49619ffa2c91119bc5b9d94b2ec675a0232312cf Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Mon, 25 Jul 2022 11:49:00 -0500 Subject: [PATCH 10/15] fix(sdk-trace-base): refactor if statement to nullish check Signed-off-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> --- .../test/common/BasicTracerProvider.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts index b42f038090..4dce6fada8 100644 --- a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts +++ b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts @@ -212,6 +212,16 @@ describe('BasicTracerProvider', () => { }); }); + describe('when attribute value length limit is not defined via env', () => { + it.only('should use default value of Infinity', () => { + const tracer = new BasicTracerProvider().getTracer('default'); + const spanLimits = tracer.getSpanLimits(); + const generalLimits = tracer.getGeneralLimits(); + assert.strictEqual(generalLimits.attributeValueLengthLimit, Infinity); + assert.strictEqual(spanLimits.attributeValueLengthLimit, Infinity); + }) + }) + describe('when attribute count limit is defined via env', () => { it('should general attribute count limit as defined with env', () => { envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '25'; From 9336daf01574f91fb9ea829811c839a6334a4f8e Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Mon, 25 Jul 2022 11:57:39 -0500 Subject: [PATCH 11/15] fix(sdk-trace-base): add more test cases Signed-off-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> --- .../src/utility.ts | 2 - .../test/common/BasicTracerProvider.test.ts | 38 +++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/packages/opentelemetry-sdk-trace-base/src/utility.ts b/packages/opentelemetry-sdk-trace-base/src/utility.ts index 2bdf95e461..be1d9e12fd 100644 --- a/packages/opentelemetry-sdk-trace-base/src/utility.ts +++ b/packages/opentelemetry-sdk-trace-base/src/utility.ts @@ -73,7 +73,6 @@ export function reconfigureLimits(userConfig: TracerConfig): TracerConfig { /** * Reassign span attribute count limit to use first non null value defined by user or use default value */ - spanLimits.attributeCountLimit = userConfig.spanLimits?.attributeCountLimit ?? userConfig.generalLimits?.attributeCountLimit ?? @@ -84,7 +83,6 @@ export function reconfigureLimits(userConfig: TracerConfig): TracerConfig { /** * Reassign span attribute value length limit to use first non null value defined by user or use default value */ - spanLimits.attributeValueLengthLimit = userConfig.spanLimits?.attributeValueLengthLimit ?? userConfig.generalLimits?.attributeValueLengthLimit ?? diff --git a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts index 4dce6fada8..c29910f317 100644 --- a/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts +++ b/packages/opentelemetry-sdk-trace-base/test/common/BasicTracerProvider.test.ts @@ -210,17 +210,28 @@ describe('BasicTracerProvider', () => { delete envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT; delete envSource.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT; }); + it('should have span attribute value length limit as deafult of Infinity', () => { + envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '125'; + envSource.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT = 'Infinity'; + const tracer = new BasicTracerProvider().getTracer('default'); + const spanLimits = tracer.getSpanLimits(); + const generalLimits = tracer.getGeneralLimits(); + assert.strictEqual(generalLimits.attributeValueLengthLimit, 125); + assert.strictEqual(spanLimits.attributeValueLengthLimit, Infinity); + delete envSource.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT; + delete envSource.OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT; + }); }); describe('when attribute value length limit is not defined via env', () => { - it.only('should use default value of Infinity', () => { + it('should use default value of Infinity', () => { const tracer = new BasicTracerProvider().getTracer('default'); const spanLimits = tracer.getSpanLimits(); const generalLimits = tracer.getGeneralLimits(); assert.strictEqual(generalLimits.attributeValueLengthLimit, Infinity); assert.strictEqual(spanLimits.attributeValueLengthLimit, Infinity); - }) - }) + }); + }); describe('when attribute count limit is defined via env', () => { it('should general attribute count limit as defined with env', () => { @@ -250,6 +261,27 @@ describe('BasicTracerProvider', () => { delete envSource.OTEL_ATTRIBUTE_COUNT_LIMIT; delete envSource.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT; }); + it('should have span attribute count limit as default of 128', () => { + envSource.OTEL_ATTRIBUTE_COUNT_LIMIT = '20'; + envSource.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = '128'; + const tracer = new BasicTracerProvider().getTracer('default'); + const spanLimits = tracer.getSpanLimits(); + const generalLimits = tracer.getGeneralLimits(); + assert.strictEqual(generalLimits.attributeCountLimit, 20); + assert.strictEqual(spanLimits.attributeCountLimit, 128); + delete envSource.OTEL_ATTRIBUTE_COUNT_LIMIT; + delete envSource.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT; + }); + }); + + describe('when attribute count limit is not defined via env', () => { + it('should use default value of 128', () => { + const tracer = new BasicTracerProvider().getTracer('default'); + const spanLimits = tracer.getSpanLimits(); + const generalLimits = tracer.getGeneralLimits(); + assert.strictEqual(generalLimits.attributeCountLimit, 128); + assert.strictEqual(spanLimits.attributeCountLimit, 128); + }); }); describe('when "eventCountLimit" is defined', () => { From 1ff5be9113bab6a00c5bbd19c2721626f08c5b74 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Mon, 25 Jul 2022 13:36:51 -0500 Subject: [PATCH 12/15] fix(sdk-trace-base): remove calling process in browser Signed-off-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> --- packages/opentelemetry-sdk-trace-base/src/utility.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/opentelemetry-sdk-trace-base/src/utility.ts b/packages/opentelemetry-sdk-trace-base/src/utility.ts index be1d9e12fd..fe766acd78 100644 --- a/packages/opentelemetry-sdk-trace-base/src/utility.ts +++ b/packages/opentelemetry-sdk-trace-base/src/utility.ts @@ -21,7 +21,8 @@ import { DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT, parseEnvironment, - RAW_ENVIRONMENT + RAW_ENVIRONMENT, + _globalThis } from '@opentelemetry/core'; /** @@ -68,7 +69,12 @@ export function mergeConfig(userConfig: TracerConfig): TracerConfig & { */ export function reconfigureLimits(userConfig: TracerConfig): TracerConfig { const spanLimits = Object.assign({}, userConfig.spanLimits); - const parsedEnvConfig = parseEnvironment(process.env as RAW_ENVIRONMENT); + + // parse environment in node or browser + const parsedEnvConfig = + typeof process !== 'undefined' ? + parseEnvironment(process.env as RAW_ENVIRONMENT) : + parseEnvironment(_globalThis as typeof globalThis & RAW_ENVIRONMENT); /** * Reassign span attribute count limit to use first non null value defined by user or use default value From fc1e3e98b4412fa4eac93853f850ffc678e2c2f3 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Tue, 26 Jul 2022 09:38:46 -0500 Subject: [PATCH 13/15] fix(sdk-trace-base): move parsing env to core package Signed-off-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> --- packages/opentelemetry-core/src/utils/environment.ts | 11 +++++++++++ packages/opentelemetry-sdk-trace-base/src/utility.ts | 10 ++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/opentelemetry-core/src/utils/environment.ts b/packages/opentelemetry-core/src/utils/environment.ts index def0fe4846..32ce8f3bd4 100644 --- a/packages/opentelemetry-core/src/utils/environment.ts +++ b/packages/opentelemetry-core/src/utils/environment.ts @@ -16,6 +16,7 @@ import { DiagLogLevel } from '@opentelemetry/api'; import { TracesSamplerValues } from './sampling'; +import { _globalThis } from '../platform/browser/globalThis'; const DEFAULT_LIST_SEPARATOR = ','; @@ -283,3 +284,13 @@ export function parseEnvironment(values: RAW_ENVIRONMENT): ENVIRONMENT { return environment; } + +/** + * Parse environment in node or browser without + * populating default values. + */ +export function parseEnvWithoutDefaults(): ENVIRONMENT { + return typeof process !== 'undefined' ? + parseEnvironment(process.env as RAW_ENVIRONMENT) : + parseEnvironment(_globalThis as typeof globalThis & RAW_ENVIRONMENT); +} diff --git a/packages/opentelemetry-sdk-trace-base/src/utility.ts b/packages/opentelemetry-sdk-trace-base/src/utility.ts index fe766acd78..3435b44c59 100644 --- a/packages/opentelemetry-sdk-trace-base/src/utility.ts +++ b/packages/opentelemetry-sdk-trace-base/src/utility.ts @@ -20,9 +20,7 @@ import { SpanLimits, TracerConfig, GeneralLimits } from './types'; import { DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT, - parseEnvironment, - RAW_ENVIRONMENT, - _globalThis + parseEnvWithoutDefaults, } from '@opentelemetry/core'; /** @@ -70,11 +68,7 @@ export function mergeConfig(userConfig: TracerConfig): TracerConfig & { export function reconfigureLimits(userConfig: TracerConfig): TracerConfig { const spanLimits = Object.assign({}, userConfig.spanLimits); - // parse environment in node or browser - const parsedEnvConfig = - typeof process !== 'undefined' ? - parseEnvironment(process.env as RAW_ENVIRONMENT) : - parseEnvironment(_globalThis as typeof globalThis & RAW_ENVIRONMENT); + const parsedEnvConfig = parseEnvWithoutDefaults(); /** * Reassign span attribute count limit to use first non null value defined by user or use default value From 2e77d0f6481287152787956e846d87daefa1d679 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Tue, 26 Jul 2022 09:58:45 -0500 Subject: [PATCH 14/15] fix(sdk-trace-base): fix lint issue Signed-off-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> --- packages/opentelemetry-core/src/utils/environment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opentelemetry-core/src/utils/environment.ts b/packages/opentelemetry-core/src/utils/environment.ts index 32ce8f3bd4..75644e6609 100644 --- a/packages/opentelemetry-core/src/utils/environment.ts +++ b/packages/opentelemetry-core/src/utils/environment.ts @@ -286,7 +286,7 @@ export function parseEnvironment(values: RAW_ENVIRONMENT): ENVIRONMENT { } /** - * Parse environment in node or browser without + * Parse environment in node or browser without * populating default values. */ export function parseEnvWithoutDefaults(): ENVIRONMENT { From aaec7cca106c2ce06d4e1a6af8e62ec8283b1864 Mon Sep 17 00:00:00 2001 From: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> Date: Tue, 26 Jul 2022 11:23:15 -0500 Subject: [PATCH 15/15] fix(sdk-trace-base): rename function Signed-off-by: Svetlana Brennan <50715937+svetlanabrennan@users.noreply.github.com> --- packages/opentelemetry-core/src/utils/environment.ts | 4 ++-- packages/opentelemetry-sdk-trace-base/src/utility.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/opentelemetry-core/src/utils/environment.ts b/packages/opentelemetry-core/src/utils/environment.ts index 75644e6609..05ba058f0f 100644 --- a/packages/opentelemetry-core/src/utils/environment.ts +++ b/packages/opentelemetry-core/src/utils/environment.ts @@ -286,10 +286,10 @@ export function parseEnvironment(values: RAW_ENVIRONMENT): ENVIRONMENT { } /** - * Parse environment in node or browser without + * Get environment in node or browser without * populating default values. */ -export function parseEnvWithoutDefaults(): ENVIRONMENT { +export function getEnvWithoutDefaults(): ENVIRONMENT { return typeof process !== 'undefined' ? parseEnvironment(process.env as RAW_ENVIRONMENT) : parseEnvironment(_globalThis as typeof globalThis & RAW_ENVIRONMENT); diff --git a/packages/opentelemetry-sdk-trace-base/src/utility.ts b/packages/opentelemetry-sdk-trace-base/src/utility.ts index 3435b44c59..684f68a210 100644 --- a/packages/opentelemetry-sdk-trace-base/src/utility.ts +++ b/packages/opentelemetry-sdk-trace-base/src/utility.ts @@ -20,7 +20,7 @@ import { SpanLimits, TracerConfig, GeneralLimits } from './types'; import { DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT, - parseEnvWithoutDefaults, + getEnvWithoutDefaults, } from '@opentelemetry/core'; /** @@ -68,7 +68,7 @@ export function mergeConfig(userConfig: TracerConfig): TracerConfig & { export function reconfigureLimits(userConfig: TracerConfig): TracerConfig { const spanLimits = Object.assign({}, userConfig.spanLimits); - const parsedEnvConfig = parseEnvWithoutDefaults(); + const parsedEnvConfig = getEnvWithoutDefaults(); /** * Reassign span attribute count limit to use first non null value defined by user or use default value