UNPKG

2.08 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.ProxyTracer = void 0;
19var NoopTracer_1 = require("./NoopTracer");
20var NOOP_TRACER = new NoopTracer_1.NoopTracer();
21/**
22 * Proxy tracer provided by the proxy tracer provider
23 */
24var ProxyTracer = /** @class */ (function () {
25 function ProxyTracer(_provider, name, version, options) {
26 this._provider = _provider;
27 this.name = name;
28 this.version = version;
29 this.options = options;
30 }
31 ProxyTracer.prototype.startSpan = function (name, options, context) {
32 return this._getTracer().startSpan(name, options, context);
33 };
34 ProxyTracer.prototype.startActiveSpan = function (_name, _options, _context, _fn) {
35 var tracer = this._getTracer();
36 return Reflect.apply(tracer.startActiveSpan, tracer, arguments);
37 };
38 /**
39 * Try to get a tracer from the proxy tracer provider.
40 * If the proxy tracer provider has no delegate, return a noop tracer.
41 */
42 ProxyTracer.prototype._getTracer = function () {
43 if (this._delegate) {
44 return this._delegate;
45 }
46 var tracer = this._provider.getDelegateTracer(this.name, this.version, this.options);
47 if (!tracer) {
48 return NOOP_TRACER;
49 }
50 this._delegate = tracer;
51 return this._delegate;
52 };
53 return ProxyTracer;
54}());
55exports.ProxyTracer = ProxyTracer;
56//# sourceMappingURL=ProxyTracer.js.map
\No newline at end of file