-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathspan.ts
185 lines (156 loc) · 3.9 KB
/
span.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import { Primitive } from './misc';
import { Transaction } from './transaction';
/** Interface holding all properties that can be set on a Span on creation. */
export interface SpanContext {
/**
* Description of the Span.
*/
description?: string;
/**
* Operation of the Span.
*/
op?: string;
/**
* Completion status of the Span.
* See: {@sentry/tracing SpanStatus} for possible values
*/
status?: string;
/**
* Parent Span ID
*/
parentSpanId?: string;
/**
* Was this span chosen to be sent as part of the sample?
*/
sampled?: boolean;
/**
* Span ID
*/
spanId?: string;
/**
* Trace ID
*/
traceId?: string;
/**
* Tags of the Span.
*/
tags?: { [key: string]: Primitive };
/**
* Data of the Span.
*/
data?: { [key: string]: any };
/**
* Timestamp in seconds (epoch time) indicating when the span started.
*/
startTimestamp?: number;
/**
* Timestamp in seconds (epoch time) indicating when the span ended.
*/
endTimestamp?: number;
}
/** Span holding trace_id, span_id */
export interface Span extends SpanContext {
/**
* @inheritDoc
*/
spanId: string;
/**
* @inheritDoc
*/
traceId: string;
/**
* @inheritDoc
*/
startTimestamp: number;
/**
* @inheritDoc
*/
tags: { [key: string]: Primitive };
/**
* @inheritDoc
*/
data: { [key: string]: any };
/**
* The transaction containing this span
*/
transaction?: Transaction;
/**
* Sets the finish timestamp on the current span.
* @param endTimestamp Takes an endTimestamp if the end should not be the time when you call this function.
*/
finish(endTimestamp?: number): void;
/**
* Sets the tag attribute on the current span.
*
* Can also be used to unset a tag, by passing `undefined`.
*
* @param key Tag key
* @param value Tag value
*/
setTag(key: string, value: Primitive): this;
/**
* Sets the data attribute on the current span
* @param key Data key
* @param value Data value
*/
setData(key: string, value: any): this;
/**
* Sets the status attribute on the current span
* See: {@sentry/tracing SpanStatus} for possible values
* @param status http code used to set the status
*/
setStatus(status: string): this;
/**
* Sets the status attribute on the current span based on the http code
* @param httpStatus http code used to set the status
*/
setHttpStatus(httpStatus: number): this;
/**
* Use {@link startChild}
* @deprecated
*/
child(
spanContext?: Pick<SpanContext, Exclude<keyof SpanContext, 'spanId' | 'sampled' | 'traceId' | 'parentSpanId'>>,
): Span;
/**
* Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.
* Also the `sampled` decision will be inherited.
*/
startChild(
spanContext?: Pick<SpanContext, Exclude<keyof SpanContext, 'spanId' | 'sampled' | 'traceId' | 'parentSpanId'>>,
): Span;
/**
* Determines whether span was successful (HTTP200)
*/
isSuccess(): boolean;
/** Return a traceparent compatible header string */
toTraceparent(): string;
/** Returns the current span properties as a `SpanContext` */
toContext(): SpanContext;
/** Updates the current span with a new `SpanContext` */
updateWithContext(spanContext: SpanContext): this;
/** Convert the object to JSON for w. spans array info only */
getTraceContext(): {
data?: { [key: string]: any };
description?: string;
op?: string;
parent_span_id?: string;
span_id: string;
status?: string;
tags?: { [key: string]: Primitive };
trace_id: string;
};
/** Convert the object to JSON */
toJSON(): {
data?: { [key: string]: any };
description?: string;
op?: string;
parent_span_id?: string;
span_id: string;
start_timestamp: number;
status?: string;
tags?: { [key: string]: Primitive };
timestamp?: number;
trace_id: string;
};
}