-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathsentryNonRecordingSpan.ts
104 lines (91 loc) · 2.31 KB
/
sentryNonRecordingSpan.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import type {
SentrySpanArguments,
Span,
SpanAttributeValue,
SpanAttributes,
SpanContextData,
SpanStatus,
SpanTimeInput,
} from '../types-hoist';
import { generateSpanId, generateTraceId } from '../utils-hoist/propagationContext';
import { TRACE_FLAG_NONE } from '../utils/spanUtils';
/**
* A Sentry Span that is non-recording, meaning it will not be sent to Sentry.
*/
export class SentryNonRecordingSpan implements Span {
private _traceId: string;
private _spanId: string;
public constructor(spanContext: SentrySpanArguments = {}) {
this._traceId = spanContext.traceId || generateTraceId();
this._spanId = spanContext.spanId || generateSpanId();
}
/** @inheritdoc */
public spanContext(): SpanContextData {
return {
spanId: this._spanId,
traceId: this._traceId,
traceFlags: TRACE_FLAG_NONE,
};
}
/** @inheritdoc */
// eslint-disable-next-line @typescript-eslint/no-empty-function
public end(_timestamp?: SpanTimeInput): void {}
/** @inheritdoc */
public setAttribute(_key: string, _value: SpanAttributeValue | undefined): this {
return this;
}
/** @inheritdoc */
public setAttributes(_values: SpanAttributes): this {
return this;
}
/** @inheritdoc */
public setStatus(_status: SpanStatus): this {
return this;
}
/** @inheritdoc */
public updateName(_name: string): this {
return this;
}
/** @inheritdoc */
public isRecording(): boolean {
return false;
}
/** @inheritdoc */
public addEvent(
_name: string,
_attributesOrStartTime?: SpanAttributes | SpanTimeInput,
_startTime?: SpanTimeInput,
): this {
return this;
}
/**
* This should generally not be used,
* but we need it for being compliant with the OTEL Span interface.
*
* @hidden
* @internal
*/
public addLink(_link: unknown): this {
return this;
}
/**
* This should generally not be used,
* but we need it for being compliant with the OTEL Span interface.
*
* @hidden
* @internal
*/
public addLinks(_links: unknown[]): this {
return this;
}
/**
* This should generally not be used,
* but we need it for being compliant with the OTEL Span interface.
*
* @hidden
* @internal
*/
public recordException(_exception: unknown, _time?: number | undefined): void {
// noop
}
}