UNPKG

1.48 kBTypeScriptView Raw
1/**
2 * Copyright 2019, 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 cls from '../internal/cls';
17import { TagMap } from './tag-map';
18export declare const EMPTY_TAG_MAP: TagMap;
19/** Gets the current tag context. */
20export declare function getCurrentTagContext(contextManager: cls.Namespace): TagMap;
21/**
22 * Sets the current tag context.
23 * @param tags The TagMap.
24 */
25export declare function setCurrentTagContext(contextManager: cls.Namespace, tags: TagMap): void;
26/**
27 * Enters the scope of code where the given `TagMap` is in the current context
28 * (replacing the previous `TagMap`).
29 * @param tags The TagMap to be set to the current context.
30 * @param fn Callback function.
31 * @returns The callback return.
32 */
33export declare function withTagContext<T>(contextManager: cls.Namespace, tags: TagMap, fn: cls.Func<T>): T;
34/** Clear the current tag context. */
35export declare function clear(contextManager: cls.Namespace): void;