Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/core/test/lib/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ describe('eventToSentryRequest', () => {
// public_key: 'dogsarebadatkeepingsecrets',
// release: 'off.leash.park',
// user: { id: '1121', segment: 'bigs' },
// transaction: '/dogs/are/great/',
// }),
tracestate: {
sentry:
'sentry=eyJ0cmFjZV9pZCI6IjEyMzEyMDEyMTEyMTIwMTIiLCJlbnZpcm9ubWVudCI6ImRvZ3BhcmsiLCJwdWJsaWNfa2V5Ijo' +
'iZG9nc2FyZWJhZGF0a2VlcGluZ3NlY3JldHMiLCJyZWxlYXNlIjoib2ZmLmxlYXNoLnBhcmsiLCJ1c2VyIjp7ImlkIjoiMTEyM' +
'SIsInNlZ21lbnQiOiJiaWdzIn19',
'SIsInNlZ21lbnQiOiJiaWdzIn0sInRyYW5zYWN0aW9uIjoiL2RvZ3MvYXJlL2dyZWF0LyJ9',
},
},
spans: [],
Expand Down Expand Up @@ -135,6 +136,7 @@ describe('eventToSentryRequest', () => {
public_key: 'dogsarebadatkeepingsecrets',
release: 'off.leash.park',
user: { id: '1121', segment: 'bigs' },
transaction: '/dogs/are/great/',
});
});
});
Expand Down
1 change: 1 addition & 0 deletions packages/tracing/src/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ export class Span implements SpanInterface {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
public_key: dsn.publicKey!,
user,
transaction: this.transaction?.name,
})}`;
}

Expand Down
1 change: 1 addition & 0 deletions packages/tracing/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ type SentryTracestateData = {
release?: string;
public_key: string;
user?: { id?: string; segment?: string };
transaction?: string;
};

/**
Expand Down
14 changes: 10 additions & 4 deletions packages/tracing/test/span.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,20 @@ describe('Span', () => {
const environment = 'dogpark';
const traceId = '12312012123120121231201212312012';
const user = { id: '1121', segment: 'bigs' };
const transactionName = 'FETCH /ball';

const computedTracestate = `sentry=${computeTracestateValue({
const baseTracestateData = {
trace_id: traceId,
environment,
release,
public_key: publicKey,
user,
};
const computedTracestate = `sentry=${computeTracestateValue({
...baseTracestateData,
transaction: transactionName,
})}`;
const computedOrphanTracestate = `sentry=${computeTracestateValue(baseTracestateData)}`;
const thirdpartyData = 'maisey=silly,charlie=goofy';

const hub = new Hub(
Expand All @@ -134,14 +140,14 @@ describe('Span', () => {
});

test('no third-party data', () => {
const transaction = new Transaction({ name: 'FETCH /ball', traceId }, hub);
const transaction = new Transaction({ name: transactionName, traceId }, hub);
const span = transaction.startChild({ op: 'dig.hole' });

expect(span.getTraceHeaders().tracestate).toEqual(computedTracestate);
});

test('third-party data', () => {
const transaction = new Transaction({ name: 'FETCH /ball' }, hub);
const transaction = new Transaction({ name: transactionName }, hub);
transaction.setMetadata({ tracestate: { sentry: computedTracestate, thirdparty: thirdpartyData } });
const span = transaction.startChild({ op: 'dig.hole' });

Expand All @@ -153,7 +159,7 @@ describe('Span', () => {
const span = new Span({ op: 'dig.hole' });
span.traceId = traceId;

expect(span.getTraceHeaders().tracestate).toEqual(computedTracestate);
expect(span.getTraceHeaders().tracestate).toEqual(computedOrphanTracestate);
});
});

Expand Down