Skip to content

Commit 85cdaaa

Browse files
committed
chore: added option to disable tracing
1 parent ea7fd72 commit 85cdaaa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/tracer/Tracer.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Tracer {
77
protected resolveWaitChunksP: (() => void) | undefined;
88
protected ended: boolean = false;
99
protected idGen = new IdSortable();
10+
protected shouldTrace = false;
1011

1112
protected nextId(): SpanId {
1213
const result = this.idGen.next();
@@ -16,7 +17,8 @@ class Tracer {
1617
return result.value.toMultibase('base32hex') as SpanId;
1718
}
1819

19-
protected queueSpanEvent(evt: SpanEvent) {
20+
protected queueSpanEvent(evt: SpanEvent): void {
21+
if (!this.shouldTrace) return;
2022
this.queue.push(evt);
2123
if (this.resolveWaitChunksP != null) this.resolveWaitChunksP();
2224
}
@@ -75,6 +77,13 @@ class Tracer {
7577
yield value;
7678
}
7779
}
80+
81+
public disableTracing(): void {
82+
this.shouldTrace = false;
83+
this.ended = true;
84+
this.resolveWaitChunksP?.();
85+
this.queue = [];
86+
}
7887
}
7988

8089
export default Tracer;

0 commit comments

Comments
 (0)