1 | ;
|
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 | */
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.ProxyTracer = void 0;
|
19 | const NoopTracer_1 = require("./NoopTracer");
|
20 | const NOOP_TRACER = new NoopTracer_1.NoopTracer();
|
21 | /**
|
22 | * Proxy tracer provided by the proxy tracer provider
|
23 | */
|
24 | class ProxyTracer {
|
25 | constructor(_provider, name, version, options) {
|
26 | this._provider = _provider;
|
27 | this.name = name;
|
28 | this.version = version;
|
29 | this.options = options;
|
30 | }
|
31 | startSpan(name, options, context) {
|
32 | return this._getTracer().startSpan(name, options, context);
|
33 | }
|
34 | startActiveSpan(_name, _options, _context, _fn) {
|
35 | const 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 | _getTracer() {
|
43 | if (this._delegate) {
|
44 | return this._delegate;
|
45 | }
|
46 | const 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 | }
|
54 | exports.ProxyTracer = ProxyTracer;
|
55 | //# sourceMappingURL=ProxyTracer.js.map |
\ | No newline at end of file |