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 @@ -508,6 +508,14 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
508
508
*/
509
509
public on ( hook : 'spanEnd' , callback : ( span : Span ) => void ) : ( ) => void ;
510
510
511
+ /**
512
+ * Register a callback for after a span is ended.
513
+ * NOTE: The span cannot be mutated anymore in this callback.
514
+ * Receives the span as argument.
515
+ * @returns {() => void } A function that, when executed, removes the registered callback.
516
+ */
517
+ public on ( hook : 'segmentSpanEnd' , callback : ( span : Span ) => void ) : ( ) => void ;
518
+
511
519
/**
512
520
* Register a callback for when an idle span is allowed to auto-finish.
513
521
* @returns {() => void } A function that, when executed, removes the registered callback.
@@ -730,6 +738,9 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
730
738
/** Fire a hook whenever a span ends. */
731
739
public emit ( hook : 'spanEnd' , span : Span ) : void ;
732
740
741
+ /** Fire a hook whenever a segment span ends. */
742
+ public emit ( hook : 'segmentSpanEnd' , span : Span ) : void ;
743
+
733
744
/**
734
745
* Fire a hook indicating that an idle span is allowed to auto finish.
735
746
*/
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