1 | import Reference from './reference';
|
2 | import Span from './span';
|
3 | import SpanContext from './span_context';
|
4 | export interface SpanOptions {
|
5 | /**
|
6 | * a parent SpanContext (or Span, for convenience) that the newly-started
|
7 | * span will be the child of (per REFERENCE_CHILD_OF). If specified,
|
8 | * `references` must be unspecified.
|
9 | */
|
10 | childOf?: Span | SpanContext;
|
11 | /**
|
12 | * an array of Reference instances, each pointing to a causal parent
|
13 | * SpanContext. If specified, `fields.childOf` must be unspecified.
|
14 | */
|
15 | references?: Reference[];
|
16 | /**
|
17 | * set of key-value pairs which will be set as tags on the newly created
|
18 | * Span. Ownership of the object is passed to the created span for
|
19 | * efficiency reasons (the caller should not modify this object after
|
20 | * calling startSpan).
|
21 | */
|
22 | tags?: {
|
23 | [key: string]: any;
|
24 | };
|
25 | /**
|
26 | * a manually specified start time for the created Span object. The time
|
27 | * should be specified in milliseconds as Unix timestamp. Decimal value are
|
28 | * supported to represent time values with sub-millisecond accuracy.
|
29 | */
|
30 | startTime?: number;
|
31 | }
|
32 | /**
|
33 | * Tracer is the entry-point between the instrumentation API and the tracing
|
34 | * implementation.
|
35 | *
|
36 | * The default object acts as a no-op implementation.
|
37 | *
|
38 | * Note to implementators: derived classes can choose to directly implement the
|
39 | * methods in the "OpenTracing API methods" section, or optionally the subset of
|
40 | * underscore-prefixed methods to pick up the argument checking and handling
|
41 | * automatically from the base class.
|
42 | */
|
43 | export declare class Tracer {
|
44 | /**
|
45 | * Starts and returns a new Span representing a logical unit of work.
|
46 | *
|
47 | * For example:
|
48 | *
|
49 | * // Start a new (parentless) root Span:
|
50 | * var parent = Tracer.startSpan('DoWork');
|
51 | *
|
52 | * // Start a new (child) Span:
|
53 | * var child = Tracer.startSpan('load-from-db', {
|
54 | * childOf: parent.context(),
|
55 | * });
|
56 | *
|
57 | * // Start a new async (FollowsFrom) Span:
|
58 | * var child = Tracer.startSpan('async-cache-write', {
|
59 | * references: [
|
60 | * opentracing.followsFrom(parent.context())
|
61 | * ],
|
62 | * });
|
63 | *
|
64 | * @param {string} name - the name of the operation (REQUIRED).
|
65 | * @param {SpanOptions} [options] - options for the newly created span.
|
66 | * @return {Span} - a new Span object.
|
67 | */
|
68 | startSpan(name: string, options?: SpanOptions): Span;
|
69 | /**
|
70 | * Injects the given SpanContext instance for cross-process propagation
|
71 | * within `carrier`. The expected type of `carrier` depends on the value of
|
72 | * `format.
|
73 | *
|
74 | * OpenTracing defines a common set of `format` values (see
|
75 | * FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
|
76 | * an expected carrier type.
|
77 | *
|
78 | * Consider this pseudocode example:
|
79 | *
|
80 | * var clientSpan = ...;
|
81 | * ...
|
82 | * // Inject clientSpan into a text carrier.
|
83 | * var headersCarrier = {};
|
84 | * Tracer.inject(clientSpan.context(), Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
|
85 | * // Incorporate the textCarrier into the outbound HTTP request header
|
86 | * // map.
|
87 | * Object.assign(outboundHTTPReq.headers, headersCarrier);
|
88 | * // ... send the httpReq
|
89 | *
|
90 | * @param {SpanContext} spanContext - the SpanContext to inject into the
|
91 | * carrier object. As a convenience, a Span instance may be passed
|
92 | * in instead (in which case its .context() is used for the
|
93 | * inject()).
|
94 | * @param {string} format - the format of the carrier.
|
95 | * @param {any} carrier - see the documentation for the chosen `format`
|
96 | * for a description of the carrier object.
|
97 | */
|
98 | inject(spanContext: SpanContext | Span, format: string, carrier: any): void;
|
99 | /**
|
100 | * Returns a SpanContext instance extracted from `carrier` in the given
|
101 | * `format`.
|
102 | *
|
103 | * OpenTracing defines a common set of `format` values (see
|
104 | * FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
|
105 | * an expected carrier type.
|
106 | *
|
107 | * Consider this pseudocode example:
|
108 | *
|
109 | * // Use the inbound HTTP request's headers as a text map carrier.
|
110 | * var headersCarrier = inboundHTTPReq.headers;
|
111 | * var wireCtx = Tracer.extract(Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
|
112 | * var serverSpan = Tracer.startSpan('...', { childOf : wireCtx });
|
113 | *
|
114 | * @param {string} format - the format of the carrier.
|
115 | * @param {any} carrier - the type of the carrier object is determined by
|
116 | * the format.
|
117 | * @return {SpanContext}
|
118 | * The extracted SpanContext, or null if no such SpanContext could
|
119 | * be found in `carrier`
|
120 | */
|
121 | extract(format: string, carrier: any): SpanContext | null;
|
122 | protected _startSpan(name: string, fields: SpanOptions): Span;
|
123 | protected _inject(spanContext: SpanContext, format: string, carrier: any): void;
|
124 | protected _extract(format: string, carrier: any): SpanContext | null;
|
125 | }
|
126 | export default Tracer;
|
127 | //# sourceMappingURL=tracer.d.ts.map |
\ | No newline at end of file |