@opentelemetry/api 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/build/esm/api/context.js +25 -5
- package/build/esm/api/context.js.map +1 -1
- package/build/esm/api/diag.d.ts +3 -11
- package/build/esm/api/diag.js +38 -7
- package/build/esm/api/diag.js.map +1 -1
- package/build/esm/api/metrics.d.ts +28 -0
- package/build/esm/api/metrics.js +60 -0
- package/build/esm/api/metrics.js.map +1 -0
- package/build/esm/baggage/internal/baggage-impl.js +41 -4
- package/build/esm/baggage/internal/baggage-impl.js.map +1 -1
- package/build/esm/context/NoopContextManager.js +25 -5
- package/build/esm/context/NoopContextManager.js.map +1 -1
- package/build/esm/context-api.d.ts +4 -0
- package/build/esm/context-api.js +21 -0
- package/build/esm/context-api.js.map +1 -0
- package/build/esm/diag/ComponentLogger.js +26 -1
- package/build/esm/diag/ComponentLogger.js.map +1 -1
- package/build/esm/diag/types.d.ts +30 -0
- package/build/esm/diag/types.js.map +1 -1
- package/build/esm/diag-api.d.ts +9 -0
- package/build/esm/diag-api.js +26 -0
- package/build/esm/diag-api.js.map +1 -0
- package/build/esm/index.d.ts +44 -48
- package/build/esm/index.js +29 -43
- package/build/esm/index.js.map +1 -1
- package/build/esm/internal/global-utils.d.ts +3 -1
- package/build/esm/internal/global-utils.js.map +1 -1
- package/build/esm/metrics/Meter.d.ts +104 -0
- package/build/esm/{diag/index.js → metrics/Meter.js} +2 -3
- package/build/esm/metrics/Meter.js.map +1 -0
- package/build/esm/metrics/MeterProvider.d.ts +17 -0
- package/build/esm/metrics/MeterProvider.js +17 -0
- package/build/esm/metrics/MeterProvider.js.map +1 -0
- package/build/esm/metrics/Metric.d.ts +97 -0
- package/build/esm/metrics/Metric.js +22 -0
- package/build/esm/metrics/Metric.js.map +1 -0
- package/build/esm/metrics/NoopMeter.d.ts +74 -0
- package/build/esm/metrics/NoopMeter.js +165 -0
- package/build/esm/metrics/NoopMeter.js.map +1 -0
- package/build/esm/metrics/NoopMeterProvider.d.ts +11 -0
- package/build/esm/metrics/NoopMeterProvider.js +31 -0
- package/build/esm/metrics/NoopMeterProvider.js.map +1 -0
- package/build/esm/metrics/ObservableResult.d.ts +31 -0
- package/build/esm/metrics/ObservableResult.js +17 -0
- package/build/esm/metrics/ObservableResult.js.map +1 -0
- package/build/esm/metrics-api.d.ts +4 -0
- package/build/esm/metrics-api.js +21 -0
- package/build/esm/metrics-api.js.map +1 -0
- package/build/esm/platform/browser/globalThis.js +1 -2
- package/build/esm/platform/browser/globalThis.js.map +1 -1
- package/build/esm/propagation-api.d.ts +4 -0
- package/build/esm/propagation-api.js +21 -0
- package/build/esm/propagation-api.js.map +1 -0
- package/build/esm/trace/NoopTracer.js +3 -3
- package/build/esm/trace/NoopTracer.js.map +1 -1
- package/build/esm/trace-api.d.ts +4 -0
- package/build/esm/trace-api.js +21 -0
- package/build/esm/trace-api.js.map +1 -0
- package/build/esm/version.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/src/api/context.js +26 -38
- package/build/src/api/context.js.map +1 -1
- package/build/src/api/diag.d.ts +3 -11
- package/build/src/api/diag.js +33 -33
- package/build/src/api/diag.js.map +1 -1
- package/build/src/api/metrics.d.ts +28 -0
- package/build/src/api/metrics.js +61 -0
- package/build/src/api/metrics.js.map +1 -0
- package/build/src/api/propagation.js +28 -31
- package/build/src/api/propagation.js.map +1 -1
- package/build/src/api/trace.js +22 -23
- package/build/src/api/trace.js.map +1 -1
- package/build/src/baggage/context-helpers.js +2 -2
- package/build/src/baggage/context-helpers.js.map +1 -1
- package/build/src/baggage/internal/baggage-impl.js +21 -30
- package/build/src/baggage/internal/baggage-impl.js.map +1 -1
- package/build/src/baggage/utils.js +7 -8
- package/build/src/baggage/utils.js.map +1 -1
- package/build/src/context/NoopContextManager.js +14 -26
- package/build/src/context/NoopContextManager.js.map +1 -1
- package/build/src/context/context.js +9 -10
- package/build/src/context/context.js.map +1 -1
- package/build/src/context-api.d.ts +4 -0
- package/build/src/{diag/index.js → context-api.js} +7 -13
- package/build/src/context-api.js.map +1 -0
- package/build/src/diag/ComponentLogger.js +16 -37
- package/build/src/diag/ComponentLogger.js.map +1 -1
- package/build/src/diag/consoleLogger.js +7 -12
- package/build/src/diag/consoleLogger.js.map +1 -1
- package/build/src/diag/internal/logLevelLogger.js +2 -2
- package/build/src/diag/internal/logLevelLogger.js.map +1 -1
- package/build/src/diag/types.d.ts +30 -0
- package/build/src/diag/types.js.map +1 -1
- package/build/src/diag-api.d.ts +9 -0
- package/build/src/diag-api.js +29 -0
- package/build/src/diag-api.js.map +1 -0
- package/build/src/index.d.ts +44 -48
- package/build/src/index.js +49 -56
- package/build/src/index.js.map +1 -1
- package/build/src/internal/global-utils.d.ts +3 -1
- package/build/src/internal/global-utils.js +15 -16
- package/build/src/internal/global-utils.js.map +1 -1
- package/build/src/internal/semver.js +9 -9
- package/build/src/internal/semver.js.map +1 -1
- package/build/src/metrics/Meter.d.ts +104 -0
- package/build/src/metrics/Meter.js +18 -0
- package/build/src/metrics/Meter.js.map +1 -0
- package/build/src/metrics/MeterProvider.d.ts +17 -0
- package/build/src/metrics/MeterProvider.js +18 -0
- package/build/src/metrics/MeterProvider.js.map +1 -0
- package/build/src/metrics/Metric.d.ts +97 -0
- package/build/src/metrics/Metric.js +25 -0
- package/build/src/metrics/Metric.js.map +1 -0
- package/build/src/metrics/NoopMeter.d.ts +74 -0
- package/build/src/metrics/NoopMeter.js +116 -0
- package/build/src/metrics/NoopMeter.js.map +1 -0
- package/build/src/metrics/NoopMeterProvider.d.ts +11 -0
- package/build/src/metrics/NoopMeterProvider.js +31 -0
- package/build/src/metrics/NoopMeterProvider.js.map +1 -0
- package/build/src/metrics/ObservableResult.d.ts +31 -0
- package/build/src/metrics/ObservableResult.js +18 -0
- package/build/src/metrics/ObservableResult.js.map +1 -0
- package/build/src/metrics-api.d.ts +4 -0
- package/build/src/metrics-api.js +24 -0
- package/build/src/metrics-api.js.map +1 -0
- package/build/src/platform/browser/globalThis.js +1 -2
- package/build/src/platform/browser/globalThis.js.map +1 -1
- package/build/src/propagation/NoopTextMapPropagator.js +7 -10
- package/build/src/propagation/NoopTextMapPropagator.js.map +1 -1
- package/build/src/propagation/TextMapPropagator.js +3 -3
- package/build/src/propagation/TextMapPropagator.js.map +1 -1
- package/build/src/propagation-api.d.ts +4 -0
- package/build/src/propagation-api.js +24 -0
- package/build/src/propagation-api.js.map +1 -0
- package/build/src/trace/NonRecordingSpan.js +20 -22
- package/build/src/trace/NonRecordingSpan.js.map +1 -1
- package/build/src/trace/NoopTracer.js +21 -24
- package/build/src/trace/NoopTracer.js.map +1 -1
- package/build/src/trace/NoopTracerProvider.js +5 -8
- package/build/src/trace/NoopTracerProvider.js.map +1 -1
- package/build/src/trace/ProxyTracer.js +13 -14
- package/build/src/trace/ProxyTracer.js.map +1 -1
- package/build/src/trace/ProxyTracerProvider.js +13 -16
- package/build/src/trace/ProxyTracerProvider.js.map +1 -1
- package/build/src/trace/context-utils.js +4 -4
- package/build/src/trace/context-utils.js.map +1 -1
- package/build/src/trace/internal/tracestate-impl.js +33 -35
- package/build/src/trace/internal/tracestate-impl.js.map +1 -1
- package/build/src/trace/internal/tracestate-validators.js +6 -6
- package/build/src/trace/internal/tracestate-validators.js.map +1 -1
- package/build/src/trace/internal/utils.js +1 -1
- package/build/src/trace/internal/utils.js.map +1 -1
- package/build/src/trace/invalid-span-constants.js +1 -1
- package/build/src/trace/invalid-span-constants.js.map +1 -1
- package/build/src/trace/spancontext-utils.js +4 -4
- package/build/src/trace/spancontext-utils.js.map +1 -1
- package/build/src/trace-api.d.ts +4 -0
- package/build/src/trace-api.js +24 -0
- package/build/src/{diag/index.js.map → trace-api.js.map} +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/package.json +34 -34
- package/CHANGELOG.md +0 -212
- package/build/esm/diag/index.d.ts +0 -3
- package/build/esm/diag/index.js.map +0 -1
- package/build/src/diag/index.d.ts +0 -3
package/build/src/api/context.js
CHANGED
|
@@ -14,46 +14,40 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
18
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
19
|
-
to[j] = from[i];
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
18
|
exports.ContextAPI = void 0;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
const NoopContextManager_1 = require("../context/NoopContextManager");
|
|
20
|
+
const global_utils_1 = require("../internal/global-utils");
|
|
21
|
+
const diag_1 = require("./diag");
|
|
22
|
+
const API_NAME = 'context';
|
|
23
|
+
const NOOP_CONTEXT_MANAGER = new NoopContextManager_1.NoopContextManager();
|
|
29
24
|
/**
|
|
30
25
|
* Singleton object which represents the entry point to the OpenTelemetry Context API
|
|
31
26
|
*/
|
|
32
|
-
|
|
27
|
+
class ContextAPI {
|
|
33
28
|
/** Empty private constructor prevents end users from constructing a new instance of the API */
|
|
34
|
-
|
|
35
|
-
}
|
|
29
|
+
constructor() { }
|
|
36
30
|
/** Get the singleton instance of the Context API */
|
|
37
|
-
|
|
31
|
+
static getInstance() {
|
|
38
32
|
if (!this._instance) {
|
|
39
33
|
this._instance = new ContextAPI();
|
|
40
34
|
}
|
|
41
35
|
return this._instance;
|
|
42
|
-
}
|
|
36
|
+
}
|
|
43
37
|
/**
|
|
44
38
|
* Set the current context manager.
|
|
45
39
|
*
|
|
46
40
|
* @returns true if the context manager was successfully registered, else false
|
|
47
41
|
*/
|
|
48
|
-
|
|
49
|
-
return global_utils_1.registerGlobal(API_NAME, contextManager, diag_1.DiagAPI.instance());
|
|
50
|
-
}
|
|
42
|
+
setGlobalContextManager(contextManager) {
|
|
43
|
+
return (0, global_utils_1.registerGlobal)(API_NAME, contextManager, diag_1.DiagAPI.instance());
|
|
44
|
+
}
|
|
51
45
|
/**
|
|
52
46
|
* Get the currently active context
|
|
53
47
|
*/
|
|
54
|
-
|
|
48
|
+
active() {
|
|
55
49
|
return this._getContextManager().active();
|
|
56
|
-
}
|
|
50
|
+
}
|
|
57
51
|
/**
|
|
58
52
|
* Execute a function with an active context
|
|
59
53
|
*
|
|
@@ -62,32 +56,26 @@ var ContextAPI = /** @class */ (function () {
|
|
|
62
56
|
* @param thisArg optional receiver to be used for calling fn
|
|
63
57
|
* @param args optional arguments forwarded to fn
|
|
64
58
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
69
|
-
args[_i - 3] = arguments[_i];
|
|
70
|
-
}
|
|
71
|
-
return (_a = this._getContextManager()).with.apply(_a, __spreadArray([context, fn, thisArg], args));
|
|
72
|
-
};
|
|
59
|
+
with(context, fn, thisArg, ...args) {
|
|
60
|
+
return this._getContextManager().with(context, fn, thisArg, ...args);
|
|
61
|
+
}
|
|
73
62
|
/**
|
|
74
63
|
* Bind a context to a target function or event emitter
|
|
75
64
|
*
|
|
76
65
|
* @param context context to bind to the event emitter or function. Defaults to the currently active context
|
|
77
66
|
* @param target function or event emitter to bind
|
|
78
67
|
*/
|
|
79
|
-
|
|
68
|
+
bind(context, target) {
|
|
80
69
|
return this._getContextManager().bind(context, target);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return global_utils_1.getGlobal(API_NAME) || NOOP_CONTEXT_MANAGER;
|
|
84
|
-
}
|
|
70
|
+
}
|
|
71
|
+
_getContextManager() {
|
|
72
|
+
return (0, global_utils_1.getGlobal)(API_NAME) || NOOP_CONTEXT_MANAGER;
|
|
73
|
+
}
|
|
85
74
|
/** Disable and remove the global context manager */
|
|
86
|
-
|
|
75
|
+
disable() {
|
|
87
76
|
this._getContextManager().disable();
|
|
88
|
-
global_utils_1.unregisterGlobal(API_NAME, diag_1.DiagAPI.instance());
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
}());
|
|
77
|
+
(0, global_utils_1.unregisterGlobal)(API_NAME, diag_1.DiagAPI.instance());
|
|
78
|
+
}
|
|
79
|
+
}
|
|
92
80
|
exports.ContextAPI = ContextAPI;
|
|
93
81
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/api/context.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/api/context.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,sEAAmE;AAEnE,2DAIkC;AAClC,iCAAiC;AAEjC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAC3B,MAAM,oBAAoB,GAAG,IAAI,uCAAkB,EAAE,CAAC;AAEtD;;GAEG;AACH,MAAa,UAAU;IAGrB,+FAA+F;IAC/F,gBAAuB,CAAC;IAExB,oDAAoD;IAC7C,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,IAAI,UAAU,EAAE,CAAC;SACnC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACI,uBAAuB,CAAC,cAA8B;QAC3D,OAAO,IAAA,6BAAc,EAAC,QAAQ,EAAE,cAAc,EAAE,cAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACI,MAAM;QACX,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC,MAAM,EAAE,CAAC;IAC5C,CAAC;IAED;;;;;;;OAOG;IACI,IAAI,CACT,OAAgB,EAChB,EAAK,EACL,OAA8B,EAC9B,GAAG,IAAO;QAEV,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACvE,CAAC;IAED;;;;;OAKG;IACI,IAAI,CAAI,OAAgB,EAAE,MAAS;QACxC,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;IAEO,kBAAkB;QACxB,OAAO,IAAA,wBAAS,EAAC,QAAQ,CAAC,IAAI,oBAAoB,CAAC;IACrD,CAAC;IAED,oDAAoD;IAC7C,OAAO;QACZ,IAAI,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,CAAC;QACpC,IAAA,+BAAgB,EAAC,QAAQ,EAAE,cAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;CACF;AAnED,gCAmEC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { NoopContextManager } from '../context/NoopContextManager';\nimport { Context, ContextManager } from '../context/types';\nimport {\n getGlobal,\n registerGlobal,\n unregisterGlobal,\n} from '../internal/global-utils';\nimport { DiagAPI } from './diag';\n\nconst API_NAME = 'context';\nconst NOOP_CONTEXT_MANAGER = new NoopContextManager();\n\n/**\n * Singleton object which represents the entry point to the OpenTelemetry Context API\n */\nexport class ContextAPI {\n private static _instance?: ContextAPI;\n\n /** Empty private constructor prevents end users from constructing a new instance of the API */\n private constructor() {}\n\n /** Get the singleton instance of the Context API */\n public static getInstance(): ContextAPI {\n if (!this._instance) {\n this._instance = new ContextAPI();\n }\n\n return this._instance;\n }\n\n /**\n * Set the current context manager.\n *\n * @returns true if the context manager was successfully registered, else false\n */\n public setGlobalContextManager(contextManager: ContextManager): boolean {\n return registerGlobal(API_NAME, contextManager, DiagAPI.instance());\n }\n\n /**\n * Get the currently active context\n */\n public active(): Context {\n return this._getContextManager().active();\n }\n\n /**\n * Execute a function with an active context\n *\n * @param context context to be active during function execution\n * @param fn function to execute in a context\n * @param thisArg optional receiver to be used for calling fn\n * @param args optional arguments forwarded to fn\n */\n public with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(\n context: Context,\n fn: F,\n thisArg?: ThisParameterType<F>,\n ...args: A\n ): ReturnType<F> {\n return this._getContextManager().with(context, fn, thisArg, ...args);\n }\n\n /**\n * Bind a context to a target function or event emitter\n *\n * @param context context to bind to the event emitter or function. Defaults to the currently active context\n * @param target function or event emitter to bind\n */\n public bind<T>(context: Context, target: T): T {\n return this._getContextManager().bind(context, target);\n }\n\n private _getContextManager(): ContextManager {\n return getGlobal(API_NAME) || NOOP_CONTEXT_MANAGER;\n }\n\n /** Disable and remove the global context manager */\n public disable() {\n this._getContextManager().disable();\n unregisterGlobal(API_NAME, DiagAPI.instance());\n }\n}\n"]}
|
package/build/src/api/diag.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ComponentLoggerOptions, DiagLogFunction, DiagLogger,
|
|
1
|
+
import { ComponentLoggerOptions, DiagLogFunction, DiagLogger, DiagLoggerApi } from '../diag/types';
|
|
2
2
|
/**
|
|
3
3
|
* Singleton object which represents the entry point to the OpenTelemetry internal
|
|
4
4
|
* diagnostic API
|
|
5
5
|
*/
|
|
6
|
-
export declare class DiagAPI implements DiagLogger {
|
|
6
|
+
export declare class DiagAPI implements DiagLogger, DiagLoggerApi {
|
|
7
7
|
private static _instance?;
|
|
8
8
|
/** Get the singleton instance of the DiagAPI API */
|
|
9
9
|
static instance(): DiagAPI;
|
|
@@ -12,15 +12,7 @@ export declare class DiagAPI implements DiagLogger {
|
|
|
12
12
|
* @private
|
|
13
13
|
*/
|
|
14
14
|
private constructor();
|
|
15
|
-
|
|
16
|
-
* Set the global DiagLogger and DiagLogLevel.
|
|
17
|
-
* If a global diag logger is already set, this will override it.
|
|
18
|
-
*
|
|
19
|
-
* @param logger - [Optional] The DiagLogger instance to set as the default logger.
|
|
20
|
-
* @param logLevel - [Optional] The DiagLogLevel used to filter logs sent to the logger. If not provided it will default to INFO.
|
|
21
|
-
* @returns true if the logger was successfully registered, else false
|
|
22
|
-
*/
|
|
23
|
-
setLogger: (logger: DiagLogger, logLevel?: DiagLogLevel) => boolean;
|
|
15
|
+
setLogger: DiagLoggerApi['setLogger'];
|
|
24
16
|
/**
|
|
25
17
|
*
|
|
26
18
|
*/
|
package/build/src/api/diag.js
CHANGED
|
@@ -16,62 +16,63 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.DiagAPI = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const ComponentLogger_1 = require("../diag/ComponentLogger");
|
|
20
|
+
const logLevelLogger_1 = require("../diag/internal/logLevelLogger");
|
|
21
|
+
const types_1 = require("../diag/types");
|
|
22
|
+
const global_utils_1 = require("../internal/global-utils");
|
|
23
|
+
const API_NAME = 'diag';
|
|
24
24
|
/**
|
|
25
25
|
* Singleton object which represents the entry point to the OpenTelemetry internal
|
|
26
26
|
* diagnostic API
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
class DiagAPI {
|
|
29
29
|
/**
|
|
30
30
|
* Private internal constructor
|
|
31
31
|
* @private
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
constructor() {
|
|
34
34
|
function _logProxy(funcName) {
|
|
35
|
-
return function () {
|
|
36
|
-
|
|
37
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
38
|
-
args[_i] = arguments[_i];
|
|
39
|
-
}
|
|
40
|
-
var logger = global_utils_1.getGlobal('diag');
|
|
35
|
+
return function (...args) {
|
|
36
|
+
const logger = (0, global_utils_1.getGlobal)('diag');
|
|
41
37
|
// shortcut if logger not set
|
|
42
38
|
if (!logger)
|
|
43
39
|
return;
|
|
44
|
-
return logger[funcName]
|
|
40
|
+
return logger[funcName](...args);
|
|
45
41
|
};
|
|
46
42
|
}
|
|
47
43
|
// Using self local variable for minification purposes as 'this' cannot be minified
|
|
48
|
-
|
|
44
|
+
const self = this;
|
|
49
45
|
// DiagAPI specific functions
|
|
50
|
-
|
|
51
|
-
var _a, _b;
|
|
52
|
-
if (logLevel === void 0) { logLevel = types_1.DiagLogLevel.INFO; }
|
|
46
|
+
const setLogger = (logger, optionsOrLogLevel = { logLevel: types_1.DiagLogLevel.INFO }) => {
|
|
47
|
+
var _a, _b, _c;
|
|
53
48
|
if (logger === self) {
|
|
54
49
|
// There isn't much we can do here.
|
|
55
50
|
// Logging to the console might break the user application.
|
|
56
51
|
// Try to log to self. If a logger was previously registered it will receive the log.
|
|
57
|
-
|
|
52
|
+
const err = new Error('Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation');
|
|
58
53
|
self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
|
|
59
54
|
return false;
|
|
60
55
|
}
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
if (typeof optionsOrLogLevel === 'number') {
|
|
57
|
+
optionsOrLogLevel = {
|
|
58
|
+
logLevel: optionsOrLogLevel,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const oldLogger = (0, global_utils_1.getGlobal)('diag');
|
|
62
|
+
const newLogger = (0, logLevelLogger_1.createLogLevelDiagLogger)((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : types_1.DiagLogLevel.INFO, logger);
|
|
63
63
|
// There already is an logger registered. We'll let it know before overwriting it.
|
|
64
|
-
if (oldLogger) {
|
|
65
|
-
|
|
66
|
-
oldLogger.warn(
|
|
67
|
-
newLogger.warn(
|
|
64
|
+
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
65
|
+
const stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : '<failed to generate stacktrace>';
|
|
66
|
+
oldLogger.warn(`Current logger will be overwritten from ${stack}`);
|
|
67
|
+
newLogger.warn(`Current logger will overwrite one already registered from ${stack}`);
|
|
68
68
|
}
|
|
69
|
-
return global_utils_1.registerGlobal('diag', newLogger, self, true);
|
|
69
|
+
return (0, global_utils_1.registerGlobal)('diag', newLogger, self, true);
|
|
70
70
|
};
|
|
71
|
-
self.
|
|
72
|
-
|
|
71
|
+
self.setLogger = setLogger;
|
|
72
|
+
self.disable = () => {
|
|
73
|
+
(0, global_utils_1.unregisterGlobal)(API_NAME, self);
|
|
73
74
|
};
|
|
74
|
-
self.createComponentLogger =
|
|
75
|
+
self.createComponentLogger = (options) => {
|
|
75
76
|
return new ComponentLogger_1.DiagComponentLogger(options);
|
|
76
77
|
};
|
|
77
78
|
self.verbose = _logProxy('verbose');
|
|
@@ -81,13 +82,12 @@ var DiagAPI = /** @class */ (function () {
|
|
|
81
82
|
self.error = _logProxy('error');
|
|
82
83
|
}
|
|
83
84
|
/** Get the singleton instance of the DiagAPI API */
|
|
84
|
-
|
|
85
|
+
static instance() {
|
|
85
86
|
if (!this._instance) {
|
|
86
87
|
this._instance = new DiagAPI();
|
|
87
88
|
}
|
|
88
89
|
return this._instance;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
}());
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
92
|
exports.DiagAPI = DiagAPI;
|
|
93
93
|
//# sourceMappingURL=diag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diag.js","sourceRoot":"","sources":["../../../src/api/diag.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"diag.js","sourceR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["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DiagComponentLogger } from '../diag/ComponentLogger';\nimport { createLogLevelDiagLogger } from '../diag/internal/logLevelLogger';\nimport {\n ComponentLoggerOptions,\n DiagLogFunction,\n DiagLogger,\n DiagLoggerApi,\n DiagLogLevel,\n} from '../diag/types';\nimport {\n getGlobal,\n registerGlobal,\n unregisterGlobal,\n} from '../internal/global-utils';\n\nconst API_NAME = 'diag';\n\n/**\n * Singleton object which represents the entry point to the OpenTelemetry internal\n * diagnostic API\n */\nexport class DiagAPI implements DiagLogger, DiagLoggerApi {\n private static _instance?: DiagAPI;\n\n /** Get the singleton instance of the DiagAPI API */\n public static instance(): DiagAPI {\n if (!this._instance) {\n this._instance = new DiagAPI();\n }\n\n return this._instance;\n }\n\n /**\n * Private internal constructor\n * @private\n */\n private constructor() {\n function _logProxy(funcName: keyof DiagLogger): DiagLogFunction {\n return function (...args) {\n const logger = getGlobal('diag');\n // shortcut if logger not set\n if (!logger) return;\n return logger[funcName](...args);\n };\n }\n\n // Using self local variable for minification purposes as 'this' cannot be minified\n const self = this;\n\n // DiagAPI specific functions\n\n const setLogger: DiagLoggerApi['setLogger'] = (\n logger,\n optionsOrLogLevel = { logLevel: DiagLogLevel.INFO },\n ) => {\n if (logger === self) {\n // There isn't much we can do here.\n // Logging to the console might break the user application.\n // Try to log to self. If a logger was previously registered it will receive the log.\n const err = new Error(\n 'Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation'\n );\n self.error(err.stack ?? err.message);\n return false;\n }\n\n if (typeof optionsOrLogLevel === 'number') {\n optionsOrLogLevel = {\n logLevel: optionsOrLogLevel,\n };\n }\n\n const oldLogger = getGlobal('diag');\n const newLogger = createLogLevelDiagLogger(optionsOrLogLevel.logLevel ?? DiagLogLevel.INFO, logger);\n // There already is an logger registered. We'll let it know before overwriting it.\n if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {\n const stack = new Error().stack ?? '<failed to generate stacktrace>';\n oldLogger.warn(`Current logger will be overwritten from ${stack}`);\n newLogger.warn(\n `Current logger will overwrite one already registered from ${stack}`\n );\n }\n\n return registerGlobal('diag', newLogger, self, true);\n };\n\n self.setLogger = setLogger;\n\n self.disable = () => {\n unregisterGlobal(API_NAME, self);\n };\n\n self.createComponentLogger = (options: ComponentLoggerOptions) => {\n return new DiagComponentLogger(options);\n };\n\n self.verbose = _logProxy('verbose');\n self.debug = _logProxy('debug');\n self.info = _logProxy('info');\n self.warn = _logProxy('warn');\n self.error = _logProxy('error');\n }\n\n public setLogger!: DiagLoggerApi['setLogger'];\n /**\n *\n */\n public createComponentLogger!: (\n options: ComponentLoggerOptions\n ) => DiagLogger;\n\n // DiagLogger implementation\n public verbose!: DiagLogFunction;\n public debug!: DiagLogFunction;\n public info!: DiagLogFunction;\n public warn!: DiagLogFunction;\n public error!: DiagLogFunction;\n\n /**\n * Unregister the global logger and return to Noop\n */\n public disable!: () => void;\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Meter, MeterOptions } from '../metrics/Meter';
|
|
2
|
+
import { MeterProvider } from '../metrics/MeterProvider';
|
|
3
|
+
/**
|
|
4
|
+
* Singleton object which represents the entry point to the OpenTelemetry Metrics API
|
|
5
|
+
*/
|
|
6
|
+
export declare class MetricsAPI {
|
|
7
|
+
private static _instance?;
|
|
8
|
+
/** Empty private constructor prevents end users from constructing a new instance of the API */
|
|
9
|
+
private constructor();
|
|
10
|
+
/** Get the singleton instance of the Metrics API */
|
|
11
|
+
static getInstance(): MetricsAPI;
|
|
12
|
+
/**
|
|
13
|
+
* Set the current global meter provider.
|
|
14
|
+
* Returns true if the meter provider was successfully registered, else false.
|
|
15
|
+
*/
|
|
16
|
+
setGlobalMeterProvider(provider: MeterProvider): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the global meter provider.
|
|
19
|
+
*/
|
|
20
|
+
getMeterProvider(): MeterProvider;
|
|
21
|
+
/**
|
|
22
|
+
* Returns a meter from the global meter provider.
|
|
23
|
+
*/
|
|
24
|
+
getMeter(name: string, version?: string, options?: MeterOptions): Meter;
|
|
25
|
+
/** Remove the global meter provider */
|
|
26
|
+
disable(): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.MetricsAPI = void 0;
|
|
19
|
+
const NoopMeterProvider_1 = require("../metrics/NoopMeterProvider");
|
|
20
|
+
const global_utils_1 = require("../internal/global-utils");
|
|
21
|
+
const diag_1 = require("./diag");
|
|
22
|
+
const API_NAME = 'metrics';
|
|
23
|
+
/**
|
|
24
|
+
* Singleton object which represents the entry point to the OpenTelemetry Metrics API
|
|
25
|
+
*/
|
|
26
|
+
class MetricsAPI {
|
|
27
|
+
/** Empty private constructor prevents end users from constructing a new instance of the API */
|
|
28
|
+
constructor() { }
|
|
29
|
+
/** Get the singleton instance of the Metrics API */
|
|
30
|
+
static getInstance() {
|
|
31
|
+
if (!this._instance) {
|
|
32
|
+
this._instance = new MetricsAPI();
|
|
33
|
+
}
|
|
34
|
+
return this._instance;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Set the current global meter provider.
|
|
38
|
+
* Returns true if the meter provider was successfully registered, else false.
|
|
39
|
+
*/
|
|
40
|
+
setGlobalMeterProvider(provider) {
|
|
41
|
+
return (0, global_utils_1.registerGlobal)(API_NAME, provider, diag_1.DiagAPI.instance());
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns the global meter provider.
|
|
45
|
+
*/
|
|
46
|
+
getMeterProvider() {
|
|
47
|
+
return (0, global_utils_1.getGlobal)(API_NAME) || NoopMeterProvider_1.NOOP_METER_PROVIDER;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns a meter from the global meter provider.
|
|
51
|
+
*/
|
|
52
|
+
getMeter(name, version, options) {
|
|
53
|
+
return this.getMeterProvider().getMeter(name, version, options);
|
|
54
|
+
}
|
|
55
|
+
/** Remove the global meter provider */
|
|
56
|
+
disable() {
|
|
57
|
+
(0, global_utils_1.unregisterGlobal)(API_NAME, diag_1.DiagAPI.instance());
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.MetricsAPI = MetricsAPI;
|
|
61
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/api/metrics.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,oEAAmE;AACnE,2DAAuF;AACvF,iCAAiC;AAEjC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAE3B;;GAEG;AACH,MAAa,UAAU;IAGrB,+FAA+F;IAC/F,gBAAuB,CAAC;IAExB,oDAAoD;IAC7C,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,IAAI,UAAU,EAAE,CAAC;SACnC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;OAGG;IACI,sBAAsB,CAAC,QAAuB;QACnD,OAAO,IAAA,6BAAc,EAAC,QAAQ,EAAE,QAAQ,EAAE,cAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACI,gBAAgB;QACrB,OAAO,IAAA,wBAAS,EAAC,QAAQ,CAAC,IAAI,uCAAmB,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,QAAQ,CAAC,IAAY,EAAE,OAAgB,EAAE,OAAsB;QACpE,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IAED,uCAAuC;IAChC,OAAO;QACZ,IAAA,+BAAgB,EAAC,QAAQ,EAAE,cAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;CACF;AAzCD,gCAyCC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Meter, MeterOptions } from '../metrics/Meter';\nimport { MeterProvider } from '../metrics/MeterProvider';\nimport { NOOP_METER_PROVIDER } from '../metrics/NoopMeterProvider';\nimport { getGlobal, registerGlobal, unregisterGlobal } from '../internal/global-utils';\nimport { DiagAPI } from './diag';\n\nconst API_NAME = 'metrics';\n\n/**\n * Singleton object which represents the entry point to the OpenTelemetry Metrics API\n */\nexport class MetricsAPI {\n private static _instance?: MetricsAPI;\n\n /** Empty private constructor prevents end users from constructing a new instance of the API */\n private constructor() {}\n\n /** Get the singleton instance of the Metrics API */\n public static getInstance(): MetricsAPI {\n if (!this._instance) {\n this._instance = new MetricsAPI();\n }\n\n return this._instance;\n }\n\n /**\n * Set the current global meter provider.\n * Returns true if the meter provider was successfully registered, else false.\n */\n public setGlobalMeterProvider(provider: MeterProvider): boolean {\n return registerGlobal(API_NAME, provider, DiagAPI.instance());\n }\n\n /**\n * Returns the global meter provider.\n */\n public getMeterProvider(): MeterProvider {\n return getGlobal(API_NAME) || NOOP_METER_PROVIDER;\n }\n\n /**\n * Returns a meter from the global meter provider.\n */\n public getMeter(name: string, version?: string, options?: MeterOptions): Meter {\n return this.getMeterProvider().getMeter(name, version, options);\n }\n\n /** Remove the global meter provider */\n public disable(): void {\n unregisterGlobal(API_NAME, DiagAPI.instance());\n }\n}\n"]}
|
|
@@ -16,40 +16,40 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.PropagationAPI = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const global_utils_1 = require("../internal/global-utils");
|
|
20
|
+
const NoopTextMapPropagator_1 = require("../propagation/NoopTextMapPropagator");
|
|
21
|
+
const TextMapPropagator_1 = require("../propagation/TextMapPropagator");
|
|
22
|
+
const context_helpers_1 = require("../baggage/context-helpers");
|
|
23
|
+
const utils_1 = require("../baggage/utils");
|
|
24
|
+
const diag_1 = require("./diag");
|
|
25
|
+
const API_NAME = 'propagation';
|
|
26
|
+
const NOOP_TEXT_MAP_PROPAGATOR = new NoopTextMapPropagator_1.NoopTextMapPropagator();
|
|
27
27
|
/**
|
|
28
28
|
* Singleton object which represents the entry point to the OpenTelemetry Propagation API
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
class PropagationAPI {
|
|
31
31
|
/** Empty private constructor prevents end users from constructing a new instance of the API */
|
|
32
|
-
|
|
32
|
+
constructor() {
|
|
33
33
|
this.createBaggage = utils_1.createBaggage;
|
|
34
34
|
this.getBaggage = context_helpers_1.getBaggage;
|
|
35
35
|
this.setBaggage = context_helpers_1.setBaggage;
|
|
36
36
|
this.deleteBaggage = context_helpers_1.deleteBaggage;
|
|
37
37
|
}
|
|
38
38
|
/** Get the singleton instance of the Propagator API */
|
|
39
|
-
|
|
39
|
+
static getInstance() {
|
|
40
40
|
if (!this._instance) {
|
|
41
41
|
this._instance = new PropagationAPI();
|
|
42
42
|
}
|
|
43
43
|
return this._instance;
|
|
44
|
-
}
|
|
44
|
+
}
|
|
45
45
|
/**
|
|
46
46
|
* Set the current propagator.
|
|
47
47
|
*
|
|
48
48
|
* @returns true if the propagator was successfully registered, else false
|
|
49
49
|
*/
|
|
50
|
-
|
|
51
|
-
return global_utils_1.registerGlobal(API_NAME, propagator, diag_1.DiagAPI.instance());
|
|
52
|
-
}
|
|
50
|
+
setGlobalPropagator(propagator) {
|
|
51
|
+
return (0, global_utils_1.registerGlobal)(API_NAME, propagator, diag_1.DiagAPI.instance());
|
|
52
|
+
}
|
|
53
53
|
/**
|
|
54
54
|
* Inject context into a carrier to be propagated inter-process
|
|
55
55
|
*
|
|
@@ -57,10 +57,9 @@ var PropagationAPI = /** @class */ (function () {
|
|
|
57
57
|
* @param carrier carrier to inject context into
|
|
58
58
|
* @param setter Function used to set values on the carrier
|
|
59
59
|
*/
|
|
60
|
-
|
|
61
|
-
if (setter === void 0) { setter = TextMapPropagator_1.defaultTextMapSetter; }
|
|
60
|
+
inject(context, carrier, setter = TextMapPropagator_1.defaultTextMapSetter) {
|
|
62
61
|
return this._getGlobalPropagator().inject(context, carrier, setter);
|
|
63
|
-
}
|
|
62
|
+
}
|
|
64
63
|
/**
|
|
65
64
|
* Extract context from a carrier
|
|
66
65
|
*
|
|
@@ -68,24 +67,22 @@ var PropagationAPI = /** @class */ (function () {
|
|
|
68
67
|
* @param carrier Carrier to extract context from
|
|
69
68
|
* @param getter Function used to extract keys from a carrier
|
|
70
69
|
*/
|
|
71
|
-
|
|
72
|
-
if (getter === void 0) { getter = TextMapPropagator_1.defaultTextMapGetter; }
|
|
70
|
+
extract(context, carrier, getter = TextMapPropagator_1.defaultTextMapGetter) {
|
|
73
71
|
return this._getGlobalPropagator().extract(context, carrier, getter);
|
|
74
|
-
}
|
|
72
|
+
}
|
|
75
73
|
/**
|
|
76
74
|
* Return a list of all fields which may be used by the propagator.
|
|
77
75
|
*/
|
|
78
|
-
|
|
76
|
+
fields() {
|
|
79
77
|
return this._getGlobalPropagator().fields();
|
|
80
|
-
}
|
|
78
|
+
}
|
|
81
79
|
/** Remove the global propagator */
|
|
82
|
-
|
|
83
|
-
global_utils_1.unregisterGlobal(API_NAME, diag_1.DiagAPI.instance());
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return global_utils_1.getGlobal(API_NAME) || NOOP_TEXT_MAP_PROPAGATOR;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
}());
|
|
80
|
+
disable() {
|
|
81
|
+
(0, global_utils_1.unregisterGlobal)(API_NAME, diag_1.DiagAPI.instance());
|
|
82
|
+
}
|
|
83
|
+
_getGlobalPropagator() {
|
|
84
|
+
return (0, global_utils_1.getGlobal)(API_NAME) || NOOP_TEXT_MAP_PROPAGATOR;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
90
87
|
exports.PropagationAPI = PropagationAPI;
|
|
91
88
|
//# sourceMappingURL=propagation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propagation.js","sourceRoot":"","sources":["../../../src/api/propagation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,
|
|
1
|
+
{"version":3,"file":"propagation.js","s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EAAE,CAAC;IAC9C,CAAC;IAED,mCAAmC;IAC5B,OAAO;QACZ,IAAA,+BAAgB,EAAC,QAAQ,EAAE,cAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;IAUO,oBAAoB;QAC1B,OAAO,IAAA,wBAAS,EAAC,QAAQ,CAAC,IAAI,wBAAwB,CAAC;IACzD,CAAC;CACF;AA7ED,wCA6EC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Context } from '../context/types';\nimport {\n getGlobal,\n registerGlobal,\n unregisterGlobal,\n} from '../internal/global-utils';\nimport { NoopTextMapPropagator } from '../propagation/NoopTextMapPropagator';\nimport {\n defaultTextMapGetter,\n defaultTextMapSetter,\n TextMapGetter,\n TextMapPropagator,\n TextMapSetter,\n} from '../propagation/TextMapPropagator';\nimport {\n getBaggage,\n setBaggage,\n deleteBaggage,\n} from '../baggage/context-helpers';\nimport { createBaggage } from '../baggage/utils';\nimport { DiagAPI } from './diag';\n\nconst API_NAME = 'propagation';\nconst NOOP_TEXT_MAP_PROPAGATOR = new NoopTextMapPropagator();\n\n/**\n * Singleton object which represents the entry point to the OpenTelemetry Propagation API\n */\nexport class PropagationAPI {\n private static _instance?: PropagationAPI;\n\n /** Empty private constructor prevents end users from constructing a new instance of the API */\n private constructor() {}\n\n /** Get the singleton instance of the Propagator API */\n public static getInstance(): PropagationAPI {\n if (!this._instance) {\n this._instance = new PropagationAPI();\n }\n\n return this._instance;\n }\n\n /**\n * Set the current propagator.\n *\n * @returns true if the propagator was successfully registered, else false\n */\n public setGlobalPropagator(propagator: TextMapPropagator): boolean {\n return registerGlobal(API_NAME, propagator, DiagAPI.instance());\n }\n\n /**\n * Inject context into a carrier to be propagated inter-process\n *\n * @param context Context carrying tracing data to inject\n * @param carrier carrier to inject context into\n * @param setter Function used to set values on the carrier\n */\n public inject<Carrier>(\n context: Context,\n carrier: Carrier,\n setter: TextMapSetter<Carrier> = defaultTextMapSetter\n ): void {\n return this._getGlobalPropagator().inject(context, carrier, setter);\n }\n\n /**\n * Extract context from a carrier\n *\n * @param context Context which the newly created context will inherit from\n * @param carrier Carrier to extract context from\n * @param getter Function used to extract keys from a carrier\n */\n public extract<Carrier>(\n context: Context,\n carrier: Carrier,\n getter: TextMapGetter<Carrier> = defaultTextMapGetter\n ): Context {\n return this._getGlobalPropagator().extract(context, carrier, getter);\n }\n\n /**\n * Return a list of all fields which may be used by the propagator.\n */\n public fields(): string[] {\n return this._getGlobalPropagator().fields();\n }\n\n /** Remove the global propagator */\n public disable() {\n unregisterGlobal(API_NAME, DiagAPI.instance());\n }\n\n public createBaggage = createBaggage;\n\n public getBaggage = getBaggage;\n\n public setBaggage = setBaggage;\n\n public deleteBaggage = deleteBaggage;\n\n private _getGlobalPropagator(): TextMapPropagator {\n return getGlobal(API_NAME) || NOOP_TEXT_MAP_PROPAGATOR;\n }\n}\n"]}
|
package/build/src/api/trace.js
CHANGED
|
@@ -16,18 +16,18 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.TraceAPI = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
25
|
/**
|
|
26
26
|
* Singleton object which represents the entry point to the OpenTelemetry Tracing API
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
class TraceAPI {
|
|
29
29
|
/** Empty private constructor prevents end users from constructing a new instance of the API */
|
|
30
|
-
|
|
30
|
+
constructor() {
|
|
31
31
|
this._proxyTracerProvider = new ProxyTracerProvider_1.ProxyTracerProvider();
|
|
32
32
|
this.wrapSpanContext = spancontext_utils_1.wrapSpanContext;
|
|
33
33
|
this.isSpanContextValid = spancontext_utils_1.isSpanContextValid;
|
|
@@ -39,42 +39,41 @@ var TraceAPI = /** @class */ (function () {
|
|
|
39
39
|
this.setSpanContext = context_utils_1.setSpanContext;
|
|
40
40
|
}
|
|
41
41
|
/** Get the singleton instance of the Trace API */
|
|
42
|
-
|
|
42
|
+
static getInstance() {
|
|
43
43
|
if (!this._instance) {
|
|
44
44
|
this._instance = new TraceAPI();
|
|
45
45
|
}
|
|
46
46
|
return this._instance;
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
48
|
/**
|
|
49
49
|
* Set the current global tracer.
|
|
50
50
|
*
|
|
51
51
|
* @returns true if the tracer provider was successfully registered, else false
|
|
52
52
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
setGlobalTracerProvider(provider) {
|
|
54
|
+
const success = (0, global_utils_1.registerGlobal)(API_NAME, this._proxyTracerProvider, diag_1.DiagAPI.instance());
|
|
55
55
|
if (success) {
|
|
56
56
|
this._proxyTracerProvider.setDelegate(provider);
|
|
57
57
|
}
|
|
58
58
|
return success;
|
|
59
|
-
}
|
|
59
|
+
}
|
|
60
60
|
/**
|
|
61
61
|
* Returns the global tracer provider.
|
|
62
62
|
*/
|
|
63
|
-
|
|
64
|
-
return global_utils_1.getGlobal(API_NAME) || this._proxyTracerProvider;
|
|
65
|
-
}
|
|
63
|
+
getTracerProvider() {
|
|
64
|
+
return (0, global_utils_1.getGlobal)(API_NAME) || this._proxyTracerProvider;
|
|
65
|
+
}
|
|
66
66
|
/**
|
|
67
67
|
* Returns a tracer from the global tracer provider.
|
|
68
68
|
*/
|
|
69
|
-
|
|
69
|
+
getTracer(name, version) {
|
|
70
70
|
return this.getTracerProvider().getTracer(name, version);
|
|
71
|
-
}
|
|
71
|
+
}
|
|
72
72
|
/** Remove the global tracer provider */
|
|
73
|
-
|
|
74
|
-
global_utils_1.unregisterGlobal(API_NAME, diag_1.DiagAPI.instance());
|
|
73
|
+
disable() {
|
|
74
|
+
(0, global_utils_1.unregisterGlobal)(API_NAME, diag_1.DiagAPI.instance());
|
|
75
75
|
this._proxyTracerProvider = new ProxyTracerProvider_1.ProxyTracerProvider();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
}());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
79
78
|
exports.TraceAPI = TraceAPI;
|
|
80
79
|
//# sourceMappingURL=trace.js.map
|