Skip to content

Commit 1940016

Browse files
authored
Merge branch 'develop' into timfish/test/cloudflare-integration-tests
2 parents a79ba28 + fa210ad commit 1940016

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

packages/opentelemetry/src/spanExporter.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ export class SentrySpanExporter {
191191
sentSpans.add(span);
192192
const transactionEvent = createTransactionForOtelSpan(span);
193193

194+
// Add an attribute to the transaction event to indicate that this transaction is an orphaned transaction
195+
if (root.parentNode && this._sentSpans.has(root.parentNode.id)) {
196+
const traceData = transactionEvent.contexts?.trace?.data;
197+
if (traceData) {
198+
traceData['sentry.parent_span_already_sent'] = true;
199+
}
200+
}
201+
194202
// We'll recursively add all the child spans to this array
195203
const spans = transactionEvent.spans || [];
196204

packages/opentelemetry/test/integration/transactions.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,20 @@ describe('Integration | Transactions', () => {
612612
expect(transactions).toHaveLength(2);
613613
expect(transactions[0]?.spans).toHaveLength(1);
614614

615+
expect(transactions[0]?.transaction).toBe('test name');
616+
expect(transactions[0]?.contexts?.trace?.data).toEqual({
617+
'sentry.origin': 'manual',
618+
'sentry.sample_rate': 1,
619+
'sentry.source': 'custom',
620+
});
621+
622+
expect(transactions[1]?.transaction).toBe('inner span 2');
623+
expect(transactions[1]?.contexts?.trace?.data).toEqual({
624+
'sentry.parent_span_already_sent': true,
625+
'sentry.origin': 'manual',
626+
'sentry.source': 'custom',
627+
});
628+
615629
const finishedSpans: any = exporter['_finishedSpanBuckets'].flatMap(bucket =>
616630
bucket ? Array.from(bucket.spans) : [],
617631
);

0 commit comments

Comments
 (0)