UNPKG

4.49 kBTypeScriptView Raw
1import type { Instrumenter } from './instrumenter';
2import type { Primitive } from './misc';
3import type { Transaction } from './transaction';
4/** Interface holding all properties that can be set on a Span on creation. */
5export interface SpanContext {
6 /**
7 * Description of the Span.
8 */
9 description?: string;
10 /**
11 * Operation of the Span.
12 */
13 op?: string;
14 /**
15 * Completion status of the Span.
16 * See: {@sentry/tracing SpanStatus} for possible values
17 */
18 status?: string;
19 /**
20 * Parent Span ID
21 */
22 parentSpanId?: string;
23 /**
24 * Was this span chosen to be sent as part of the sample?
25 */
26 sampled?: boolean;
27 /**
28 * Span ID
29 */
30 spanId?: string;
31 /**
32 * Trace ID
33 */
34 traceId?: string;
35 /**
36 * Tags of the Span.
37 */
38 tags?: {
39 [key: string]: Primitive;
40 };
41 /**
42 * Data of the Span.
43 */
44 data?: {
45 [key: string]: any;
46 };
47 /**
48 * Timestamp in seconds (epoch time) indicating when the span started.
49 */
50 startTimestamp?: number;
51 /**
52 * Timestamp in seconds (epoch time) indicating when the span ended.
53 */
54 endTimestamp?: number;
55 /**
56 * The instrumenter that created this span.
57 */
58 instrumenter?: Instrumenter;
59}
60/** Span holding trace_id, span_id */
61export interface Span extends SpanContext {
62 /**
63 * @inheritDoc
64 */
65 spanId: string;
66 /**
67 * @inheritDoc
68 */
69 traceId: string;
70 /**
71 * @inheritDoc
72 */
73 startTimestamp: number;
74 /**
75 * @inheritDoc
76 */
77 tags: {
78 [key: string]: Primitive;
79 };
80 /**
81 * @inheritDoc
82 */
83 data: {
84 [key: string]: any;
85 };
86 /**
87 * The transaction containing this span
88 */
89 transaction?: Transaction;
90 /**
91 * The instrumenter that created this span.
92 */
93 instrumenter: Instrumenter;
94 /**
95 * Sets the finish timestamp on the current span.
96 * @param endTimestamp Takes an endTimestamp if the end should not be the time when you call this function.
97 */
98 finish(endTimestamp?: number): void;
99 /**
100 * Sets the tag attribute on the current span.
101 *
102 * Can also be used to unset a tag, by passing `undefined`.
103 *
104 * @param key Tag key
105 * @param value Tag value
106 */
107 setTag(key: string, value: Primitive): this;
108 /**
109 * Sets the data attribute on the current span
110 * @param key Data key
111 * @param value Data value
112 */
113 setData(key: string, value: any): this;
114 /**
115 * Sets the status attribute on the current span
116 * See: {@sentry/tracing SpanStatus} for possible values
117 * @param status http code used to set the status
118 */
119 setStatus(status: string): this;
120 /**
121 * Sets the status attribute on the current span based on the http code
122 * @param httpStatus http code used to set the status
123 */
124 setHttpStatus(httpStatus: number): this;
125 /**
126 * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`.
127 * Also the `sampled` decision will be inherited.
128 */
129 startChild(spanContext?: Pick<SpanContext, Exclude<keyof SpanContext, 'sampled' | 'traceId' | 'parentSpanId'>>): Span;
130 /**
131 * Determines whether span was successful (HTTP200)
132 */
133 isSuccess(): boolean;
134 /** Return a traceparent compatible header string */
135 toTraceparent(): string;
136 /** Returns the current span properties as a `SpanContext` */
137 toContext(): SpanContext;
138 /** Updates the current span with a new `SpanContext` */
139 updateWithContext(spanContext: SpanContext): this;
140 /** Convert the object to JSON for w. spans array info only */
141 getTraceContext(): {
142 data?: {
143 [key: string]: any;
144 };
145 description?: string;
146 op?: string;
147 parent_span_id?: string;
148 span_id: string;
149 status?: string;
150 tags?: {
151 [key: string]: Primitive;
152 };
153 trace_id: string;
154 };
155 /** Convert the object to JSON */
156 toJSON(): {
157 data?: {
158 [key: string]: any;
159 };
160 description?: string;
161 op?: string;
162 parent_span_id?: string;
163 span_id: string;
164 start_timestamp: number;
165 status?: string;
166 tags?: {
167 [key: string]: Primitive;
168 };
169 timestamp?: number;
170 trace_id: string;
171 };
172}
173//# sourceMappingURL=span.d.ts.map
\No newline at end of file