Skip to content

Commit

Permalink
fix: Defer tracing decision to downstream SDKs when using SDK without…
Browse files Browse the repository at this point in the history
… performance (#8839)
  • Loading branch information
lforst committed Aug 28, 2023
1 parent 06caf0d commit 7ed50ed
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion packages/core/src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,5 @@ function generatePropagationContext(): PropagationContext {
return {
traceId: uuid4(),
spanId: uuid4().substring(16),
sampled: false,
};
}
4 changes: 2 additions & 2 deletions packages/hub/test/scope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Scope', () => {
expect(scope._propagationContext).toEqual({
traceId: expect.any(String),
spanId: expect.any(String),
sampled: false,
sampled: undefined,
dsc: undefined,
parentSpanId: undefined,
});
Expand Down Expand Up @@ -442,7 +442,7 @@ describe('Scope', () => {
expect(scope._propagationContext).toEqual({
traceId: expect.any(String),
spanId: expect.any(String),
sampled: false,
sampled: undefined,
});
// @ts-expect-error accessing private property
expect(scope._propagationContext).not.toEqual(oldPropagationContext);
Expand Down
5 changes: 3 additions & 2 deletions packages/node/test/integrations/http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,11 @@ describe('tracing', () => {
const baggageHeader = request.getHeader('baggage') as string;

const parts = sentryTraceHeader.split('-');
expect(parts.length).toEqual(3);

// Should not include sampling decision since we don't wanna influence the tracing decisions downstream
expect(parts.length).toEqual(2);
expect(parts[0]).toEqual(traceId);
expect(parts[1]).toEqual(expect.any(String));
expect(parts[2]).toEqual('0');

expect(baggageHeader).toEqual(
`sentry-environment=production,sentry-release=1.0.0,sentry-user_segment=segmentA,sentry-public_key=dogsarebadatkeepingsecrets,sentry-trace_id=${traceId}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/tracing-internal/src/browser/browsertracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export class BrowserTracing implements Integration {
traceId: idleTransaction.traceId,
spanId: idleTransaction.spanId,
parentSpanId: idleTransaction.parentSpanId,
sampled: !!idleTransaction.sampled,
sampled: idleTransaction.sampled,
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type TracePropagationTargets = (string | RegExp)[];
export interface PropagationContext {
traceId: string;
spanId: string;
sampled: boolean;
sampled?: boolean;
parentSpanId?: string;
dsc?: DynamicSamplingContext;
}
2 changes: 1 addition & 1 deletion packages/utils/src/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function tracingContextFromHeaders(
const propagationContext: PropagationContext = {
traceId: traceId || uuid4(),
spanId: uuid4().substring(16),
sampled: parentSampled === undefined ? false : parentSampled,
sampled: parentSampled,
};

if (parentSpanId) {
Expand Down

0 comments on commit 7ed50ed

Please sign in to comment.