1 | import type { Measurements } from './measurement';
|
2 | import type { Primitive } from './misc';
|
3 | import type { HrTime } from './opentelemetry';
|
4 | import type { SpanStatus } from './spanStatus';
|
5 | import type { TransactionSource } from './transaction';
|
6 | type SpanOriginType = 'manual' | 'auto';
|
7 | type SpanOriginCategory = string;
|
8 | type SpanOriginIntegrationName = string;
|
9 | type SpanOriginIntegrationPart = string;
|
10 | export type SpanOrigin = SpanOriginType | `${SpanOriginType}.${SpanOriginCategory}` | `${SpanOriginType}.${SpanOriginCategory}.${SpanOriginIntegrationName}` | `${SpanOriginType}.${SpanOriginCategory}.${SpanOriginIntegrationName}.${SpanOriginIntegrationPart}`;
|
11 | export type SpanAttributeValue = string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>;
|
12 | export type SpanAttributes = Partial<{
|
13 | 'sentry.origin': string;
|
14 | 'sentry.op': string;
|
15 | 'sentry.source': TransactionSource;
|
16 | 'sentry.sample_rate': number;
|
17 | }> & Record<string, SpanAttributeValue | undefined>;
|
18 | export type MetricSummary = {
|
19 | min: number;
|
20 | max: number;
|
21 | count: number;
|
22 | sum: number;
|
23 | tags?: Record<string, Primitive> | undefined;
|
24 | };
|
25 | /** This type is aligned with the OpenTelemetry TimeInput type. */
|
26 | export type SpanTimeInput = HrTime | number | Date;
|
27 | /** A JSON representation of a span. */
|
28 | export interface SpanJSON {
|
29 | data?: {
|
30 | [key: string]: any;
|
31 | };
|
32 | description?: string;
|
33 | op?: string;
|
34 | parent_span_id?: string;
|
35 | span_id: string;
|
36 | start_timestamp: number;
|
37 | status?: string;
|
38 | timestamp?: number;
|
39 | trace_id: string;
|
40 | origin?: SpanOrigin;
|
41 | _metrics_summary?: Record<string, Array<MetricSummary>>;
|
42 | profile_id?: string;
|
43 | exclusive_time?: number;
|
44 | measurements?: Measurements;
|
45 | is_segment?: boolean;
|
46 | segment_id?: string;
|
47 | }
|
48 | type TraceFlagNone = 0;
|
49 | type TraceFlagSampled = 1;
|
50 | export type TraceFlag = TraceFlagNone | TraceFlagSampled;
|
51 | export interface TraceState {
|
52 | /**
|
53 | * Create a new TraceState which inherits from this TraceState and has the
|
54 | * given key set.
|
55 | * The new entry will always be added in the front of the list of states.
|
56 | *
|
57 | * @param key key of the TraceState entry.
|
58 | * @param value value of the TraceState entry.
|
59 | */
|
60 | set(key: string, value: string): TraceState;
|
61 | /**
|
62 | * Return a new TraceState which inherits from this TraceState but does not
|
63 | * contain the given key.
|
64 | *
|
65 | * @param key the key for the TraceState entry to be removed.
|
66 | */
|
67 | unset(key: string): TraceState;
|
68 | /**
|
69 | * Returns the value to which the specified key is mapped, or `undefined` if
|
70 | * this map contains no mapping for the key.
|
71 | *
|
72 | * @param key with which the specified value is to be associated.
|
73 | * @returns the value to which the specified key is mapped, or `undefined` if
|
74 | * this map contains no mapping for the key.
|
75 | */
|
76 | get(key: string): string | undefined;
|
77 | /**
|
78 | * Serializes the TraceState to a `list` as defined below. The `list` is a
|
79 | * series of `list-members` separated by commas `,`, and a list-member is a
|
80 | * key/value pair separated by an equals sign `=`. Spaces and horizontal tabs
|
81 | * surrounding `list-members` are ignored. There can be a maximum of 32
|
82 | * `list-members` in a `list`.
|
83 | *
|
84 | * @returns the serialized string.
|
85 | */
|
86 | serialize(): string;
|
87 | }
|
88 | export interface SpanContextData {
|
89 | /**
|
90 | * The ID of the trace that this span belongs to. It is worldwide unique
|
91 | * with practically sufficient probability by being made as 16 randomly
|
92 | * generated bytes, encoded as a 32 lowercase hex characters corresponding to
|
93 | * 128 bits.
|
94 | */
|
95 | traceId: string;
|
96 | /**
|
97 | * The ID of the Span. It is globally unique with practically sufficient
|
98 | * probability by being made as 8 randomly generated bytes, encoded as a 16
|
99 | * lowercase hex characters corresponding to 64 bits.
|
100 | */
|
101 | spanId: string;
|
102 | /**
|
103 | * Only true if the SentrySpanArguments was propagated from a remote parent.
|
104 | */
|
105 | isRemote?: boolean | undefined;
|
106 | /**
|
107 | * Trace flags to propagate.
|
108 | *
|
109 | * It is represented as 1 byte (bitmap). Bit to represent whether trace is
|
110 | * sampled or not. When set, the least significant bit documents that the
|
111 | * caller may have recorded trace data. A caller who does not record trace
|
112 | * data out-of-band leaves this flag unset.
|
113 | */
|
114 | traceFlags: TraceFlag | number;
|
115 | /** In OpenTelemetry, this can be used to store trace state, which are basically key-value pairs. */
|
116 | traceState?: TraceState | undefined;
|
117 | }
|
118 | /**
|
119 | * Interface holding all properties that can be set on a Span on creation.
|
120 | * This is only used for the legacy span/transaction creation and will go away in v8.
|
121 | */
|
122 | export interface SentrySpanArguments {
|
123 | /**
|
124 | * Human-readable identifier for the span.
|
125 | */
|
126 | name?: string | undefined;
|
127 | /**
|
128 | * Operation of the Span.
|
129 | */
|
130 | op?: string | undefined;
|
131 | /**
|
132 | * Parent Span ID
|
133 | */
|
134 | parentSpanId?: string | undefined;
|
135 | /**
|
136 | * Was this span chosen to be sent as part of the sample?
|
137 | */
|
138 | sampled?: boolean | undefined;
|
139 | /**
|
140 | * Span ID
|
141 | */
|
142 | spanId?: string | undefined;
|
143 | /**
|
144 | * Trace ID
|
145 | */
|
146 | traceId?: string | undefined;
|
147 | /**
|
148 | * Attributes of the Span.
|
149 | */
|
150 | attributes?: SpanAttributes;
|
151 | /**
|
152 | * Timestamp in seconds (epoch time) indicating when the span started.
|
153 | */
|
154 | startTimestamp?: number | undefined;
|
155 | /**
|
156 | * Timestamp in seconds (epoch time) indicating when the span ended.
|
157 | */
|
158 | endTimestamp?: number | undefined;
|
159 | /**
|
160 | * Set to `true` if this span should be sent as a standalone segment span
|
161 | * as opposed to a transaction.
|
162 | *
|
163 | * @experimental this option is currently experimental and should only be
|
164 | * used within SDK code. It might be removed or changed in the future.
|
165 | */
|
166 | isStandalone?: boolean | undefined;
|
167 | }
|
168 | /**
|
169 | * A generic Span which holds trace data.
|
170 | */
|
171 | export interface Span {
|
172 | /**
|
173 | * Get context data for this span.
|
174 | * This includes the spanId & the traceId.
|
175 | */
|
176 | spanContext(): SpanContextData;
|
177 | /**
|
178 | * End the current span.
|
179 | */
|
180 | end(endTimestamp?: SpanTimeInput): void;
|
181 | /**
|
182 | * Set a single attribute on the span.
|
183 | * Set it to `undefined` to remove the attribute.
|
184 | */
|
185 | setAttribute(key: string, value: SpanAttributeValue | undefined): this;
|
186 | /**
|
187 | * Set multiple attributes on the span.
|
188 | * Any attribute set to `undefined` will be removed.
|
189 | */
|
190 | setAttributes(attributes: SpanAttributes): this;
|
191 | /**
|
192 | * Sets the status attribute on the current span.
|
193 | */
|
194 | setStatus(status: SpanStatus): this;
|
195 | /**
|
196 | * Update the name of the span.
|
197 | */
|
198 | updateName(name: string): this;
|
199 | /**
|
200 | * If this is span is actually recording data.
|
201 | * This will return false if tracing is disabled, this span was not sampled or if the span is already finished.
|
202 | */
|
203 | isRecording(): boolean;
|
204 | /**
|
205 | * Adds an event to the Span.
|
206 | */
|
207 | addEvent(name: string, attributesOrStartTime?: SpanAttributes | SpanTimeInput, startTime?: SpanTimeInput): this;
|
208 | /**
|
209 | * NOT USED IN SENTRY, only added for compliance with OTEL Span interface
|
210 | */
|
211 | addLink(link: unknown): this;
|
212 | /**
|
213 | * NOT USED IN SENTRY, only added for compliance with OTEL Span interface
|
214 | */
|
215 | addLinks(links: unknown): this;
|
216 | /**
|
217 | * NOT USED IN SENTRY, only added for compliance with OTEL Span interface
|
218 | */
|
219 | recordException(exception: unknown, time?: number): void;
|
220 | }
|
221 | export {};
|
222 | //# sourceMappingURL=span.d.ts.map |
\ | No newline at end of file |