@opentelemetry/api 1.1.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/api/trace.d.ts +2 -1
- package/build/esm/api/trace.js +2 -1
- package/build/esm/api/trace.js.map +1 -1
- 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/Sampler.d.ts +1 -0
- package/build/esm/trace/Sampler.js.map +1 -1
- package/build/esm/trace/SamplingResult.d.ts +2 -0
- package/build/esm/trace/SamplingResult.js +1 -0
- package/build/esm/trace/SamplingResult.js.map +1 -1
- package/build/esm/trace/context-utils.d.ts +4 -0
- package/build/esm/trace/context-utils.js +7 -0
- package/build/esm/trace/context-utils.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.d.ts +2 -1
- package/build/src/api/trace.js +23 -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/Sampler.d.ts +1 -0
- package/build/src/trace/Sampler.js.map +1 -1
- package/build/src/trace/SamplingResult.d.ts +2 -0
- package/build/src/trace/SamplingResult.js +1 -0
- package/build/src/trace/SamplingResult.js.map +1 -1
- package/build/src/trace/context-utils.d.ts +4 -0
- package/build/src/trace/context-utils.js +12 -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 -204
- 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
|
@@ -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","sourceRoot":"","sources":["../../../src/api/propagation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,2DAIkC;AAClC,gFAA6E;AAC7E,wEAM0C;AAC1C,gEAIoC;AACpC,4CAAiD;AACjD,iCAAiC;AAEjC,MAAM,QAAQ,GAAG,aAAa,CAAC;AAC/B,MAAM,wBAAwB,GAAG,IAAI,6CAAqB,EAAE,CAAC;AAE7D;;GAEG;AACH,MAAa,cAAc;IAGzB,+FAA+F;IAC/F;QA8DO,kBAAa,GAAG,qBAAa,CAAC;QAE9B,eAAU,GAAG,4BAAU,CAAC;QAExB,eAAU,GAAG,4BAAU,CAAC;QAExB,kBAAa,GAAG,+BAAa,CAAC;IApEd,CAAC;IAExB,uDAAuD;IAChD,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,EAAE,CAAC;SACvC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACI,mBAAmB,CAAC,UAA6B;QACtD,OAAO,IAAA,6BAAc,EAAC,QAAQ,EAAE,UAAU,EAAE,cAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CACX,OAAgB,EAChB,OAAgB,EAChB,SAAiC,wCAAoB;QAErD,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;OAMG;IACI,OAAO,CACZ,OAAgB,EAChB,OAAgB,EAChB,SAAiC,wCAAoB;QAErD,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACI,MAAM;QACX,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC,MAAM,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.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isSpanContextValid, wrapSpanContext } from '../trace/spancontext-utils';
|
|
2
2
|
import { Tracer } from '../trace/tracer';
|
|
3
3
|
import { TracerProvider } from '../trace/tracer_provider';
|
|
4
|
-
import { deleteSpan, getSpan, getSpanContext, setSpan, setSpanContext } from '../trace/context-utils';
|
|
4
|
+
import { deleteSpan, getActiveSpan, getSpan, getSpanContext, setSpan, setSpanContext } from '../trace/context-utils';
|
|
5
5
|
/**
|
|
6
6
|
* Singleton object which represents the entry point to the OpenTelemetry Tracing API
|
|
7
7
|
*/
|
|
@@ -32,6 +32,7 @@ export declare class TraceAPI {
|
|
|
32
32
|
isSpanContextValid: typeof isSpanContextValid;
|
|
33
33
|
deleteSpan: typeof deleteSpan;
|
|
34
34
|
getSpan: typeof getSpan;
|
|
35
|
+
getActiveSpan: typeof getActiveSpan;
|
|
35
36
|
getSpanContext: typeof getSpanContext;
|
|
36
37
|
setSpan: typeof setSpan;
|
|
37
38
|
setSpanContext: typeof setSpanContext;
|
package/build/src/api/trace.js
CHANGED
|
@@ -16,64 +16,64 @@
|
|
|
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;
|
|
34
34
|
this.deleteSpan = context_utils_1.deleteSpan;
|
|
35
35
|
this.getSpan = context_utils_1.getSpan;
|
|
36
|
+
this.getActiveSpan = context_utils_1.getActiveSpan;
|
|
36
37
|
this.getSpanContext = context_utils_1.getSpanContext;
|
|
37
38
|
this.setSpan = context_utils_1.setSpan;
|
|
38
39
|
this.setSpanContext = context_utils_1.setSpanContext;
|
|
39
40
|
}
|
|
40
41
|
/** Get the singleton instance of the Trace API */
|
|
41
|
-
|
|
42
|
+
static getInstance() {
|
|
42
43
|
if (!this._instance) {
|
|
43
44
|
this._instance = new TraceAPI();
|
|
44
45
|
}
|
|
45
46
|
return this._instance;
|
|
46
|
-
}
|
|
47
|
+
}
|
|
47
48
|
/**
|
|
48
49
|
* Set the current global tracer.
|
|
49
50
|
*
|
|
50
51
|
* @returns true if the tracer provider was successfully registered, else false
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
setGlobalTracerProvider(provider) {
|
|
54
|
+
const success = (0, global_utils_1.registerGlobal)(API_NAME, this._proxyTracerProvider, diag_1.DiagAPI.instance());
|
|
54
55
|
if (success) {
|
|
55
56
|
this._proxyTracerProvider.setDelegate(provider);
|
|
56
57
|
}
|
|
57
58
|
return success;
|
|
58
|
-
}
|
|
59
|
+
}
|
|
59
60
|
/**
|
|
60
61
|
* Returns the global tracer provider.
|
|
61
62
|
*/
|
|
62
|
-
|
|
63
|
-
return global_utils_1.getGlobal(API_NAME) || this._proxyTracerProvider;
|
|
64
|
-
}
|
|
63
|
+
getTracerProvider() {
|
|
64
|
+
return (0, global_utils_1.getGlobal)(API_NAME) || this._proxyTracerProvider;
|
|
65
|
+
}
|
|
65
66
|
/**
|
|
66
67
|
* Returns a tracer from the global tracer provider.
|
|
67
68
|
*/
|
|
68
|
-
|
|
69
|
+
getTracer(name, version) {
|
|
69
70
|
return this.getTracerProvider().getTracer(name, version);
|
|
70
|
-
}
|
|
71
|
+
}
|
|
71
72
|
/** Remove the global tracer provider */
|
|
72
|
-
|
|
73
|
-
global_utils_1.unregisterGlobal(API_NAME, diag_1.DiagAPI.instance());
|
|
73
|
+
disable() {
|
|
74
|
+
(0, global_utils_1.unregisterGlobal)(API_NAME, diag_1.DiagAPI.instance());
|
|
74
75
|
this._proxyTracerProvider = new ProxyTracerProvider_1.ProxyTracerProvider();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
}());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
78
|
exports.TraceAPI = TraceAPI;
|
|
79
79
|
//# sourceMappingURL=trace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../src/api/trace.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../src/api/trace.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,2DAIkC;AAClC,sEAAmE;AACnE,kEAGoC;AAGpC,0DAOgC;AAChC,iCAAiC;AAEjC,MAAM,QAAQ,GAAG,OAAO,CAAC;AAEzB;;GAEG;AACH,MAAa,QAAQ;IAKnB,+FAA+F;IAC/F;QAHQ,yBAAoB,GAAG,IAAI,yCAAmB,EAAE,CAAC;QAmDlD,oBAAe,GAAG,mCAAe,CAAC;QAElC,uBAAkB,GAAG,sCAAkB,CAAC;QAExC,eAAU,GAAG,0BAAU,CAAC;QAExB,YAAO,GAAG,uBAAO,CAAC;QAElB,kBAAa,GAAG,6BAAa,CAAC;QAE9B,mBAAc,GAAG,8BAAc,CAAC;QAEhC,YAAO,GAAG,uBAAO,CAAC;QAElB,mBAAc,GAAG,8BAAc,CAAC;IA9DhB,CAAC;IAExB,kDAAkD;IAC3C,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SACjC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACI,uBAAuB,CAAC,QAAwB;QACrD,MAAM,OAAO,GAAG,IAAA,6BAAc,EAC5B,QAAQ,EACR,IAAI,CAAC,oBAAoB,EACzB,cAAO,CAAC,QAAQ,EAAE,CACnB,CAAC;QACF,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;SACjD;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,iBAAiB;QACtB,OAAO,IAAA,wBAAS,EAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,oBAAoB,CAAC;IAC1D,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,IAAY,EAAE,OAAgB;QAC7C,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED,wCAAwC;IACjC,OAAO;QACZ,IAAA,+BAAgB,EAAC,QAAQ,EAAE,cAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,oBAAoB,GAAG,IAAI,yCAAmB,EAAE,CAAC;IACxD,CAAC;CAiBF;AArED,4BAqEC","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 {\n getGlobal,\n registerGlobal,\n unregisterGlobal,\n} from '../internal/global-utils';\nimport { ProxyTracerProvider } from '../trace/ProxyTracerProvider';\nimport {\n isSpanContextValid,\n wrapSpanContext,\n} from '../trace/spancontext-utils';\nimport { Tracer } from '../trace/tracer';\nimport { TracerProvider } from '../trace/tracer_provider';\nimport {\n deleteSpan,\n getActiveSpan,\n getSpan,\n getSpanContext,\n setSpan,\n setSpanContext,\n} from '../trace/context-utils';\nimport { DiagAPI } from './diag';\n\nconst API_NAME = 'trace';\n\n/**\n * Singleton object which represents the entry point to the OpenTelemetry Tracing API\n */\nexport class TraceAPI {\n private static _instance?: TraceAPI;\n\n private _proxyTracerProvider = new ProxyTracerProvider();\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 Trace API */\n public static getInstance(): TraceAPI {\n if (!this._instance) {\n this._instance = new TraceAPI();\n }\n\n return this._instance;\n }\n\n /**\n * Set the current global tracer.\n *\n * @returns true if the tracer provider was successfully registered, else false\n */\n public setGlobalTracerProvider(provider: TracerProvider): boolean {\n const success = registerGlobal(\n API_NAME,\n this._proxyTracerProvider,\n DiagAPI.instance()\n );\n if (success) {\n this._proxyTracerProvider.setDelegate(provider);\n }\n return success;\n }\n\n /**\n * Returns the global tracer provider.\n */\n public getTracerProvider(): TracerProvider {\n return getGlobal(API_NAME) || this._proxyTracerProvider;\n }\n\n /**\n * Returns a tracer from the global tracer provider.\n */\n public getTracer(name: string, version?: string): Tracer {\n return this.getTracerProvider().getTracer(name, version);\n }\n\n /** Remove the global tracer provider */\n public disable() {\n unregisterGlobal(API_NAME, DiagAPI.instance());\n this._proxyTracerProvider = new ProxyTracerProvider();\n }\n\n public wrapSpanContext = wrapSpanContext;\n\n public isSpanContextValid = isSpanContextValid;\n\n public deleteSpan = deleteSpan;\n\n public getSpan = getSpan;\n\n public getActiveSpan = getActiveSpan;\n\n public getSpanContext = getSpanContext;\n\n public setSpan = setSpan;\n\n public setSpanContext = setSpanContext;\n}\n"]}
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.deleteBaggage = exports.setBaggage = exports.getBaggage = void 0;
|
|
19
|
-
|
|
19
|
+
const context_1 = require("../context/context");
|
|
20
20
|
/**
|
|
21
21
|
* Baggage key
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
const BAGGAGE_KEY = (0, context_1.createContextKey)('OpenTelemetry Baggage Key');
|
|
24
24
|
/**
|
|
25
25
|
* Retrieve the current baggage from the given context
|
|
26
26
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-helpers.js","sourceRoot":"","sources":["../../../src/baggage/context-helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"context-helpers.js","sourceRoot":"","sources":["../../../src/baggage/context-helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,gDAAsD;AAItD;;GAEG;AACH,MAAM,WAAW,GAAG,IAAA,0BAAgB,EAAC,2BAA2B,CAAC,CAAC;AAElE;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,OAAgB;IACzC,OAAQ,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa,IAAI,SAAS,CAAC;AACjE,CAAC;AAFD,gCAEC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,OAAgB,EAAE,OAAgB;IAC3D,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAFD,gCAEC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,OAAgB;IAC5C,OAAO,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;AAC1C,CAAC;AAFD,sCAEC","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 { createContextKey } from '../context/context';\nimport { Context } from '../context/types';\nimport { Baggage } from './types';\n\n/**\n * Baggage key\n */\nconst BAGGAGE_KEY = createContextKey('OpenTelemetry Baggage Key');\n\n/**\n * Retrieve the current baggage from the given context\n *\n * @param {Context} Context that manage all context values\n * @returns {Baggage} Extracted baggage from the context\n */\nexport function getBaggage(context: Context): Baggage | undefined {\n return (context.getValue(BAGGAGE_KEY) as Baggage) || undefined;\n}\n\n/**\n * Store a baggage in the given context\n *\n * @param {Context} Context that manage all context values\n * @param {Baggage} baggage that will be set in the actual context\n */\nexport function setBaggage(context: Context, baggage: Baggage): Context {\n return context.setValue(BAGGAGE_KEY, baggage);\n}\n\n/**\n * Delete the baggage stored in the given context\n *\n * @param {Context} Context that manage all context values\n */\nexport function deleteBaggage(context: Context): Context {\n return context.deleteValue(BAGGAGE_KEY);\n}\n"]}
|
|
@@ -16,49 +16,40 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.BaggageImpl = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
class BaggageImpl {
|
|
20
|
+
constructor(entries) {
|
|
21
21
|
this._entries = entries ? new Map(entries) : new Map();
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
getEntry(key) {
|
|
24
|
+
const entry = this._entries.get(key);
|
|
25
25
|
if (!entry) {
|
|
26
26
|
return undefined;
|
|
27
27
|
}
|
|
28
28
|
return Object.assign({}, entry);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return Array.from(this._entries.entries()).map(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
BaggageImpl.prototype.setEntry = function (key, entry) {
|
|
37
|
-
var newBaggage = new BaggageImpl(this._entries);
|
|
29
|
+
}
|
|
30
|
+
getAllEntries() {
|
|
31
|
+
return Array.from(this._entries.entries()).map(([k, v]) => [k, v]);
|
|
32
|
+
}
|
|
33
|
+
setEntry(key, entry) {
|
|
34
|
+
const newBaggage = new BaggageImpl(this._entries);
|
|
38
35
|
newBaggage._entries.set(key, entry);
|
|
39
36
|
return newBaggage;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
}
|
|
38
|
+
removeEntry(key) {
|
|
39
|
+
const newBaggage = new BaggageImpl(this._entries);
|
|
43
40
|
newBaggage._entries.delete(key);
|
|
44
41
|
return newBaggage;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
for (
|
|
49
|
-
keys[_i] = arguments[_i];
|
|
50
|
-
}
|
|
51
|
-
var newBaggage = new BaggageImpl(this._entries);
|
|
52
|
-
for (var _a = 0, keys_1 = keys; _a < keys_1.length; _a++) {
|
|
53
|
-
var key = keys_1[_a];
|
|
42
|
+
}
|
|
43
|
+
removeEntries(...keys) {
|
|
44
|
+
const newBaggage = new BaggageImpl(this._entries);
|
|
45
|
+
for (const key of keys) {
|
|
54
46
|
newBaggage._entries.delete(key);
|
|
55
47
|
}
|
|
56
48
|
return newBaggage;
|
|
57
|
-
}
|
|
58
|
-
|
|
49
|
+
}
|
|
50
|
+
clear() {
|
|
59
51
|
return new BaggageImpl();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
}());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
63
54
|
exports.BaggageImpl = BaggageImpl;
|
|
64
55
|
//# sourceMappingURL=baggage-impl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baggage-impl.js","sourceRoot":"","sources":["../../../../src/baggage/internal/baggage-impl.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH;
|
|
1
|
+
{"version":3,"file":"baggage-impl.js","sourceRoot":"","sources":["../../../../src/baggage/internal/baggage-impl.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,MAAa,WAAW;IAGtB,YAAY,OAAmC;QAC7C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;IACzD,CAAC;IAED,QAAQ,CAAC,GAAW;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,aAAa;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,QAAQ,CAAC,GAAW,EAAE,KAAmB;QACvC,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClD,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACpC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,WAAW,CAAC,GAAW;QACrB,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClD,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,aAAa,CAAC,GAAG,IAAc;QAC7B,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SACjC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,KAAK;QACH,OAAO,IAAI,WAAW,EAAE,CAAC;IAC3B,CAAC;CACF;AA3CD,kCA2CC","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 type { Baggage, BaggageEntry } from '../types';\n\nexport class BaggageImpl implements Baggage {\n private _entries: Map<string, BaggageEntry>;\n\n constructor(entries?: Map<string, BaggageEntry>) {\n this._entries = entries ? new Map(entries) : new Map();\n }\n\n getEntry(key: string): BaggageEntry | undefined {\n const entry = this._entries.get(key);\n if (!entry) {\n return undefined;\n }\n\n return Object.assign({}, entry);\n }\n\n getAllEntries(): [string, BaggageEntry][] {\n return Array.from(this._entries.entries()).map(([k, v]) => [k, v]);\n }\n\n setEntry(key: string, entry: BaggageEntry): BaggageImpl {\n const newBaggage = new BaggageImpl(this._entries);\n newBaggage._entries.set(key, entry);\n return newBaggage;\n }\n\n removeEntry(key: string): BaggageImpl {\n const newBaggage = new BaggageImpl(this._entries);\n newBaggage._entries.delete(key);\n return newBaggage;\n }\n\n removeEntries(...keys: string[]): BaggageImpl {\n const newBaggage = new BaggageImpl(this._entries);\n for (const key of keys) {\n newBaggage._entries.delete(key);\n }\n return newBaggage;\n }\n\n clear(): BaggageImpl {\n return new BaggageImpl();\n }\n}\n"]}
|
|
@@ -16,17 +16,16 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.baggageEntryMetadataFromString = exports.createBaggage = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const diag_1 = require("../api/diag");
|
|
20
|
+
const baggage_impl_1 = require("./internal/baggage-impl");
|
|
21
|
+
const symbol_1 = require("./internal/symbol");
|
|
22
|
+
const diag = diag_1.DiagAPI.instance();
|
|
23
23
|
/**
|
|
24
24
|
* Create a new Baggage with optional entries
|
|
25
25
|
*
|
|
26
26
|
* @param entries An array of baggage entries the new baggage should contain
|
|
27
27
|
*/
|
|
28
|
-
function createBaggage(entries) {
|
|
29
|
-
if (entries === void 0) { entries = {}; }
|
|
28
|
+
function createBaggage(entries = {}) {
|
|
30
29
|
return new baggage_impl_1.BaggageImpl(new Map(Object.entries(entries)));
|
|
31
30
|
}
|
|
32
31
|
exports.createBaggage = createBaggage;
|
|
@@ -38,12 +37,12 @@ exports.createBaggage = createBaggage;
|
|
|
38
37
|
*/
|
|
39
38
|
function baggageEntryMetadataFromString(str) {
|
|
40
39
|
if (typeof str !== 'string') {
|
|
41
|
-
diag.error(
|
|
40
|
+
diag.error(`Cannot create baggage metadata from unknown type: ${typeof str}`);
|
|
42
41
|
str = '';
|
|
43
42
|
}
|
|
44
43
|
return {
|
|
45
44
|
__TYPE__: symbol_1.baggageEntryMetadataSymbol,
|
|
46
|
-
toString
|
|
45
|
+
toString() {
|
|
47
46
|
return str;
|
|
48
47
|
},
|
|
49
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/baggage/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/baggage/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,sCAAsC;AACtC,0DAAsD;AACtD,8CAA+D;AAG/D,MAAM,IAAI,GAAG,cAAO,CAAC,QAAQ,EAAE,CAAC;AAEhC;;;;GAIG;AACH,SAAgB,aAAa,CAC3B,UAAwC,EAAE;IAE1C,OAAO,IAAI,0BAAW,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAJD,sCAIC;AAED;;;;;GAKG;AACH,SAAgB,8BAA8B,CAC5C,GAAW;IAEX,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,IAAI,CAAC,KAAK,CACR,qDAAqD,OAAO,GAAG,EAAE,CAClE,CAAC;QACF,GAAG,GAAG,EAAE,CAAC;KACV;IAED,OAAO;QACL,QAAQ,EAAE,mCAA0B;QACpC,QAAQ;YACN,OAAO,GAAG,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC;AAhBD,wEAgBC","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 { DiagAPI } from '../api/diag';\nimport { BaggageImpl } from './internal/baggage-impl';\nimport { baggageEntryMetadataSymbol } from './internal/symbol';\nimport { Baggage, BaggageEntry, BaggageEntryMetadata } from './types';\n\nconst diag = DiagAPI.instance();\n\n/**\n * Create a new Baggage with optional entries\n *\n * @param entries An array of baggage entries the new baggage should contain\n */\nexport function createBaggage(\n entries: Record<string, BaggageEntry> = {}\n): Baggage {\n return new BaggageImpl(new Map(Object.entries(entries)));\n}\n\n/**\n * Create a serializable BaggageEntryMetadata object from a string.\n *\n * @param str string metadata. Format is currently not defined by the spec and has no special meaning.\n *\n */\nexport function baggageEntryMetadataFromString(\n str: string\n): BaggageEntryMetadata {\n if (typeof str !== 'string') {\n diag.error(\n `Cannot create baggage metadata from unknown type: ${typeof str}`\n );\n str = '';\n }\n\n return {\n __TYPE__: baggageEntryMetadataSymbol,\n toString() {\n return str;\n },\n };\n}\n"]}
|
|
@@ -14,37 +14,25 @@
|
|
|
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.NoopContextManager = void 0;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
NoopContextManager.prototype.active = function () {
|
|
19
|
+
const context_1 = require("./context");
|
|
20
|
+
class NoopContextManager {
|
|
21
|
+
active() {
|
|
29
22
|
return context_1.ROOT_CONTEXT;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
return fn.call.apply(fn, __spreadArray([thisArg], args));
|
|
37
|
-
};
|
|
38
|
-
NoopContextManager.prototype.bind = function (_context, target) {
|
|
23
|
+
}
|
|
24
|
+
with(_context, fn, thisArg, ...args) {
|
|
25
|
+
return fn.call(thisArg, ...args);
|
|
26
|
+
}
|
|
27
|
+
bind(_context, target) {
|
|
39
28
|
return target;
|
|
40
|
-
}
|
|
41
|
-
|
|
29
|
+
}
|
|
30
|
+
enable() {
|
|
42
31
|
return this;
|
|
43
|
-
}
|
|
44
|
-
|
|
32
|
+
}
|
|
33
|
+
disable() {
|
|
45
34
|
return this;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
}());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
49
37
|
exports.NoopContextManager = NoopContextManager;
|
|
50
38
|
//# sourceMappingURL=NoopContextManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoopContextManager.js","sourceRoot":"","sources":["../../../src/context/NoopContextManager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"NoopContextManager.js","sourceRoot":"","sources":["../../../src/context/NoopContextManager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,uCAAyC;AAGzC,MAAa,kBAAkB;IAC7B,MAAM;QACJ,OAAO,sBAAY,CAAC;IACtB,CAAC;IAED,IAAI,CACF,QAAuB,EACvB,EAAK,EACL,OAA8B,EAC9B,GAAG,IAAO;QAEV,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,CAAI,QAAuB,EAAE,MAAS;QACxC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAzBD,gDAyBC","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 { ROOT_CONTEXT } from './context';\nimport * as types from './types';\n\nexport class NoopContextManager implements types.ContextManager {\n active(): types.Context {\n return ROOT_CONTEXT;\n }\n\n with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(\n _context: types.Context,\n fn: F,\n thisArg?: ThisParameterType<F>,\n ...args: A\n ): ReturnType<F> {\n return fn.call(thisArg, ...args);\n }\n\n bind<T>(_context: types.Context, target: T): T {\n return target;\n }\n\n enable(): this {\n return this;\n }\n\n disable(): this {\n return this;\n }\n}\n"]}
|
|
@@ -27,30 +27,29 @@ function createContextKey(description) {
|
|
|
27
27
|
return Symbol.for(description);
|
|
28
28
|
}
|
|
29
29
|
exports.createContextKey = createContextKey;
|
|
30
|
-
|
|
30
|
+
class BaseContext {
|
|
31
31
|
/**
|
|
32
32
|
* Construct a new context which inherits values from an optional parent context.
|
|
33
33
|
*
|
|
34
34
|
* @param parentContext a context from which to inherit values
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
constructor(parentContext) {
|
|
37
37
|
// for minification
|
|
38
|
-
|
|
38
|
+
const self = this;
|
|
39
39
|
self._currentContext = parentContext ? new Map(parentContext) : new Map();
|
|
40
|
-
self.getValue =
|
|
41
|
-
self.setValue =
|
|
42
|
-
|
|
40
|
+
self.getValue = (key) => self._currentContext.get(key);
|
|
41
|
+
self.setValue = (key, value) => {
|
|
42
|
+
const context = new BaseContext(self._currentContext);
|
|
43
43
|
context._currentContext.set(key, value);
|
|
44
44
|
return context;
|
|
45
45
|
};
|
|
46
|
-
self.deleteValue =
|
|
47
|
-
|
|
46
|
+
self.deleteValue = (key) => {
|
|
47
|
+
const context = new BaseContext(self._currentContext);
|
|
48
48
|
context._currentContext.delete(key);
|
|
49
49
|
return context;
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
}());
|
|
52
|
+
}
|
|
54
53
|
/** The root context is used as the default parent context when there is no active context */
|
|
55
54
|
exports.ROOT_CONTEXT = new BaseContext();
|
|
56
55
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/context/context.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,qDAAqD;AACrD,SAAgB,gBAAgB,CAAC,WAAmB;IAClD,0EAA0E;IAC1E,2EAA2E;IAC3E,wEAAwE;IACxE,mDAAmD;IACnD,EAAE;IACF,8EAA8E;IAC9E,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC;AARD,4CAQC;AAED;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/context/context.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,qDAAqD;AACrD,SAAgB,gBAAgB,CAAC,WAAmB;IAClD,0EAA0E;IAC1E,2EAA2E;IAC3E,wEAAwE;IACxE,mDAAmD;IACnD,EAAE;IACF,8EAA8E;IAC9E,OAAO,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC;AARD,4CAQC;AAED,MAAM,WAAW;IAGf;;;;OAIG;IACH,YAAY,aAAoC;QAC9C,mBAAmB;QACnB,MAAM,IAAI,GAAG,IAAI,CAAC;QAElB,IAAI,CAAC,eAAe,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;QAE1E,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAE/D,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAW,EAAE,KAAc,EAAW,EAAE;YACvD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACtD,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACxC,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;QAEF,IAAI,CAAC,WAAW,GAAG,CAAC,GAAW,EAAW,EAAE;YAC1C,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACtD,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACpC,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC;CAyBF;AAED,6FAA6F;AAChF,QAAA,YAAY,GAAY,IAAI,WAAW,EAAE,CAAC","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 './types';\n\n/** Get a key to uniquely identify a context value */\nexport function createContextKey(description: string) {\n // The specification states that for the same input, multiple calls should\n // return different keys. Due to the nature of the JS dependency management\n // system, this creates problems where multiple versions of some package\n // could hold different keys for the same property.\n //\n // Therefore, we use Symbol.for which returns the same key for the same input.\n return Symbol.for(description);\n}\n\nclass BaseContext implements Context {\n private _currentContext!: Map<symbol, unknown>;\n\n /**\n * Construct a new context which inherits values from an optional parent context.\n *\n * @param parentContext a context from which to inherit values\n */\n constructor(parentContext?: Map<symbol, unknown>) {\n // for minification\n const self = this;\n\n self._currentContext = parentContext ? new Map(parentContext) : new Map();\n\n self.getValue = (key: symbol) => self._currentContext.get(key);\n\n self.setValue = (key: symbol, value: unknown): Context => {\n const context = new BaseContext(self._currentContext);\n context._currentContext.set(key, value);\n return context;\n };\n\n self.deleteValue = (key: symbol): Context => {\n const context = new BaseContext(self._currentContext);\n context._currentContext.delete(key);\n return context;\n };\n }\n\n /**\n * Get a value from the context.\n *\n * @param key key which identifies a context value\n */\n public getValue!: (key: symbol) => unknown;\n\n /**\n * Create a new context which inherits from this context and has\n * the given key set to the given value.\n *\n * @param key context key for which to set the value\n * @param value value to set for the given key\n */\n public setValue!: (key: symbol, value: unknown) => Context;\n\n /**\n * Return a new context which inherits from this context but does\n * not contain a value for the given key.\n *\n * @param key context key for which to clear a value\n */\n public deleteValue!: (key: symbol) => Context;\n}\n\n/** The root context is used as the default parent context when there is no active context */\nexport const ROOT_CONTEXT: Context = new BaseContext();\n"]}
|
|
@@ -14,17 +14,11 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
25
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
|
-
};
|
|
27
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
exports.context = void 0;
|
|
19
|
+
// Split module-level variable definition into separate files to allow
|
|
20
|
+
// tree-shaking on each api instance.
|
|
21
|
+
const context_1 = require("./api/context");
|
|
22
|
+
/** Entrypoint for context API */
|
|
23
|
+
exports.context = context_1.ContextAPI.getInstance();
|
|
24
|
+
//# sourceMappingURL=context-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-api.js","sourceRoot":"","sources":["../../src/context-api.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,sEAAsE;AACtE,qCAAqC;AACrC,2CAA2C;AAC3C,iCAAiC;AACpB,QAAA,OAAO,GAAG,oBAAU,CAAC,WAAW,EAAE,CAAC","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\n// Split module-level variable definition into separate files to allow\n// tree-shaking on each api instance.\nimport { ContextAPI } from './api/context';\n/** Entrypoint for context API */\nexport const context = ContextAPI.getInstance();\n"]}
|