Skip to content

Commit 4a2a7ae

Browse files
author
Luca Forstner
committed
.
1 parent c4282b8 commit 4a2a7ae

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone/test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ sentryTest('sends a segment span envelope', async ({ getLocalTestUrl, page }) =>
4545
data: {
4646
'sentry.origin': 'manual',
4747
'sentry.sample_rate': 1,
48+
'sentry.override_trace_sample_rate': true, // This should probably not be here but for now it will be.
4849
'sentry.source': 'custom',
4950
},
5051
description: 'standalone_segment_span',

packages/browser/test/tracing/browserTracingIntegration.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ global.window.TextDecoder = TextDecoder;
1818
import {
1919
SEMANTIC_ATTRIBUTE_SENTRY_OP,
2020
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
21+
SEMANTIC_ATTRIBUTE_SENTRY_OVERRIDE_TRACE_SAMPLE_RATE,
2122
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
2223
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
2324
TRACING_DEFAULTS,
@@ -103,6 +104,7 @@ describe('browserTracingIntegration', () => {
103104
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',
104105
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.browser',
105106
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,
107+
[SEMANTIC_ATTRIBUTE_SENTRY_OVERRIDE_TRACE_SAMPLE_RATE]: true,
106108
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
107109
},
108110
span_id: expect.stringMatching(/[a-f0-9]{16}/),
@@ -174,6 +176,7 @@ describe('browserTracingIntegration', () => {
174176
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',
175177
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.browser',
176178
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,
179+
[SEMANTIC_ATTRIBUTE_SENTRY_OVERRIDE_TRACE_SAMPLE_RATE]: true,
177180
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
178181
},
179182
span_id: expect.stringMatching(/[a-f0-9]{16}/),
@@ -288,6 +291,7 @@ describe('browserTracingIntegration', () => {
288291
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',
289292
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',
290293
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,
294+
[SEMANTIC_ATTRIBUTE_SENTRY_OVERRIDE_TRACE_SAMPLE_RATE]: true,
291295
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',
292296
},
293297
span_id: expect.stringMatching(/[a-f0-9]{16}/),
@@ -323,6 +327,7 @@ describe('browserTracingIntegration', () => {
323327
data: {
324328
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',
325329
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.test',
330+
[SEMANTIC_ATTRIBUTE_SENTRY_OVERRIDE_TRACE_SAMPLE_RATE]: true,
326331
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 1,
327332
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom',
328333
testy: 'yes',

packages/core/src/envelope.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Client } from './client';
2+
import { SEMANTIC_ATTRIBUTE_SENTRY_OVERRIDE_TRACE_SAMPLE_RATE } from './semanticAttributes';
23
import { getDynamicSamplingContextFromSpan } from './tracing/dynamicSamplingContext';
34
import type { SentrySpan } from './tracing/sentrySpan';
45
import type {
@@ -141,6 +142,8 @@ export function createSpanEnvelope(spans: [SentrySpan, ...SentrySpan[]], client?
141142
const items: SpanItem[] = [];
142143
for (const span of spans) {
143144
const spanJson = convertToSpanJSON(span);
145+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
146+
delete spanJson.data[SEMANTIC_ATTRIBUTE_SENTRY_OVERRIDE_TRACE_SAMPLE_RATE];
144147
if (spanJson) {
145148
items.push(createSpanEnvelopeItem(spanJson));
146149
}

packages/core/src/tracing/sampling.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function sampleSpan(
2121
return [false];
2222
}
2323

24-
let shouldUpdateSampleRateOnDsc = false;
24+
let shouldUpdateSampleRateOnDsc = undefined;
2525

2626
// we would have bailed already if neither `tracesSampler` nor `tracesSampleRate` nor `enableTracing` were defined, so one of these should
2727
// work; prefer the hook if so

packages/core/src/tracing/sentrySpan.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ export class SentrySpan implements Span {
351351
delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];
352352
delete this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_OVERRIDE_TRACE_SAMPLE_RATE];
353353
spans.forEach(span => {
354-
span.data && delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];
354+
delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME];
355+
delete span.data[SEMANTIC_ATTRIBUTE_SENTRY_OVERRIDE_TRACE_SAMPLE_RATE];
355356
});
356357
// eslint-enabled-next-line @typescript-eslint/no-dynamic-delete
357358

0 commit comments

Comments
 (0)