UNPKG

2.09 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright The OpenTelemetry Authors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.ProxyTracerProvider = void 0;
19const ProxyTracer_1 = require("./ProxyTracer");
20const NoopTracerProvider_1 = require("./NoopTracerProvider");
21const NOOP_TRACER_PROVIDER = new NoopTracerProvider_1.NoopTracerProvider();
22/**
23 * Tracer provider which provides {@link ProxyTracer}s.
24 *
25 * Before a delegate is set, tracers provided are NoOp.
26 * When a delegate is set, traces are provided from the delegate.
27 * When a delegate is set after tracers have already been provided,
28 * all tracers already provided will use the provided delegate implementation.
29 */
30class ProxyTracerProvider {
31 /**
32 * Get a {@link ProxyTracer}
33 */
34 getTracer(name, version, options) {
35 var _a;
36 return ((_a = this.getDelegateTracer(name, version, options)) !== null && _a !== void 0 ? _a : new ProxyTracer_1.ProxyTracer(this, name, version, options));
37 }
38 getDelegate() {
39 var _a;
40 return (_a = this._delegate) !== null && _a !== void 0 ? _a : NOOP_TRACER_PROVIDER;
41 }
42 /**
43 * Set the delegate tracer provider
44 */
45 setDelegate(delegate) {
46 this._delegate = delegate;
47 }
48 getDelegateTracer(name, version, options) {
49 var _a;
50 return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version, options);
51 }
52}
53exports.ProxyTracerProvider = ProxyTracerProvider;
54//# sourceMappingURL=ProxyTracerProvider.js.map
\No newline at end of file