Skip to content

Commit 42460ad

Browse files
committed
wip
1 parent 80d5ff2 commit 42460ad

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
@@ -508,6 +508,14 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
508508
*/
509509
public on(hook: 'spanEnd', callback: (span: Span) => void): () => void;
510510

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+
511519
/**
512520
* Register a callback for when an idle span is allowed to auto-finish.
513521
* @returns {() => void} A function that, when executed, removes the registered callback.
@@ -730,6 +738,9 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
730738
/** Fire a hook whenever a span ends. */
731739
public emit(hook: 'spanEnd', span: Span): void;
732740

741+
/** Fire a hook whenever a segment span ends. */
742+
public emit(hook: 'segmentSpanEnd', span: Span): void;
743+
733744
/**
734745
* Fire a hook indicating that an idle span is allowed to auto finish.
735746
*/

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
@@ -282,6 +282,14 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
282282
_experiments?: {
283283
// eslint-disable-next-line @typescript-eslint/no-explicit-any
284284
[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;
285293
};
286294

287295
/**

0 commit comments

Comments
 (0)