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
8 changes: 8 additions & 0 deletions packages/opentelemetry/src/spanExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ export class SentrySpanExporter {
sentSpans.add(span);
const transactionEvent = createTransactionForOtelSpan(span);

// Add an attribute to the transaction event to indicate that this transaction is an orphaned transaction
if (root.parentNode && this._sentSpans.has(root.parentNode.id)) {
const traceData = transactionEvent.contexts?.trace?.data;
if (traceData) {
traceData['sentry.parent_span_already_sent'] = true;
}
}

// We'll recursively add all the child spans to this array
const spans = transactionEvent.spans || [];

Expand Down
14 changes: 14 additions & 0 deletions packages/opentelemetry/test/integration/transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,20 @@ describe('Integration | Transactions', () => {
expect(transactions).toHaveLength(2);
expect(transactions[0]?.spans).toHaveLength(1);

expect(transactions[0]?.transaction).toBe('test name');
expect(transactions[0]?.contexts?.trace?.data).toEqual({
'sentry.origin': 'manual',
'sentry.sample_rate': 1,
'sentry.source': 'custom',
});

expect(transactions[1]?.transaction).toBe('inner span 2');
expect(transactions[1]?.contexts?.trace?.data).toEqual({
'sentry.parent_span_already_sent': true,
'sentry.origin': 'manual',
'sentry.source': 'custom',
});

const finishedSpans: any = exporter['_finishedSpanBuckets'].flatMap(bucket =>
bucket ? Array.from(bucket.spans) : [],
);
Expand Down
Loading