UNPKG

3.3 kBTypeScriptView Raw
1/**
2 * Copyright 2018, OpenCensus Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import * as loggerTypes from '../../common/types';
17import * as configTypes from '../config/types';
18import { TraceParams } from '../config/types';
19import { Propagation } from '../propagation/types';
20import * as samplerTypes from '../sampler/types';
21import * as types from './types';
22/**
23 * This class represents a tracer.
24 */
25export declare class CoreTracerBase implements types.TracerBase {
26 /** Indicates if the tracer is active */
27 private activeLocal;
28 /** A configuration for starting the tracer */
29 private config;
30 /** A list of end span event listeners */
31 private eventListenersLocal;
32 /** Bit to represent whether trace is sampled or not. */
33 private readonly IS_SAMPLED;
34 /** A sampler used to make sample decisions */
35 sampler: samplerTypes.Sampler;
36 /** An object to log information */
37 logger: loggerTypes.Logger;
38 /** A configuration object for trace parameters */
39 activeTraceParams: TraceParams;
40 /** Constructs a new TraceImpl instance. */
41 constructor();
42 /** A propagation instance */
43 readonly propagation: Propagation;
44 /** Sets the current root span. */
45 setCurrentRootSpan(root: types.Span): void;
46 /**
47 * Starts a tracer.
48 * @param config A tracer configuration object to start a tracer.
49 */
50 start(config: configTypes.TracerConfig): this;
51 /** Stops the tracer. */
52 stop(): this;
53 /** Gets the list of event listeners. */
54 readonly eventListeners: types.SpanEventListener[];
55 /** Indicates if the tracer is active or not. */
56 readonly active: boolean;
57 /**
58 * Starts a root span.
59 * @param options A TraceOptions object to start a root span.
60 * @param fn A callback function to run after starting a root span.
61 */
62 startRootSpan<T>(options: types.TraceOptions, fn: (root: types.Span) => T): T;
63 /** Notifies listeners of the span start. */
64 onStartSpan(span: types.Span): void;
65 /** Notifies listeners of the span end. */
66 onEndSpan(span: types.Span): void;
67 /**
68 * Registers an end span event listener.
69 * @param listener The listener to register.
70 */
71 registerSpanEventListener(listener: types.SpanEventListener): void;
72 /**
73 * Unregisters an end span event listener.
74 * @param listener The listener to unregister.
75 */
76 unregisterSpanEventListener(listener: types.SpanEventListener): void;
77 private notifyStartSpan;
78 private notifyEndSpan;
79 /**
80 * Starts a span.
81 * @param [options] A SpanOptions object to start a child span.
82 */
83 startChildSpan(options?: types.SpanOptions): types.Span;
84 /** Determine whether to sample request or not. */
85 private makeSamplingDecision;
86}