Skip to content

Commit 15ba2d7

Browse files
authored
feat(core)!: remove TracesSamplerValues from exports (#5406)
1 parent 05c2869 commit 15ba2d7

File tree

6 files changed

+15
-19
lines changed

6 files changed

+15
-19
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se
6565
* (user-facing): only a non-env-var based default is now used on `WebTracerProvider#register()`.
6666
* propagators can now not be configured via `window.OTEL_PROPAGATORS` anymore, please pass the propagator to `WebTracerProvider#register()` instead.
6767
* if not configured via code, `WebTracerProvider#register()` will now fall back to defaults (`tracecontext` and `baggage`)
68+
* feat(core)!: remove TracesSamplerValues from exports [#5406](https://github.com/open-telemetry/opentelemetry-js/pull/5406) @pichlermarc
69+
* (user-facing): TracesSamplerValues was only consumed internally and has been removed from exports without replacement
6870

6971
### :rocket: (Enhancement)
7072

packages/opentelemetry-core/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export {
103103
parseEnvironment,
104104
} from './utils/environment';
105105
export { merge } from './utils/merge';
106-
export { TracesSamplerValues } from './utils/sampling';
107106
export { TimeoutError, callWithTimeout } from './utils/timeout';
108107
export { isUrlIgnored, urlMatches } from './utils/url';
109108
export { isWrapped } from './utils/wrap';

packages/opentelemetry-core/src/utils/environment.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
import { DiagLogLevel } from '@opentelemetry/api';
18-
import { TracesSamplerValues } from './sampling';
1918

2019
const DEFAULT_LIST_SEPARATOR = ',';
2120

@@ -208,7 +207,7 @@ export const DEFAULT_ENVIRONMENT: Required<ENVIRONMENT> = {
208207
OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT:
209208
DEFAULT_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT,
210209
OTEL_TRACES_EXPORTER: '',
211-
OTEL_TRACES_SAMPLER: TracesSamplerValues.ParentBasedAlwaysOn,
210+
OTEL_TRACES_SAMPLER: 'parentbased_always_on',
212211
OTEL_TRACES_SAMPLER_ARG: '',
213212
OTEL_LOGS_EXPORTER: '',
214213
OTEL_EXPORTER_OTLP_INSECURE: '',

packages/opentelemetry-core/src/utils/sampling.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,3 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
17-
export enum TracesSamplerValues {
18-
AlwaysOff = 'always_off',
19-
AlwaysOn = 'always_on',
20-
ParentBasedAlwaysOff = 'parentbased_always_off',
21-
ParentBasedAlwaysOn = 'parentbased_always_on',
22-
ParentBasedTraceIdRatio = 'parentbased_traceidratio',
23-
TraceIdRatio = 'traceidratio',
24-
}

packages/opentelemetry-core/test/utils/environment.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
import * as assert from 'assert';
2424
import * as sinon from 'sinon';
2525
import { DiagLogLevel } from '@opentelemetry/api';
26-
import { TracesSamplerValues } from '../../src';
2726

2827
let lastMock: RAW_ENVIRONMENT = {};
2928

@@ -183,15 +182,12 @@ describe('environment', () => {
183182
it('should remove a mock environment', () => {
184183
mockEnvironment({
185184
OTEL_LOG_LEVEL: 'DEBUG',
186-
OTEL_TRACES_SAMPLER: TracesSamplerValues.AlwaysOff,
185+
OTEL_TRACES_SAMPLER: 'always_off',
187186
});
188187
removeMockEnvironment();
189188
const env = getEnv();
190189
assert.strictEqual(env.OTEL_LOG_LEVEL, DiagLogLevel.INFO);
191-
assert.strictEqual(
192-
env.OTEL_TRACES_SAMPLER,
193-
TracesSamplerValues.ParentBasedAlwaysOn
194-
);
190+
assert.strictEqual(env.OTEL_TRACES_SAMPLER, 'parentbased_always_on');
195191
});
196192
});
197193
});

packages/opentelemetry-sdk-trace-base/src/config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,22 @@
1515
*/
1616

1717
import { diag } from '@opentelemetry/api';
18-
import { getEnv, TracesSamplerValues, ENVIRONMENT } from '@opentelemetry/core';
18+
import { getEnv, ENVIRONMENT } from '@opentelemetry/core';
1919
import { Sampler } from './Sampler';
2020
import { AlwaysOffSampler } from './sampler/AlwaysOffSampler';
2121
import { AlwaysOnSampler } from './sampler/AlwaysOnSampler';
2222
import { ParentBasedSampler } from './sampler/ParentBasedSampler';
2323
import { TraceIdRatioBasedSampler } from './sampler/TraceIdRatioBasedSampler';
2424

25+
const enum TracesSamplerValues {
26+
AlwaysOff = 'always_off',
27+
AlwaysOn = 'always_on',
28+
ParentBasedAlwaysOff = 'parentbased_always_off',
29+
ParentBasedAlwaysOn = 'parentbased_always_on',
30+
ParentBasedTraceIdRatio = 'parentbased_traceidratio',
31+
TraceIdRatio = 'traceidratio',
32+
}
33+
2534
const FALLBACK_OTEL_TRACES_SAMPLER = TracesSamplerValues.AlwaysOn;
2635
const DEFAULT_RATIO = 1;
2736

0 commit comments

Comments
 (0)