File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -509,6 +509,14 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
509
509
*/
510
510
public on ( hook : 'spanEnd' , callback : ( span : Span ) => void ) : ( ) => void ;
511
511
512
+ /**
513
+ * Register a callback for after a span is ended.
514
+ * NOTE: The span cannot be mutated anymore in this callback.
515
+ * Receives the span as argument.
516
+ * @returns {() => void } A function that, when executed, removes the registered callback.
517
+ */
518
+ public on ( hook : 'segmentSpanEnd' , callback : ( span : Span ) => void ) : ( ) => void ;
519
+
512
520
/**
513
521
* Register a callback for when an idle span is allowed to auto-finish.
514
522
* @returns {() => void } A function that, when executed, removes the registered callback.
@@ -742,6 +750,9 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
742
750
/** Fire a hook whenever a span ends. */
743
751
public emit ( hook : 'spanEnd' , span : Span ) : void ;
744
752
753
+ /** Fire a hook whenever a segment span ends. */
754
+ public emit ( hook : 'segmentSpanEnd' , span : Span ) : void ;
755
+
745
756
/**
746
757
* Fire a hook indicating that an idle span is allowed to auto finish.
747
758
*/
Original file line number Diff line number Diff line change @@ -298,6 +298,8 @@ export class SentrySpan implements Span {
298
298
return ;
299
299
}
300
300
301
+ client ?. emit ( 'segmentSpanEnd' , this ) ;
302
+
301
303
// if this is a standalone span, we send it immediately
302
304
if ( this . _isStandaloneSpan ) {
303
305
if ( this . _sampled ) {
@@ -310,6 +312,9 @@ export class SentrySpan implements Span {
310
312
}
311
313
}
312
314
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 ;
313
318
}
314
319
315
320
const transactionEvent = this . _convertSpanToTransaction ( ) ;
Original file line number Diff line number Diff line change @@ -282,6 +282,14 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
282
282
_experiments ?: {
283
283
// eslint-disable-next-line @typescript-eslint/no-explicit-any
284
284
[ key : string ] : any ;
285
+
286
+ /**
287
+ * DO NOT set this option manually.
288
+ *
289
+ * @internal , this option is only used and set internally.
290
+ * @hidden
291
+ */
292
+ _INTERNAL_spanStreaming ?: boolean ;
285
293
} ;
286
294
287
295
/**
You can’t perform that action at this time.
0 commit comments