1 | import * as api from '@opentelemetry/api';
|
2 | import { InstrumentationLibrary } from '@opentelemetry/core';
|
3 | import { Resource } from '@opentelemetry/resources';
|
4 | import { BasicTracerProvider } from './BasicTracerProvider';
|
5 | import { SpanLimits, TracerConfig } from './types';
|
6 |
|
7 |
|
8 |
|
9 | export declare class Tracer implements api.Tracer {
|
10 | private _tracerProvider;
|
11 | private readonly _sampler;
|
12 | private readonly _spanLimits;
|
13 | private readonly _idGenerator;
|
14 | readonly resource: Resource;
|
15 | readonly instrumentationLibrary: InstrumentationLibrary;
|
16 | |
17 |
|
18 |
|
19 | constructor(instrumentationLibrary: InstrumentationLibrary, config: TracerConfig, _tracerProvider: BasicTracerProvider);
|
20 | /**
|
21 | * Starts a new Span or returns the default NoopSpan based on the sampling
|
22 | * decision.
|
23 | */
|
24 | startSpan(name: string, options?: api.SpanOptions, context?: api.Context): api.Span;
|
25 | /**
|
26 | * Starts a new {@link Span} and calls the given function passing it the
|
27 | * created span as first argument.
|
28 | * Additionally the new span gets set in context and this context is activated
|
29 | * for the duration of the function call.
|
30 | *
|
31 | * @param name The name of the span
|
32 | * @param [options] SpanOptions used for span creation
|
33 | * @param [context] Context to use to extract parent
|
34 | * @param fn function called in the context of the span and receives the newly created span as an argument
|
35 | * @returns return value of fn
|
36 | * @example
|
37 | * const something = tracer.startActiveSpan('op', span => {
|
38 | * try {
|
39 | * do some work
|
40 | * span.setStatus({code: SpanStatusCode.OK});
|
41 | * return something;
|
42 | * } catch (err) {
|
43 | * span.setStatus({
|
44 | * code: SpanStatusCode.ERROR,
|
45 | * message: err.message,
|
46 | * });
|
47 | * throw err;
|
48 | * } finally {
|
49 | * span.end();
|
50 | * }
|
51 | * });
|
52 | * @example
|
53 | * const span = tracer.startActiveSpan('op', span => {
|
54 | * try {
|
55 | * do some work
|
56 | * return span;
|
57 | * } catch (err) {
|
58 | * span.setStatus({
|
59 | * code: SpanStatusCode.ERROR,
|
60 | * message: err.message,
|
61 | * });
|
62 | * throw err;
|
63 | * }
|
64 | * });
|
65 | * do some more work
|
66 | * span.end();
|
67 | */
|
68 | startActiveSpan<F extends (span: api.Span) => ReturnType<F>>(name: string, fn: F): ReturnType<F>;
|
69 | startActiveSpan<F extends (span: api.Span) => ReturnType<F>>(name: string, opts: api.SpanOptions, fn: F): ReturnType<F>;
|
70 | startActiveSpan<F extends (span: api.Span) => ReturnType<F>>(name: string, opts: api.SpanOptions, ctx: api.Context, fn: F): ReturnType<F>;
|
71 |
|
72 | getSpanLimits(): SpanLimits;
|
73 | getActiveSpanProcessor(): import("./SpanProcessor").SpanProcessor;
|
74 | }
|
75 |
|
\ | No newline at end of file |