Skip to content

Commit 38f3b19

Browse files
committed
wip
1 parent 0f4c190 commit 38f3b19

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

packages/core/src/client.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,14 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
583583
*/
584584
public on(hook: 'spanEnd', callback: (span: Span) => void): () => void;
585585

586+
/**
587+
* Register a callback for after a span is ended.
588+
* NOTE: The span cannot be mutated anymore in this callback.
589+
* Receives the span as argument.
590+
* @returns {() => void} A function that, when executed, removes the registered callback.
591+
*/
592+
public on(hook: 'segmentSpanEnd', callback: (span: Span) => void): () => void;
593+
586594
/**
587595
* Register a callback for when an idle span is allowed to auto-finish.
588596
* @returns {() => void} A function that, when executed, removes the registered callback.
@@ -830,6 +838,9 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
830838
/** Fire a hook whenever a span ends. */
831839
public emit(hook: 'spanEnd', span: Span): void;
832840

841+
/** Fire a hook whenever a segment span ends. */
842+
public emit(hook: 'segmentSpanEnd', span: Span): void;
843+
833844
/**
834845
* Fire a hook indicating that an idle span is allowed to auto finish.
835846
*/

packages/core/src/tracing/sentrySpan.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ export class SentrySpan implements Span {
298298
return;
299299
}
300300

301+
client?.emit('segmentSpanEnd', this);
302+
301303
// if this is a standalone span, we send it immediately
302304
if (this._isStandaloneSpan) {
303305
if (this._sampled) {
@@ -310,6 +312,9 @@ export class SentrySpan implements Span {
310312
}
311313
}
312314
return;
315+
} else if (client?.getOptions()._experiments?._INTERNAL_spanStreaming) {
316+
// nothing to do here; the spanStreaming integration will listen to the respective client hook.
317+
return;
313318
}
314319

315320
const transactionEvent = this._convertSpanToTransaction();

packages/core/src/types-hoist/options.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
306306
* @deprecated Use the top level`beforeSendMetric` option instead.
307307
*/
308308
beforeSendMetric?: (metric: Metric) => Metric | null;
309+
310+
/**
311+
* DO NOT set this option manually.
312+
*
313+
* @internal, this option is only used and set internally.
314+
* @hidden
315+
*/
316+
_INTERNAL_spanStreaming?: boolean;
309317
};
310318

311319
/**

0 commit comments

Comments
 (0)