/** * Copyright 2019, OpenCensus Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import * as webTypes from '@opencensus/web-types'; import { Span } from './span'; import { TracerBase } from './tracer-base'; /** Tracer manages the current root span and trace header propagation. */ export declare class Tracer extends TracerBase implements webTypes.Tracer { private static singletonInstance; /** Gets the tracer instance. */ static readonly instance: Tracer; private currentRootSpanNoZone; /** * Gets the current root span associated to Zone.current. * If the current zone does not have a root span (e.g. root zone) or * `Zone` is not present return the value store in the unique root span. */ /** * Sets the current root span to the current Zone. * If the current zone does not have a 'data' property (e.g. root zone) * or `Zone` is not present, just assign the root span to a variable. */ currentRootSpan: Span; /** * Creates a new Zone (in case `Zone` global variable is present) and start * a new RootSpan to `currentRootSpan` associating the new RootSpan to the * new Zone. Thus, there might be several root spans at the same time. * If `Zone` is not present, just create the root span and store it in the current * root span. * Currently no sampling decisions are propagated or made here. * @param options Options for tracer instance * @param fn Callback function * @returns The callback return */ startRootSpan(options: webTypes.TraceOptions, fn: (root: Span) => T): T; /** Clears the current root span. */ clearCurrentTrace(): void; /** * Start a new Span instance to the currentRootSpan * @param name Span name or SpanOptions object. * @param kind Span kind * @returns The new Span instance started */ startChildSpan(options?: webTypes.SpanOptions): Span; /** * Binds the trace context to the given function - but because opencensus-web * currently only supports a single trace context at a time, this just returns * the function. */ wrap(fn: webTypes.Func): webTypes.Func; /** Binds trace context to NodeJS event emitter. No-op for opencensus-web. */ wrapEmitter(emitter: webTypes.NodeJsEventEmitter): void; isZonePresent(): boolean; }