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 @@ -607,6 +607,14 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
607607 */
608608 public on ( hook : 'spanEnd' , callback : ( span : Span ) => void ) : ( ) => void ;
609609
610+ /**
611+ * Register a callback for after a span is ended.
612+ * NOTE: The span cannot be mutated anymore in this callback.
613+ * Receives the span as argument.
614+ * @returns {() => void } A function that, when executed, removes the registered callback.
615+ */
616+ public on ( hook : 'segmentSpanEnd' , callback : ( span : Span ) => void ) : ( ) => void ;
617+
610618 /**
611619 * Register a callback for when an idle span is allowed to auto-finish.
612620 * @returns {() => void } A function that, when executed, removes the registered callback.
@@ -879,6 +887,9 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
879887 /** Fire a hook whenever a span ends. */
880888 public emit ( hook : 'spanEnd' , span : Span ) : void ;
881889
890+ /** Fire a hook whenever a segment span ends. */
891+ public emit ( hook : 'segmentSpanEnd' , span : Span ) : void ;
892+
882893 /**
883894 * Fire a hook indicating that an idle span is allowed to auto finish.
884895 */
Original file line number Diff line number Diff 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 ( ) ;
Original file line number Diff line number Diff line change @@ -314,6 +314,14 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
314314 * @deprecated Use the top level `enableLogs` option instead.
315315 */
316316 enableLogs ?: boolean ;
317+
318+ /*
319+ * DO NOT set this option manually.
320+ *
321+ * @internal , this option is only used and set internally.
322+ * @hidden
323+ */
324+ _INTERNAL_spanStreaming ?: boolean ;
317325 } ;
318326
319327 /**
You can’t perform that action at this time.
0 commit comments