UNPKG

5.59 kBTypeScriptView Raw
1import { Logger } from '../../common/types';
2import * as configTypes from '../config/types';
3import * as types from './types';
4/** Defines a base model for spans. */
5export declare class Span implements types.Span {
6 protected className: string;
7 /** The clock used to mesure the beginning and ending of a span */
8 private clock;
9 /** Indicates if this span was started */
10 private startedLocal;
11 /** Indicates if this span was ended */
12 private endedLocal;
13 /** A list of child spans which are immediate, local children of this span */
14 private spansLocal;
15 /** The Span ID of this span */
16 readonly id: string;
17 /** A tracer object */
18 readonly tracer: types.TracerBase;
19 /** An object to log information to */
20 logger: Logger;
21 /** A set of attributes, each in the format [KEY]:[VALUE] */
22 attributes: types.Attributes;
23 /** A text annotation with a set of attributes. */
24 annotations: types.Annotation[];
25 /** An event describing a message sent/received between Spans */
26 messageEvents: types.MessageEvent[];
27 /** Pointers from the current span to another span */
28 links: types.Link[];
29 /** If the parent span is in another process. */
30 remoteParent: boolean;
31 /** This span's root span. If it's a root span, it will point to this */
32 root: Span;
33 /** This span's parent. If it's a root span, must be empty */
34 parentSpan?: Span;
35 /** The resource name of the span */
36 name: string;
37 /** Kind of span. */
38 kind: types.SpanKind;
39 /** A final status for this span */
40 status: types.Status;
41 /** Trace Parameters */
42 activeTraceParams: configTypes.TraceParams;
43 /** The number of dropped attributes. */
44 droppedAttributesCount: number;
45 /** The number of dropped links. */
46 droppedLinksCount: number;
47 /** The number of dropped annotations. */
48 droppedAnnotationsCount: number;
49 /** The number of dropped message events. */
50 droppedMessageEventsCount: number;
51 /** Constructs a new Span instance. */
52 constructor(tracer: types.TracerBase, parent?: Span);
53 /** Returns whether a span is root or not. */
54 isRootSpan(): boolean;
55 /** Gets the trace ID. */
56 get traceId(): string;
57 /** Gets the trace state */
58 get traceState(): types.TraceState | undefined;
59 /**
60 * Gets the ID of the parent span.
61 * RootSpan doesn't have a parentSpan but it override this method.
62 */
63 get parentSpanId(): string;
64 /** Indicates if span was started. */
65 get started(): boolean;
66 /** Indicates if span was ended. */
67 get ended(): boolean;
68 /**
69 * Gives a timestamp that indicates the span's start time in RFC3339 UTC
70 * "Zulu" format.
71 */
72 get startTime(): Date;
73 /** Recursively gets the descendant spans. */
74 allDescendants(): types.Span[];
75 /** The list of immediate child spans. */
76 get spans(): types.Span[];
77 /** The number of direct children. */
78 get numberOfChildren(): number;
79 /**
80 * Gives a timestamp that indicates the span's end time in RFC3339 UTC
81 * "Zulu" format.
82 */
83 get endTime(): Date;
84 /**
85 * Gets the duration of the clock.
86 */
87 get duration(): number;
88 /** Gives the TraceContext of the span. */
89 get spanContext(): types.SpanContext;
90 /**
91 * Adds an atribute to the span.
92 * @param key Describes the value added.
93 * @param value The result of an operation. If the value is a typeof object
94 * it has to be JSON.stringify-able, cannot contain circular dependencies.
95 */
96 addAttribute(key: string, value: string | number | boolean | object): void;
97 /**
98 * Adds an annotation to the span.
99 * @param description Describes the event.
100 * @param attributes A set of attributes on the annotation.
101 * @param timestamp A time, in milliseconds. Defaults to Date.now()
102 */
103 addAnnotation(description: string, attributes?: types.Attributes, timestamp?: number): void;
104 /**
105 * Adds a link to the span.
106 * @param traceId The trace ID for a trace within a project.
107 * @param spanId The span ID for a span within a trace.
108 * @param type The relationship of the current span relative to the linked.
109 * @param attributes A set of attributes on the link.
110 */
111 addLink(traceId: string, spanId: string, type: types.LinkType, attributes?: types.Attributes): void;
112 /**
113 * Adds a message event to the span.
114 * @param type The type of message event.
115 * @param id An identifier for the message event.
116 * @param timestamp A time in milliseconds. Defaults to Date.now()
117 * @param uncompressedSize The number of uncompressed bytes sent or received
118 * @param compressedSize The number of compressed bytes sent or received. If
119 * zero or undefined, assumed to be the same size as uncompressed.
120 */
121 addMessageEvent(type: types.MessageEventType, id: number, timestamp?: number, uncompressedSize?: number, compressedSize?: number): void;
122 /**
123 * Sets a status to the span.
124 * @param code The canonical status code.
125 * @param message optional A developer-facing error message.
126 */
127 setStatus(code: types.CanonicalCode, message?: string): void;
128 /** Starts the span. */
129 start(): void;
130 /** Ends the span and all of its children, recursively. */
131 end(): void;
132 /** Forces the span to end. */
133 truncate(): void;
134 /**
135 * Starts a new child span.
136 * @param [options] A SpanOptions object to start a child span.
137 */
138 startChildSpan(options?: types.SpanOptions): types.Span;
139}