Skip to content

Commit

Permalink
fix: Report dropped spans for transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Jul 4, 2024
1 parent 13ff71f commit 1ec9c35
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,18 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
return prepared;
}

const result = processBeforeSend(options, prepared, hint);
const result = processBeforeSend(this, options, prepared, hint);
return _validateBeforeSendResult(result, beforeSendLabel);
})
.then(processedEvent => {
if (processedEvent === null) {
this.recordDroppedEvent('before_send', dataCategory, event);
if (isTransactionEvent(event)) {
const spans = event.spans || [];
// the transaction itself counts as one span, plus all the child spans that are added
const spanCount = 1 + spans.length;
this._outcomes['span'] = (this._outcomes['span'] || 0) + spanCount;
}
throw new SentryError(`${beforeSendLabel} returned \`null\`, will not send event.`, 'log');
}

Expand Down Expand Up @@ -893,6 +899,7 @@ function _validateBeforeSendResult(
* Process the matching `beforeSendXXX` callback.
*/
function processBeforeSend(
client: Client,
options: ClientOptions,
event: Event,
hint: EventHint,
Expand All @@ -910,6 +917,8 @@ function processBeforeSend(
const processedSpan = beforeSendSpan(span);
if (processedSpan) {
processedSpans.push(processedSpan);
} else {
client.recordDroppedEvent('before_send', 'span');
}
}
event.spans = processedSpans;
Expand Down

0 comments on commit 1ec9c35

Please sign in to comment.