diff --git a/packages/core/src/tracing/hubextensions.ts b/packages/core/src/tracing/hubextensions.ts index 17d847e5e8d8..9624df4b709e 100644 --- a/packages/core/src/tracing/hubextensions.ts +++ b/packages/core/src/tracing/hubextensions.ts @@ -186,6 +186,9 @@ The transaction will not be sampled. Please use the ${configInstrumenter} instru if (transaction.sampled) { transaction.initSpanRecorder(options._experiments && (options._experiments.maxSpans as number)); } + if (client && client.emit) { + client.emit('startTransaction', transaction); + } return transaction; } @@ -213,6 +216,9 @@ export function startIdleTransaction( if (transaction.sampled) { transaction.initSpanRecorder(options._experiments && (options._experiments.maxSpans as number)); } + if (client && client.emit) { + client.emit('startTransaction', transaction); + } return transaction; } diff --git a/packages/core/src/tracing/transaction.ts b/packages/core/src/tracing/transaction.ts index 440a8b69b41d..eba498b7e654 100644 --- a/packages/core/src/tracing/transaction.ts +++ b/packages/core/src/tracing/transaction.ts @@ -141,11 +141,15 @@ export class Transaction extends SpanClass implements TransactionInterface { // just sets the end timestamp super.finish(endTimestamp); + const client = this._hub.getClient(); + if (client && client.emit) { + client.emit('finishTransaction', this); + } + if (this.sampled !== true) { // At this point if `sampled !== true` we want to discard the transaction. __DEBUG_BUILD__ && logger.log('[Tracing] Discarding transaction because its trace was not chosen to be sampled.'); - const client = this._hub.getClient(); if (client) { client.recordDroppedEvent('sample_rate', 'transaction'); }