Skip to content

Commit

Permalink
feat(core)!: remove TracesSamplerValues from exports
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc committed Jan 30, 2025
1 parent bb21233 commit 51a607b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
1 change: 0 additions & 1 deletion packages/opentelemetry-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 1 addition & 2 deletions packages/opentelemetry-core/src/utils/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import { DiagLogLevel } from '@opentelemetry/api';
import { TracesSamplerValues } from './sampling';

const DEFAULT_LIST_SEPARATOR = ',';

Expand Down Expand Up @@ -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: '',
Expand Down
9 changes: 1 addition & 8 deletions packages/opentelemetry-core/src/utils/sampling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}

8 changes: 2 additions & 6 deletions packages/opentelemetry-core/test/utils/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand Down Expand Up @@ -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');
});
});
});
11 changes: 10 additions & 1 deletion packages/opentelemetry-sdk-trace-base/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 51a607b

Please sign in to comment.