Skip to content

Commit 9ddaa92

Browse files
committed
wip
1 parent 632f0b9 commit 9ddaa92

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

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

753+
/** Fire a hook whenever a segment span ends. */
754+
public emit(hook: 'segmentSpanEnd', span: Span): void;
755+
745756
/**
746757
* Fire a hook indicating that an idle span is allowed to auto finish.
747758
*/

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)