1 | import { Exception } from '../common/Exception';
|
2 | import { TimeInput } from '../common/Time';
|
3 | import { SpanAttributes, SpanAttributeValue } from './attributes';
|
4 | import { SpanContext } from './span_context';
|
5 | import { SpanStatus } from './status';
|
6 | /**
|
7 | * An interface that represents a span. A span represents a single operation
|
8 | * within a trace. Examples of span might include remote procedure calls or a
|
9 | * in-process function calls to sub-components. A Trace has a single, top-level
|
10 | * "root" Span that in turn may have zero or more child Spans, which in turn
|
11 | * may have children.
|
12 | *
|
13 | * Spans are created by the {@link Tracer.startSpan} method.
|
14 | */
|
15 | export interface Span {
|
16 | /**
|
17 | * Returns the {@link SpanContext} object associated with this Span.
|
18 | *
|
19 | * Get an immutable, serializable identifier for this span that can be used
|
20 | * to create new child spans. Returned SpanContext is usable even after the
|
21 | * span ends.
|
22 | *
|
23 | * @returns the SpanContext object associated with this Span.
|
24 | */
|
25 | spanContext(): SpanContext;
|
26 | /**
|
27 | * Sets an attribute to the span.
|
28 | *
|
29 | * Sets a single Attribute with the key and value passed as arguments.
|
30 | *
|
31 | * @param key the key for this attribute.
|
32 | * @param value the value for this attribute. Setting a value null or
|
33 | * undefined is invalid and will result in undefined behavior.
|
34 | */
|
35 | setAttribute(key: string, value: SpanAttributeValue): this;
|
36 | /**
|
37 | * Sets attributes to the span.
|
38 | *
|
39 | * @param attributes the attributes that will be added.
|
40 | * null or undefined attribute values
|
41 | * are invalid and will result in undefined behavior.
|
42 | */
|
43 | setAttributes(attributes: SpanAttributes): this;
|
44 | /**
|
45 | * Adds an event to the Span.
|
46 | *
|
47 | * @param name the name of the event.
|
48 | * @param [attributesOrStartTime] the attributes that will be added; these are
|
49 | * associated with this event. Can be also a start time
|
50 | * if type is {@type TimeInput} and 3rd param is undefined
|
51 | * @param [startTime] start time of the event.
|
52 | */
|
53 | addEvent(name: string, attributesOrStartTime?: SpanAttributes | TimeInput, startTime?: TimeInput): this;
|
54 | /**
|
55 | * Sets a status to the span. If used, this will override the default Span
|
56 | * status. Default is {@link SpanStatusCode.UNSET}. SetStatus overrides the value
|
57 | * of previous calls to SetStatus on the Span.
|
58 | *
|
59 | * @param status the SpanStatus to set.
|
60 | */
|
61 | setStatus(status: SpanStatus): this;
|
62 | /**
|
63 | * Updates the Span name.
|
64 | *
|
65 | * This will override the name provided via {@link Tracer.startSpan}.
|
66 | *
|
67 | * Upon this update, any sampling behavior based on Span name will depend on
|
68 | * the implementation.
|
69 | *
|
70 | * @param name the Span name.
|
71 | */
|
72 | updateName(name: string): this;
|
73 | /**
|
74 | * Marks the end of Span execution.
|
75 | *
|
76 | * Call to End of a Span MUST not have any effects on child spans. Those may
|
77 | * still be running and can be ended later.
|
78 | *
|
79 | * Do not return `this`. The Span generally should not be used after it
|
80 | * is ended so chaining is not desired in this context.
|
81 | *
|
82 | * @param [endTime] the time to set as Span's end time. If not provided,
|
83 | * use the current time as the span's end time.
|
84 | */
|
85 | end(endTime?: TimeInput): void;
|
86 | /**
|
87 | * Returns the flag whether this span will be recorded.
|
88 | *
|
89 | * @returns true if this Span is active and recording information like events
|
90 | * with the `AddEvent` operation and attributes using `setAttributes`.
|
91 | */
|
92 | isRecording(): boolean;
|
93 | /**
|
94 | * Sets exception as a span event
|
95 | * @param exception the exception the only accepted values are string or Error
|
96 | * @param [time] the time to set as Span's event time. If not provided,
|
97 | * use the current time.
|
98 | */
|
99 | recordException(exception: Exception, time?: TimeInput): void;
|
100 | }
|
101 | //# sourceMappingURL=span.d.ts.map |
\ | No newline at end of file |