UNPKG

4.85 kBTypeScriptView Raw
1import type { Instrumenter, Primitive, Span as SpanInterface, SpanContext, TraceContext, Transaction } from '@sentry/types';
2/**
3 * Keeps track of finished spans for a given transaction
4 * @internal
5 * @hideconstructor
6 * @hidden
7 */
8export declare class SpanRecorder {
9 spans: Span[];
10 private readonly _maxlen;
11 constructor(maxlen?: number);
12 /**
13 * This is just so that we don't run out of memory while recording a lot
14 * of spans. At some point we just stop and flush out the start of the
15 * trace tree (i.e.the first n spans with the smallest
16 * start_timestamp).
17 */
18 add(span: Span): void;
19}
20/**
21 * Span contains all data about a span
22 */
23export declare class Span implements SpanInterface {
24 /**
25 * @inheritDoc
26 */
27 traceId: string;
28 /**
29 * @inheritDoc
30 */
31 spanId: string;
32 /**
33 * @inheritDoc
34 */
35 parentSpanId?: string;
36 /**
37 * Internal keeper of the status
38 */
39 status?: SpanStatusType | string;
40 /**
41 * @inheritDoc
42 */
43 sampled?: boolean;
44 /**
45 * Timestamp in seconds when the span was created.
46 */
47 startTimestamp: number;
48 /**
49 * Timestamp in seconds when the span ended.
50 */
51 endTimestamp?: number;
52 /**
53 * @inheritDoc
54 */
55 op?: string;
56 /**
57 * @inheritDoc
58 */
59 description?: string;
60 /**
61 * @inheritDoc
62 */
63 tags: {
64 [key: string]: Primitive;
65 };
66 /**
67 * @inheritDoc
68 */
69 data: {
70 [key: string]: any;
71 };
72 /**
73 * List of spans that were finalized
74 */
75 spanRecorder?: SpanRecorder;
76 /**
77 * @inheritDoc
78 */
79 transaction?: Transaction;
80 /**
81 * The instrumenter that created this span.
82 */
83 instrumenter: Instrumenter;
84 /**
85 * You should never call the constructor manually, always use `Sentry.startTransaction()`
86 * or call `startChild()` on an existing span.
87 * @internal
88 * @hideconstructor
89 * @hidden
90 */
91 constructor(spanContext?: SpanContext);
92 /**
93 * @inheritDoc
94 */
95 startChild(spanContext?: Pick<SpanContext, Exclude<keyof SpanContext, 'sampled' | 'traceId' | 'parentSpanId'>>): Span;
96 /**
97 * @inheritDoc
98 */
99 setTag(key: string, value: Primitive): this;
100 /**
101 * @inheritDoc
102 */
103 setData(key: string, value: any): this;
104 /**
105 * @inheritDoc
106 */
107 setStatus(value: SpanStatusType): this;
108 /**
109 * @inheritDoc
110 */
111 setHttpStatus(httpStatus: number): this;
112 /**
113 * @inheritDoc
114 */
115 isSuccess(): boolean;
116 /**
117 * @inheritDoc
118 */
119 finish(endTimestamp?: number): void;
120 /**
121 * @inheritDoc
122 */
123 toTraceparent(): string;
124 /**
125 * @inheritDoc
126 */
127 toContext(): SpanContext;
128 /**
129 * @inheritDoc
130 */
131 updateWithContext(spanContext: SpanContext): this;
132 /**
133 * @inheritDoc
134 */
135 getTraceContext(): TraceContext;
136 /**
137 * @inheritDoc
138 */
139 toJSON(): {
140 data?: {
141 [key: string]: any;
142 };
143 description?: string;
144 op?: string;
145 parent_span_id?: string;
146 span_id: string;
147 start_timestamp: number;
148 status?: string;
149 tags?: {
150 [key: string]: Primitive;
151 };
152 timestamp?: number;
153 trace_id: string;
154 };
155}
156export declare type SpanStatusType =
157/** The operation completed successfully. */
158'ok'
159/** Deadline expired before operation could complete. */
160 | 'deadline_exceeded'
161/** 401 Unauthorized (actually does mean unauthenticated according to RFC 7235) */
162 | 'unauthenticated'
163/** 403 Forbidden */
164 | 'permission_denied'
165/** 404 Not Found. Some requested entity (file or directory) was not found. */
166 | 'not_found'
167/** 429 Too Many Requests */
168 | 'resource_exhausted'
169/** Client specified an invalid argument. 4xx. */
170 | 'invalid_argument'
171/** 501 Not Implemented */
172 | 'unimplemented'
173/** 503 Service Unavailable */
174 | 'unavailable'
175/** Other/generic 5xx. */
176 | 'internal_error'
177/** Unknown. Any non-standard HTTP status code. */
178 | 'unknown_error'
179/** The operation was cancelled (typically by the user). */
180 | 'cancelled'
181/** Already exists (409) */
182 | 'already_exists'
183/** Operation was rejected because the system is not in a state required for the operation's */
184 | 'failed_precondition'
185/** The operation was aborted, typically due to a concurrency issue. */
186 | 'aborted'
187/** Operation was attempted past the valid range. */
188 | 'out_of_range'
189/** Unrecoverable data loss or corruption */
190 | 'data_loss';
191/**
192 * Converts a HTTP status code into a {@link SpanStatusType}.
193 *
194 * @param httpStatus The HTTP response status code.
195 * @returns The span status or unknown_error.
196 */
197export declare function spanStatusfromHttpCode(httpStatus: number): SpanStatusType;
198//# sourceMappingURL=span.d.ts.map
\No newline at end of file