1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.TraceAPI = void 0;
|
19 | const global_utils_1 = require("../internal/global-utils");
|
20 | const ProxyTracerProvider_1 = require("../trace/ProxyTracerProvider");
|
21 | const spancontext_utils_1 = require("../trace/spancontext-utils");
|
22 | const context_utils_1 = require("../trace/context-utils");
|
23 | const diag_1 = require("./diag");
|
24 | const API_NAME = 'trace';
|
25 |
|
26 |
|
27 |
|
28 | class TraceAPI {
|
29 |
|
30 | constructor() {
|
31 | this._proxyTracerProvider = new ProxyTracerProvider_1.ProxyTracerProvider();
|
32 | this.wrapSpanContext = spancontext_utils_1.wrapSpanContext;
|
33 | this.isSpanContextValid = spancontext_utils_1.isSpanContextValid;
|
34 | this.deleteSpan = context_utils_1.deleteSpan;
|
35 | this.getSpan = context_utils_1.getSpan;
|
36 | this.getActiveSpan = context_utils_1.getActiveSpan;
|
37 | this.getSpanContext = context_utils_1.getSpanContext;
|
38 | this.setSpan = context_utils_1.setSpan;
|
39 | this.setSpanContext = context_utils_1.setSpanContext;
|
40 | }
|
41 |
|
42 | static getInstance() {
|
43 | if (!this._instance) {
|
44 | this._instance = new TraceAPI();
|
45 | }
|
46 | return this._instance;
|
47 | }
|
48 | |
49 |
|
50 |
|
51 |
|
52 |
|
53 | setGlobalTracerProvider(provider) {
|
54 | const success = (0, global_utils_1.registerGlobal)(API_NAME, this._proxyTracerProvider, diag_1.DiagAPI.instance());
|
55 | if (success) {
|
56 | this._proxyTracerProvider.setDelegate(provider);
|
57 | }
|
58 | return success;
|
59 | }
|
60 | |
61 |
|
62 |
|
63 | getTracerProvider() {
|
64 | return (0, global_utils_1.getGlobal)(API_NAME) || this._proxyTracerProvider;
|
65 | }
|
66 | |
67 |
|
68 |
|
69 | getTracer(name, version) {
|
70 | return this.getTracerProvider().getTracer(name, version);
|
71 | }
|
72 |
|
73 | disable() {
|
74 | (0, global_utils_1.unregisterGlobal)(API_NAME, diag_1.DiagAPI.instance());
|
75 | this._proxyTracerProvider = new ProxyTracerProvider_1.ProxyTracerProvider();
|
76 | }
|
77 | }
|
78 | exports.TraceAPI = TraceAPI;
|
79 |
|
\ | No newline at end of file |