diff --git a/packages/opentelemetry-core/src/index.ts b/packages/opentelemetry-core/src/index.ts index c518a33933..d9143bff35 100644 --- a/packages/opentelemetry-core/src/index.ts +++ b/packages/opentelemetry-core/src/index.ts @@ -103,7 +103,6 @@ export { parseEnvironment, } from './utils/environment'; export { merge } from './utils/merge'; -export { TracesSamplerValues } from './utils/sampling'; export { TimeoutError, callWithTimeout } from './utils/timeout'; export { isUrlIgnored, urlMatches } from './utils/url'; export { isWrapped } from './utils/wrap'; diff --git a/packages/opentelemetry-core/src/utils/environment.ts b/packages/opentelemetry-core/src/utils/environment.ts index addb6b18ce..4e7146ea92 100644 --- a/packages/opentelemetry-core/src/utils/environment.ts +++ b/packages/opentelemetry-core/src/utils/environment.ts @@ -15,7 +15,6 @@ */ import { DiagLogLevel } from '@opentelemetry/api'; -import { TracesSamplerValues } from './sampling'; const DEFAULT_LIST_SEPARATOR = ','; @@ -208,7 +207,7 @@ export const DEFAULT_ENVIRONMENT: Required<ENVIRONMENT> = { OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT: DEFAULT_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT, OTEL_TRACES_EXPORTER: '', - OTEL_TRACES_SAMPLER: TracesSamplerValues.ParentBasedAlwaysOn, + OTEL_TRACES_SAMPLER: 'parentbased_always_on', OTEL_TRACES_SAMPLER_ARG: '', OTEL_LOGS_EXPORTER: '', OTEL_EXPORTER_OTLP_INSECURE: '', diff --git a/packages/opentelemetry-core/src/utils/sampling.ts b/packages/opentelemetry-core/src/utils/sampling.ts index d18f59b6fc..2ccad8439f 100644 --- a/packages/opentelemetry-core/src/utils/sampling.ts +++ b/packages/opentelemetry-core/src/utils/sampling.ts @@ -14,11 +14,4 @@ * limitations under the License. */ -export enum TracesSamplerValues { - AlwaysOff = 'always_off', - AlwaysOn = 'always_on', - ParentBasedAlwaysOff = 'parentbased_always_off', - ParentBasedAlwaysOn = 'parentbased_always_on', - ParentBasedTraceIdRatio = 'parentbased_traceidratio', - TraceIdRatio = 'traceidratio', -} + diff --git a/packages/opentelemetry-core/test/utils/environment.test.ts b/packages/opentelemetry-core/test/utils/environment.test.ts index 708238a059..936a9df274 100644 --- a/packages/opentelemetry-core/test/utils/environment.test.ts +++ b/packages/opentelemetry-core/test/utils/environment.test.ts @@ -23,7 +23,6 @@ import { import * as assert from 'assert'; import * as sinon from 'sinon'; import { DiagLogLevel } from '@opentelemetry/api'; -import { TracesSamplerValues } from '../../src'; let lastMock: RAW_ENVIRONMENT = {}; @@ -183,15 +182,12 @@ describe('environment', () => { it('should remove a mock environment', () => { mockEnvironment({ OTEL_LOG_LEVEL: 'DEBUG', - OTEL_TRACES_SAMPLER: TracesSamplerValues.AlwaysOff, + OTEL_TRACES_SAMPLER: 'always_off', }); removeMockEnvironment(); const env = getEnv(); assert.strictEqual(env.OTEL_LOG_LEVEL, DiagLogLevel.INFO); - assert.strictEqual( - env.OTEL_TRACES_SAMPLER, - TracesSamplerValues.ParentBasedAlwaysOn - ); + assert.strictEqual(env.OTEL_TRACES_SAMPLER, 'parentbased_always_on'); }); }); }); diff --git a/packages/opentelemetry-sdk-trace-base/src/config.ts b/packages/opentelemetry-sdk-trace-base/src/config.ts index a53ca6ab67..0756d00dd7 100644 --- a/packages/opentelemetry-sdk-trace-base/src/config.ts +++ b/packages/opentelemetry-sdk-trace-base/src/config.ts @@ -15,13 +15,22 @@ */ import { diag } from '@opentelemetry/api'; -import { getEnv, TracesSamplerValues, ENVIRONMENT } from '@opentelemetry/core'; +import { getEnv, ENVIRONMENT } from '@opentelemetry/core'; import { Sampler } from './Sampler'; import { AlwaysOffSampler } from './sampler/AlwaysOffSampler'; import { AlwaysOnSampler } from './sampler/AlwaysOnSampler'; import { ParentBasedSampler } from './sampler/ParentBasedSampler'; import { TraceIdRatioBasedSampler } from './sampler/TraceIdRatioBasedSampler'; +const enum TracesSamplerValues { + AlwaysOff = 'always_off', + AlwaysOn = 'always_on', + ParentBasedAlwaysOff = 'parentbased_always_off', + ParentBasedAlwaysOn = 'parentbased_always_on', + ParentBasedTraceIdRatio = 'parentbased_traceidratio', + TraceIdRatio = 'traceidratio', +} + const FALLBACK_OTEL_TRACES_SAMPLER = TracesSamplerValues.AlwaysOn; const DEFAULT_RATIO = 1;