@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,47 +16,46 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.unregisterGlobal = exports.getGlobal = exports.registerGlobal = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function registerGlobal(type, instance, diag, allowOverride) {
|
|
19
|
+
const platform_1 = require("../platform");
|
|
20
|
+
const version_1 = require("../version");
|
|
21
|
+
const semver_1 = require("./semver");
|
|
22
|
+
const major = version_1.VERSION.split('.')[0];
|
|
23
|
+
const GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(`opentelemetry.js.api.${major}`);
|
|
24
|
+
const _global = platform_1._globalThis;
|
|
25
|
+
function registerGlobal(type, instance, diag, allowOverride = false) {
|
|
26
26
|
var _a;
|
|
27
|
-
|
|
28
|
-
var api = (_global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : {
|
|
27
|
+
const api = (_global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : {
|
|
29
28
|
version: version_1.VERSION,
|
|
30
29
|
});
|
|
31
30
|
if (!allowOverride && api[type]) {
|
|
32
31
|
// already registered an API of this type
|
|
33
|
-
|
|
32
|
+
const err = new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${type}`);
|
|
34
33
|
diag.error(err.stack || err.message);
|
|
35
34
|
return false;
|
|
36
35
|
}
|
|
37
36
|
if (api.version !== version_1.VERSION) {
|
|
38
37
|
// All registered APIs must be of the same version exactly
|
|
39
|
-
|
|
38
|
+
const err = new Error('@opentelemetry/api: All API registration versions must match');
|
|
40
39
|
diag.error(err.stack || err.message);
|
|
41
40
|
return false;
|
|
42
41
|
}
|
|
43
42
|
api[type] = instance;
|
|
44
|
-
diag.debug(
|
|
43
|
+
diag.debug(`@opentelemetry/api: Registered a global for ${type} v${version_1.VERSION}.`);
|
|
45
44
|
return true;
|
|
46
45
|
}
|
|
47
46
|
exports.registerGlobal = registerGlobal;
|
|
48
47
|
function getGlobal(type) {
|
|
49
48
|
var _a, _b;
|
|
50
|
-
|
|
51
|
-
if (!globalVersion || !semver_1.isCompatible(globalVersion)) {
|
|
49
|
+
const globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;
|
|
50
|
+
if (!globalVersion || !(0, semver_1.isCompatible)(globalVersion)) {
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
53
|
return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
|
|
55
54
|
}
|
|
56
55
|
exports.getGlobal = getGlobal;
|
|
57
56
|
function unregisterGlobal(type, diag) {
|
|
58
|
-
diag.debug(
|
|
59
|
-
|
|
57
|
+
diag.debug(`@opentelemetry/api: Unregistering a global for ${type} v${version_1.VERSION}.`);
|
|
58
|
+
const api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
|
|
60
59
|
if (api) {
|
|
61
60
|
delete api[type];
|
|
62
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-utils.js","sourceRoot":"","sources":["../../../src/internal/global-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;
|
|
1
|
+
{"version":3,"file":"global-utils.js","sourceRoot":"","sources":["../../../src/internal/global-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAKH,0CAA0C;AAG1C,wCAAqC;AACrC,qCAAwC;AAExC,MAAM,KAAK,GAAG,iBAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,MAAM,4BAA4B,GAAG,MAAM,CAAC,GAAG,CAC7C,wBAAwB,KAAK,EAAE,CAChC,CAAC;AAEF,MAAM,OAAO,GAAG,sBAAyB,CAAC;AAE1C,SAAgB,cAAc,CAC5B,IAAU,EACV,QAA6B,EAC7B,IAAgB,EAChB,aAAa,GAAG,KAAK;;IAErB,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,4BAA4B,CAAC,GAAG,MAAA,OAAO,CAC1D,4BAA4B,CAC7B,mCAAI;QACH,OAAO,EAAE,iBAAO;KACjB,CAAC,CAAC;IAEH,IAAI,CAAC,aAAa,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE;QAC/B,yCAAyC;QACzC,MAAM,GAAG,GAAG,IAAI,KAAK,CACnB,gEAAgE,IAAI,EAAE,CACvE,CAAC;QACF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC;KACd;IAED,IAAI,GAAG,CAAC,OAAO,KAAK,iBAAO,EAAE;QAC3B,0DAA0D;QAC1D,MAAM,GAAG,GAAG,IAAI,KAAK,CACnB,8DAA8D,CAC/D,CAAC;QACF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC;KACd;IAED,GAAG,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;IACrB,IAAI,CAAC,KAAK,CACR,+CAA+C,IAAI,KAAK,iBAAO,GAAG,CACnE,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC;AApCD,wCAoCC;AAED,SAAgB,SAAS,CACvB,IAAU;;IAEV,MAAM,aAAa,GAAG,MAAA,OAAO,CAAC,4BAA4B,CAAC,0CAAE,OAAO,CAAC;IACrE,IAAI,CAAC,aAAa,IAAI,CAAC,IAAA,qBAAY,EAAC,aAAa,CAAC,EAAE;QAClD,OAAO;KACR;IACD,OAAO,MAAA,OAAO,CAAC,4BAA4B,CAAC,0CAAG,IAAI,CAAC,CAAC;AACvD,CAAC;AARD,8BAQC;AAED,SAAgB,gBAAgB,CAAC,IAAyB,EAAE,IAAgB;IAC1E,IAAI,CAAC,KAAK,CACR,kDAAkD,IAAI,KAAK,iBAAO,GAAG,CACtE,CAAC;IACF,MAAM,GAAG,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAElD,IAAI,GAAG,EAAE;QACP,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;KAClB;AACH,CAAC;AATD,4CASC","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 { MeterProvider } from '../metrics/MeterProvider';\nimport { ContextManager } from '../context/types';\nimport { DiagLogger } from '../diag/types';\nimport { _globalThis } from '../platform';\nimport { TextMapPropagator } from '../propagation/TextMapPropagator';\nimport type { TracerProvider } from '../trace/tracer_provider';\nimport { VERSION } from '../version';\nimport { isCompatible } from './semver';\n\nconst major = VERSION.split('.')[0];\nconst GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(\n `opentelemetry.js.api.${major}`\n);\n\nconst _global = _globalThis as OTelGlobal;\n\nexport function registerGlobal<Type extends keyof OTelGlobalAPI>(\n type: Type,\n instance: OTelGlobalAPI[Type],\n diag: DiagLogger,\n allowOverride = false\n): boolean {\n const api = (_global[GLOBAL_OPENTELEMETRY_API_KEY] = _global[\n GLOBAL_OPENTELEMETRY_API_KEY\n ] ?? {\n version: VERSION,\n });\n\n if (!allowOverride && api[type]) {\n // already registered an API of this type\n const err = new Error(\n `@opentelemetry/api: Attempted duplicate registration of API: ${type}`\n );\n diag.error(err.stack || err.message);\n return false;\n }\n\n if (api.version !== VERSION) {\n // All registered APIs must be of the same version exactly\n const err = new Error(\n '@opentelemetry/api: All API registration versions must match'\n );\n diag.error(err.stack || err.message);\n return false;\n }\n\n api[type] = instance;\n diag.debug(\n `@opentelemetry/api: Registered a global for ${type} v${VERSION}.`\n );\n\n return true;\n}\n\nexport function getGlobal<Type extends keyof OTelGlobalAPI>(\n type: Type\n): OTelGlobalAPI[Type] | undefined {\n const globalVersion = _global[GLOBAL_OPENTELEMETRY_API_KEY]?.version;\n if (!globalVersion || !isCompatible(globalVersion)) {\n return;\n }\n return _global[GLOBAL_OPENTELEMETRY_API_KEY]?.[type];\n}\n\nexport function unregisterGlobal(type: keyof OTelGlobalAPI, diag: DiagLogger) {\n diag.debug(\n `@opentelemetry/api: Unregistering a global for ${type} v${VERSION}.`\n );\n const api = _global[GLOBAL_OPENTELEMETRY_API_KEY];\n\n if (api) {\n delete api[type];\n }\n}\n\ntype OTelGlobal = {\n [GLOBAL_OPENTELEMETRY_API_KEY]?: OTelGlobalAPI;\n};\n\ntype OTelGlobalAPI = {\n version: string;\n\n diag?: DiagLogger;\n trace?: TracerProvider;\n context?: ContextManager;\n metrics?: MeterProvider;\n propagation?: TextMapPropagator;\n};\n"]}
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.isCompatible = exports._makeCompatibilityCheck = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const version_1 = require("../version");
|
|
20
|
+
const re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
|
|
21
21
|
/**
|
|
22
22
|
* Create a function to test an API version to see if it is compatible with the provided ownVersion.
|
|
23
23
|
*
|
|
@@ -35,14 +35,14 @@ var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
|
|
|
35
35
|
* @param ownVersion version which should be checked against
|
|
36
36
|
*/
|
|
37
37
|
function _makeCompatibilityCheck(ownVersion) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const acceptedVersions = new Set([ownVersion]);
|
|
39
|
+
const rejectedVersions = new Set();
|
|
40
|
+
const myVersionMatch = ownVersion.match(re);
|
|
41
41
|
if (!myVersionMatch) {
|
|
42
42
|
// we cannot guarantee compatibility so we always return noop
|
|
43
|
-
return
|
|
43
|
+
return () => false;
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
const ownVersionParsed = {
|
|
46
46
|
major: +myVersionMatch[1],
|
|
47
47
|
minor: +myVersionMatch[2],
|
|
48
48
|
patch: +myVersionMatch[3],
|
|
@@ -69,13 +69,13 @@ function _makeCompatibilityCheck(ownVersion) {
|
|
|
69
69
|
if (rejectedVersions.has(globalVersion)) {
|
|
70
70
|
return false;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
const globalVersionMatch = globalVersion.match(re);
|
|
73
73
|
if (!globalVersionMatch) {
|
|
74
74
|
// cannot parse other version
|
|
75
75
|
// we cannot guarantee compatibility so we always noop
|
|
76
76
|
return _reject(globalVersion);
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
const globalVersionParsed = {
|
|
79
79
|
major: +globalVersionMatch[1],
|
|
80
80
|
minor: +globalVersionMatch[2],
|
|
81
81
|
patch: +globalVersionMatch[3],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semver.js","sourceRoot":"","sources":["../../../src/internal/semver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"semver.js","sourceRoot":"","sources":["../../../src/internal/semver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,wCAAqC;AAErC,MAAM,EAAE,GAAG,+BAA+B,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,uBAAuB,CACrC,UAAkB;IAElB,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IACvD,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAE3C,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5C,IAAI,CAAC,cAAc,EAAE;QACnB,6DAA6D;QAC7D,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC;KACpB;IAED,MAAM,gBAAgB,GAAG;QACvB,KAAK,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;QACzB,KAAK,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;QACzB,KAAK,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;QACzB,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;KAC9B,CAAC;IAEF,kEAAkE;IAClE,IAAI,gBAAgB,CAAC,UAAU,IAAI,IAAI,EAAE;QACvC,OAAO,SAAS,YAAY,CAAC,aAAqB;YAChD,OAAO,aAAa,KAAK,UAAU,CAAC;QACtC,CAAC,CAAC;KACH;IAED,SAAS,OAAO,CAAC,CAAS;QACxB,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,SAAS,OAAO,CAAC,CAAS;QACxB,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,SAAS,YAAY,CAAC,aAAqB;QAChD,IAAI,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACvC,OAAO,IAAI,CAAC;SACb;QAED,IAAI,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACvC,OAAO,KAAK,CAAC;SACd;QAED,MAAM,kBAAkB,GAAG,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,kBAAkB,EAAE;YACvB,6BAA6B;YAC7B,sDAAsD;YACtD,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;SAC/B;QAED,MAAM,mBAAmB,GAAG;YAC1B,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAC7B,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAC7B,KAAK,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAC7B,UAAU,EAAE,kBAAkB,CAAC,CAAC,CAAC;SAClC,CAAC;QAEF,qEAAqE;QACrE,IAAI,mBAAmB,CAAC,UAAU,IAAI,IAAI,EAAE;YAC1C,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;SAC/B;QAED,4BAA4B;QAC5B,IAAI,gBAAgB,CAAC,KAAK,KAAK,mBAAmB,CAAC,KAAK,EAAE;YACxD,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;SAC/B;QAED,IAAI,gBAAgB,CAAC,KAAK,KAAK,CAAC,EAAE;YAChC,IACE,gBAAgB,CAAC,KAAK,KAAK,mBAAmB,CAAC,KAAK;gBACpD,gBAAgB,CAAC,KAAK,IAAI,mBAAmB,CAAC,KAAK,EACnD;gBACA,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;aAC/B;YAED,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;SAC/B;QAED,IAAI,gBAAgB,CAAC,KAAK,IAAI,mBAAmB,CAAC,KAAK,EAAE;YACvD,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;SAC/B;QAED,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC;AAtFD,0DAsFC;AAED;;;;;;;;;;;;;;GAcG;AACU,QAAA,YAAY,GAAG,uBAAuB,CAAC,iBAAO,CAAC,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 { VERSION } from '../version';\n\nconst re = /^(\\d+)\\.(\\d+)\\.(\\d+)(-(.+))?$/;\n\n/**\n * Create a function to test an API version to see if it is compatible with the provided ownVersion.\n *\n * The returned function has the following semantics:\n * - Exact match is always compatible\n * - Major versions must match exactly\n * - 1.x package cannot use global 2.x package\n * - 2.x package cannot use global 1.x package\n * - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API\n * - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects\n * - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3\n * - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor\n * - Patch and build tag differences are not considered at this time\n *\n * @param ownVersion version which should be checked against\n */\nexport function _makeCompatibilityCheck(\n ownVersion: string\n): (globalVersion: string) => boolean {\n const acceptedVersions = new Set<string>([ownVersion]);\n const rejectedVersions = new Set<string>();\n\n const myVersionMatch = ownVersion.match(re);\n if (!myVersionMatch) {\n // we cannot guarantee compatibility so we always return noop\n return () => false;\n }\n\n const ownVersionParsed = {\n major: +myVersionMatch[1],\n minor: +myVersionMatch[2],\n patch: +myVersionMatch[3],\n prerelease: myVersionMatch[4],\n };\n\n // if ownVersion has a prerelease tag, versions must match exactly\n if (ownVersionParsed.prerelease != null) {\n return function isExactmatch(globalVersion: string): boolean {\n return globalVersion === ownVersion;\n };\n }\n\n function _reject(v: string) {\n rejectedVersions.add(v);\n return false;\n }\n\n function _accept(v: string) {\n acceptedVersions.add(v);\n return true;\n }\n\n return function isCompatible(globalVersion: string): boolean {\n if (acceptedVersions.has(globalVersion)) {\n return true;\n }\n\n if (rejectedVersions.has(globalVersion)) {\n return false;\n }\n\n const globalVersionMatch = globalVersion.match(re);\n if (!globalVersionMatch) {\n // cannot parse other version\n // we cannot guarantee compatibility so we always noop\n return _reject(globalVersion);\n }\n\n const globalVersionParsed = {\n major: +globalVersionMatch[1],\n minor: +globalVersionMatch[2],\n patch: +globalVersionMatch[3],\n prerelease: globalVersionMatch[4],\n };\n\n // if globalVersion has a prerelease tag, versions must match exactly\n if (globalVersionParsed.prerelease != null) {\n return _reject(globalVersion);\n }\n\n // major versions must match\n if (ownVersionParsed.major !== globalVersionParsed.major) {\n return _reject(globalVersion);\n }\n\n if (ownVersionParsed.major === 0) {\n if (\n ownVersionParsed.minor === globalVersionParsed.minor &&\n ownVersionParsed.patch <= globalVersionParsed.patch\n ) {\n return _accept(globalVersion);\n }\n\n return _reject(globalVersion);\n }\n\n if (ownVersionParsed.minor <= globalVersionParsed.minor) {\n return _accept(globalVersion);\n }\n\n return _reject(globalVersion);\n };\n}\n\n/**\n * Test an API version to see if it is compatible with this API.\n *\n * - Exact match is always compatible\n * - Major versions must match exactly\n * - 1.x package cannot use global 2.x package\n * - 2.x package cannot use global 1.x package\n * - The minor version of the API module requesting access to the global API must be less than or equal to the minor version of this API\n * - 1.3 package may use 1.4 global because the later global contains all functions 1.3 expects\n * - 1.4 package may NOT use 1.3 global because it may try to call functions which don't exist on 1.3\n * - If the major version is 0, the minor version is treated as the major and the patch is treated as the minor\n * - Patch and build tag differences are not considered at this time\n *\n * @param version version of the API requesting an instance of the global API\n */\nexport const isCompatible = _makeCompatibilityCheck(VERSION);\n"]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { BatchObservableCallback, Counter, Histogram, MetricAttributes, MetricOptions, Observable, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter } from './Metric';
|
|
2
|
+
/**
|
|
3
|
+
* An interface describes additional metadata of a meter.
|
|
4
|
+
*/
|
|
5
|
+
export interface MeterOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The schemaUrl of the meter or instrumentation library
|
|
8
|
+
*/
|
|
9
|
+
schemaUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* An interface to allow the recording metrics.
|
|
13
|
+
*
|
|
14
|
+
* {@link Metric}s are used for recording pre-defined aggregation (`Counter`),
|
|
15
|
+
* or raw values (`Histogram`) in which the aggregation and attributes
|
|
16
|
+
* for the exported metric are deferred.
|
|
17
|
+
*/
|
|
18
|
+
export interface Meter {
|
|
19
|
+
/**
|
|
20
|
+
* Creates and returns a new `Histogram`.
|
|
21
|
+
* @param name the name of the metric.
|
|
22
|
+
* @param [options] the metric options.
|
|
23
|
+
*/
|
|
24
|
+
createHistogram<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): Histogram<AttributesTypes>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new `Counter` metric. Generally, this kind of metric when the
|
|
27
|
+
* value is a quantity, the sum is of primary interest, and the event count
|
|
28
|
+
* and value distribution are not of primary interest.
|
|
29
|
+
* @param name the name of the metric.
|
|
30
|
+
* @param [options] the metric options.
|
|
31
|
+
*/
|
|
32
|
+
createCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): Counter<AttributesTypes>;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new `UpDownCounter` metric. UpDownCounter is a synchronous
|
|
35
|
+
* instrument and very similar to Counter except that Add(increment)
|
|
36
|
+
* supports negative increments. It is generally useful for capturing changes
|
|
37
|
+
* in an amount of resources used, or any quantity that rises and falls
|
|
38
|
+
* during a request.
|
|
39
|
+
* Example uses for UpDownCounter:
|
|
40
|
+
* <ol>
|
|
41
|
+
* <li> count the number of active requests. </li>
|
|
42
|
+
* <li> count memory in use by instrumenting new and delete. </li>
|
|
43
|
+
* <li> count queue size by instrumenting enqueue and dequeue. </li>
|
|
44
|
+
* <li> count semaphore up and down operations. </li>
|
|
45
|
+
* </ol>
|
|
46
|
+
*
|
|
47
|
+
* @param name the name of the metric.
|
|
48
|
+
* @param [options] the metric options.
|
|
49
|
+
*/
|
|
50
|
+
createUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): UpDownCounter<AttributesTypes>;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new `ObservableGauge` metric.
|
|
53
|
+
*
|
|
54
|
+
* The callback SHOULD be safe to be invoked concurrently.
|
|
55
|
+
*
|
|
56
|
+
* @param name the name of the metric.
|
|
57
|
+
* @param [options] the metric options.
|
|
58
|
+
*/
|
|
59
|
+
createObservableGauge<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): ObservableGauge<AttributesTypes>;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new `ObservableCounter` metric.
|
|
62
|
+
*
|
|
63
|
+
* The callback SHOULD be safe to be invoked concurrently.
|
|
64
|
+
*
|
|
65
|
+
* @param name the name of the metric.
|
|
66
|
+
* @param [options] the metric options.
|
|
67
|
+
*/
|
|
68
|
+
createObservableCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): ObservableCounter<AttributesTypes>;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new `ObservableUpDownCounter` metric.
|
|
71
|
+
*
|
|
72
|
+
* The callback SHOULD be safe to be invoked concurrently.
|
|
73
|
+
*
|
|
74
|
+
* @param name the name of the metric.
|
|
75
|
+
* @param [options] the metric options.
|
|
76
|
+
*/
|
|
77
|
+
createObservableUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): ObservableUpDownCounter<AttributesTypes>;
|
|
78
|
+
/**
|
|
79
|
+
* Sets up a function that will be called whenever a metric collection is
|
|
80
|
+
* initiated.
|
|
81
|
+
*
|
|
82
|
+
* If the function is already in the list of callbacks for this Observable,
|
|
83
|
+
* the function is not added a second time.
|
|
84
|
+
*
|
|
85
|
+
* Only the associated observables can be observed in the callback.
|
|
86
|
+
* Measurements of observables that are not associated observed in the
|
|
87
|
+
* callback are dropped.
|
|
88
|
+
*
|
|
89
|
+
* @param callback the batch observable callback
|
|
90
|
+
* @param observables the observables associated with this batch observable callback
|
|
91
|
+
*/
|
|
92
|
+
addBatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes>(callback: BatchObservableCallback<AttributesTypes>, observables: Observable<AttributesTypes>[]): void;
|
|
93
|
+
/**
|
|
94
|
+
* Removes a callback previously registered with {@link Meter.addBatchObservableCallback}.
|
|
95
|
+
*
|
|
96
|
+
* The callback to be removed is identified using a combination of the callback itself,
|
|
97
|
+
* and the set of the observables associated with it.
|
|
98
|
+
*
|
|
99
|
+
* @param callback the batch observable callback
|
|
100
|
+
* @param observables the observables associated with this batch observable callback
|
|
101
|
+
*/
|
|
102
|
+
removeBatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes>(callback: BatchObservableCallback<AttributesTypes>, observables: Observable<AttributesTypes>[]): void;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=Meter.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
//# sourceMappingURL=Meter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Meter.js","sourceRoot":"","sources":["../../../src/metrics/Meter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","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 BatchObservableCallback,\n Counter,\n Histogram,\n MetricAttributes,\n MetricOptions,\n Observable,\n ObservableCounter,\n ObservableGauge,\n ObservableUpDownCounter,\n UpDownCounter,\n} from './Metric';\n\n/**\n * An interface describes additional metadata of a meter.\n */\nexport interface MeterOptions {\n /**\n * The schemaUrl of the meter or instrumentation library\n */\n schemaUrl?: string;\n}\n\n/**\n * An interface to allow the recording metrics.\n *\n * {@link Metric}s are used for recording pre-defined aggregation (`Counter`),\n * or raw values (`Histogram`) in which the aggregation and attributes\n * for the exported metric are deferred.\n */\nexport interface Meter {\n /**\n * Creates and returns a new `Histogram`.\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createHistogram<AttributesTypes extends MetricAttributes = MetricAttributes>(\n name: string,\n options?: MetricOptions\n ): Histogram<AttributesTypes>;\n\n /**\n * Creates a new `Counter` metric. Generally, this kind of metric when the\n * value is a quantity, the sum is of primary interest, and the event count\n * and value distribution are not of primary interest.\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(\n name: string,\n options?: MetricOptions\n ): Counter<AttributesTypes>;\n\n /**\n * Creates a new `UpDownCounter` metric. UpDownCounter is a synchronous\n * instrument and very similar to Counter except that Add(increment)\n * supports negative increments. It is generally useful for capturing changes\n * in an amount of resources used, or any quantity that rises and falls\n * during a request.\n * Example uses for UpDownCounter:\n * <ol>\n * <li> count the number of active requests. </li>\n * <li> count memory in use by instrumenting new and delete. </li>\n * <li> count queue size by instrumenting enqueue and dequeue. </li>\n * <li> count semaphore up and down operations. </li>\n * </ol>\n *\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): UpDownCounter<AttributesTypes>;\n\n /**\n * Creates a new `ObservableGauge` metric.\n *\n * The callback SHOULD be safe to be invoked concurrently.\n *\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createObservableGauge<AttributesTypes extends MetricAttributes = MetricAttributes>(\n name: string,\n options?: MetricOptions\n ): ObservableGauge<AttributesTypes>;\n\n /**\n * Creates a new `ObservableCounter` metric.\n *\n * The callback SHOULD be safe to be invoked concurrently.\n *\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createObservableCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(\n name: string,\n options?: MetricOptions\n ): ObservableCounter<AttributesTypes>;\n\n /**\n * Creates a new `ObservableUpDownCounter` metric.\n *\n * The callback SHOULD be safe to be invoked concurrently.\n *\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createObservableUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes>(\n name: string,\n options?: MetricOptions\n ): ObservableUpDownCounter<AttributesTypes>;\n\n /**\n * Sets up a function that will be called whenever a metric collection is\n * initiated.\n *\n * If the function is already in the list of callbacks for this Observable,\n * the function is not added a second time.\n *\n * Only the associated observables can be observed in the callback.\n * Measurements of observables that are not associated observed in the\n * callback are dropped.\n *\n * @param callback the batch observable callback\n * @param observables the observables associated with this batch observable callback\n */\n addBatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes>(\n callback: BatchObservableCallback<AttributesTypes>,\n observables: Observable<AttributesTypes>[]\n ): void;\n\n /**\n * Removes a callback previously registered with {@link Meter.addBatchObservableCallback}.\n *\n * The callback to be removed is identified using a combination of the callback itself,\n * and the set of the observables associated with it.\n *\n * @param callback the batch observable callback\n * @param observables the observables associated with this batch observable callback\n */\n removeBatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes>(\n callback: BatchObservableCallback<AttributesTypes>,\n observables: Observable<AttributesTypes>[]\n ): void;\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Meter, MeterOptions } from './Meter';
|
|
2
|
+
/**
|
|
3
|
+
* A registry for creating named {@link Meter}s.
|
|
4
|
+
*/
|
|
5
|
+
export interface MeterProvider {
|
|
6
|
+
/**
|
|
7
|
+
* Returns a Meter, creating one if one with the given name, version, and
|
|
8
|
+
* schemaUrl pair is not already created.
|
|
9
|
+
*
|
|
10
|
+
* @param name The name of the meter or instrumentation library.
|
|
11
|
+
* @param version The version of the meter or instrumentation library.
|
|
12
|
+
* @param options The options of the meter or instrumentation library.
|
|
13
|
+
* @returns Meter A Meter with the given name and version
|
|
14
|
+
*/
|
|
15
|
+
getMeter(name: string, version?: string, options?: MeterOptions): Meter;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=MeterProvider.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
//# sourceMappingURL=MeterProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MeterProvider.js","sourceRoot":"","sources":["../../../src/metrics/MeterProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","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 './Meter';\n\n/**\n * A registry for creating named {@link Meter}s.\n */\nexport interface MeterProvider {\n /**\n * Returns a Meter, creating one if one with the given name, version, and\n * schemaUrl pair is not already created.\n *\n * @param name The name of the meter or instrumentation library.\n * @param version The version of the meter or instrumentation library.\n * @param options The options of the meter or instrumentation library.\n * @returns Meter A Meter with the given name and version\n */\n getMeter(name: string, version?: string, options?: MeterOptions): Meter;\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Attributes, AttributeValue } from '../common/Attributes';
|
|
2
|
+
import { Context } from '../context/types';
|
|
3
|
+
import { BatchObservableResult, ObservableResult } from './ObservableResult';
|
|
4
|
+
/**
|
|
5
|
+
* Options needed for metric creation
|
|
6
|
+
*/
|
|
7
|
+
export interface MetricOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The description of the Metric.
|
|
10
|
+
* @default ''
|
|
11
|
+
*/
|
|
12
|
+
description?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The unit of the Metric values.
|
|
15
|
+
* @default ''
|
|
16
|
+
*/
|
|
17
|
+
unit?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Indicates the type of the recorded value.
|
|
20
|
+
* @default {@link ValueType.DOUBLE}
|
|
21
|
+
*/
|
|
22
|
+
valueType?: ValueType;
|
|
23
|
+
}
|
|
24
|
+
/** The Type of value. It describes how the data is reported. */
|
|
25
|
+
export declare enum ValueType {
|
|
26
|
+
INT = 0,
|
|
27
|
+
DOUBLE = 1
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Counter is the most common synchronous instrument. This instrument supports
|
|
31
|
+
* an `Add(increment)` function for reporting a sum, and is restricted to
|
|
32
|
+
* non-negative increments. The default aggregation is Sum, as for any additive
|
|
33
|
+
* instrument.
|
|
34
|
+
*
|
|
35
|
+
* Example uses for Counter:
|
|
36
|
+
* <ol>
|
|
37
|
+
* <li> count the number of bytes received. </li>
|
|
38
|
+
* <li> count the number of requests completed. </li>
|
|
39
|
+
* <li> count the number of accounts created. </li>
|
|
40
|
+
* <li> count the number of checkpoints run. </li>
|
|
41
|
+
* <li> count the number of 5xx errors. </li>
|
|
42
|
+
* <ol>
|
|
43
|
+
*/
|
|
44
|
+
export interface Counter<AttributesTypes extends MetricAttributes = MetricAttributes> {
|
|
45
|
+
/**
|
|
46
|
+
* Increment value of counter by the input. Inputs must not be negative.
|
|
47
|
+
*/
|
|
48
|
+
add(value: number, attributes?: AttributesTypes, context?: Context): void;
|
|
49
|
+
}
|
|
50
|
+
export interface UpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes> {
|
|
51
|
+
/**
|
|
52
|
+
* Increment value of counter by the input. Inputs may be negative.
|
|
53
|
+
*/
|
|
54
|
+
add(value: number, attributes?: AttributesTypes, context?: Context): void;
|
|
55
|
+
}
|
|
56
|
+
export interface Histogram<AttributesTypes extends MetricAttributes = MetricAttributes> {
|
|
57
|
+
/**
|
|
58
|
+
* Records a measurement. Value of the measurement must not be negative.
|
|
59
|
+
*/
|
|
60
|
+
record(value: number, attributes?: AttributesTypes, context?: Context): void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Attributes is a map from string to attribute values.
|
|
64
|
+
*
|
|
65
|
+
* Note: only the own enumerable keys are counted as valid attribute keys.
|
|
66
|
+
*/
|
|
67
|
+
export declare type MetricAttributes = Attributes;
|
|
68
|
+
/**
|
|
69
|
+
* Attribute values may be any non-nullish primitive value except an object.
|
|
70
|
+
*
|
|
71
|
+
* null or undefined attribute values are invalid and will result in undefined behavior.
|
|
72
|
+
*/
|
|
73
|
+
export declare type MetricAttributeValue = AttributeValue;
|
|
74
|
+
/**
|
|
75
|
+
* The observable callback for Observable instruments.
|
|
76
|
+
*/
|
|
77
|
+
export declare type ObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes> = (observableResult: ObservableResult<AttributesTypes>) => void | Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* The observable callback for a batch of Observable instruments.
|
|
80
|
+
*/
|
|
81
|
+
export declare type BatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes> = (observableResult: BatchObservableResult<AttributesTypes>) => void | Promise<void>;
|
|
82
|
+
export interface Observable<AttributesTypes extends MetricAttributes = MetricAttributes> {
|
|
83
|
+
/**
|
|
84
|
+
* Sets up a function that will be called whenever a metric collection is initiated.
|
|
85
|
+
*
|
|
86
|
+
* If the function is already in the list of callbacks for this Observable, the function is not added a second time.
|
|
87
|
+
*/
|
|
88
|
+
addCallback(callback: ObservableCallback<AttributesTypes>): void;
|
|
89
|
+
/**
|
|
90
|
+
* Removes a callback previously registered with {@link Observable.addCallback}.
|
|
91
|
+
*/
|
|
92
|
+
removeCallback(callback: ObservableCallback<AttributesTypes>): void;
|
|
93
|
+
}
|
|
94
|
+
export declare type ObservableCounter<AttributesTypes extends MetricAttributes = MetricAttributes> = Observable<AttributesTypes>;
|
|
95
|
+
export declare type ObservableUpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes> = Observable<AttributesTypes>;
|
|
96
|
+
export declare type ObservableGauge<AttributesTypes extends MetricAttributes = MetricAttributes> = Observable<AttributesTypes>;
|
|
97
|
+
//# sourceMappingURL=Metric.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
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.ValueType = void 0;
|
|
19
|
+
/** The Type of value. It describes how the data is reported. */
|
|
20
|
+
var ValueType;
|
|
21
|
+
(function (ValueType) {
|
|
22
|
+
ValueType[ValueType["INT"] = 0] = "INT";
|
|
23
|
+
ValueType[ValueType["DOUBLE"] = 1] = "DOUBLE";
|
|
24
|
+
})(ValueType = exports.ValueType || (exports.ValueType = {}));
|
|
25
|
+
//# sourceMappingURL=Metric.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Metric.js","sourceRoot":"","sources":["../../../src/metrics/Metric.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AA6BH,gEAAgE;AAChE,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,uCAAG,CAAA;IACH,6CAAM,CAAA;AACR,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB","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 { Attributes, AttributeValue } from '../common/Attributes';\nimport { Context } from '../context/types';\nimport { BatchObservableResult, ObservableResult } from './ObservableResult';\n\n/**\n * Options needed for metric creation\n */\nexport interface MetricOptions {\n /**\n * The description of the Metric.\n * @default ''\n */\n description?: string;\n\n /**\n * The unit of the Metric values.\n * @default ''\n */\n unit?: string;\n\n /**\n * Indicates the type of the recorded value.\n * @default {@link ValueType.DOUBLE}\n */\n valueType?: ValueType;\n}\n\n/** The Type of value. It describes how the data is reported. */\nexport enum ValueType {\n INT,\n DOUBLE,\n}\n\n/**\n * Counter is the most common synchronous instrument. This instrument supports\n * an `Add(increment)` function for reporting a sum, and is restricted to\n * non-negative increments. The default aggregation is Sum, as for any additive\n * instrument.\n *\n * Example uses for Counter:\n * <ol>\n * <li> count the number of bytes received. </li>\n * <li> count the number of requests completed. </li>\n * <li> count the number of accounts created. </li>\n * <li> count the number of checkpoints run. </li>\n * <li> count the number of 5xx errors. </li>\n * <ol>\n */\nexport interface Counter<AttributesTypes extends MetricAttributes = MetricAttributes> {\n /**\n * Increment value of counter by the input. Inputs must not be negative.\n */\n add(value: number, attributes?: AttributesTypes, context?: Context): void;\n}\n\nexport interface UpDownCounter<AttributesTypes extends MetricAttributes = MetricAttributes> {\n /**\n * Increment value of counter by the input. Inputs may be negative.\n */\n add(value: number, attributes?: AttributesTypes, context?: Context): void;\n}\n\nexport interface Histogram<AttributesTypes extends MetricAttributes = MetricAttributes> {\n /**\n * Records a measurement. Value of the measurement must not be negative.\n */\n record(value: number, attributes?: AttributesTypes, context?: Context): void;\n}\n\n// api.SpanAttributes instead of api.Attributes is used here for api package backward compatibility.\n/**\n * Attributes is a map from string to attribute values.\n *\n * Note: only the own enumerable keys are counted as valid attribute keys.\n */\nexport type MetricAttributes = Attributes;\n\n// api.SpanAttributeValue instead of api.AttributeValue is used here for api package backward compatibility.\n/**\n * Attribute values may be any non-nullish primitive value except an object.\n *\n * null or undefined attribute values are invalid and will result in undefined behavior.\n */\nexport type MetricAttributeValue = AttributeValue;\n\n/**\n * The observable callback for Observable instruments.\n */\nexport type ObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes> =\n (observableResult: ObservableResult<AttributesTypes>) => void | Promise<void>;\n\n/**\n * The observable callback for a batch of Observable instruments.\n */\nexport type BatchObservableCallback<AttributesTypes extends MetricAttributes = MetricAttributes> =\n (observableResult: BatchObservableResult<AttributesTypes>) => void | Promise<void>;\n\nexport interface Observable<AttributesTypes extends MetricAttributes = MetricAttributes> {\n /**\n * Sets up a function that will be called whenever a metric collection is initiated.\n *\n * If the function is already in the list of callbacks for this Observable, the function is not added a second time.\n */\n addCallback(callback: ObservableCallback<AttributesTypes>): void;\n\n /**\n * Removes a callback previously registered with {@link Observable.addCallback}.\n */\n removeCallback(callback: ObservableCallback<AttributesTypes>): void;\n}\n\nexport type ObservableCounter<AttributesTypes extends MetricAttributes=MetricAttributes> = Observable<AttributesTypes>;\nexport type ObservableUpDownCounter<AttributesTypes extends MetricAttributes=MetricAttributes> = Observable<AttributesTypes>;\nexport type ObservableGauge<AttributesTypes extends MetricAttributes=MetricAttributes> = Observable<AttributesTypes>;\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Meter } from './Meter';
|
|
2
|
+
import { BatchObservableCallback, Counter, Histogram, MetricOptions, ObservableCallback, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter, MetricAttributes, Observable } from './Metric';
|
|
3
|
+
/**
|
|
4
|
+
* NoopMeter is a noop implementation of the {@link Meter} interface. It reuses
|
|
5
|
+
* constant NoopMetrics for all of its methods.
|
|
6
|
+
*/
|
|
7
|
+
export declare class NoopMeter implements Meter {
|
|
8
|
+
constructor();
|
|
9
|
+
/**
|
|
10
|
+
* @see {@link Meter.createHistogram}
|
|
11
|
+
*/
|
|
12
|
+
createHistogram(_name: string, _options?: MetricOptions): Histogram;
|
|
13
|
+
/**
|
|
14
|
+
* @see {@link Meter.createCounter}
|
|
15
|
+
*/
|
|
16
|
+
createCounter(_name: string, _options?: MetricOptions): Counter;
|
|
17
|
+
/**
|
|
18
|
+
* @see {@link Meter.createUpDownCounter}
|
|
19
|
+
*/
|
|
20
|
+
createUpDownCounter(_name: string, _options?: MetricOptions): UpDownCounter;
|
|
21
|
+
/**
|
|
22
|
+
* @see {@link Meter.createObservableGauge}
|
|
23
|
+
*/
|
|
24
|
+
createObservableGauge(_name: string, _options?: MetricOptions): ObservableGauge;
|
|
25
|
+
/**
|
|
26
|
+
* @see {@link Meter.createObservableCounter}
|
|
27
|
+
*/
|
|
28
|
+
createObservableCounter(_name: string, _options?: MetricOptions): ObservableCounter;
|
|
29
|
+
/**
|
|
30
|
+
* @see {@link Meter.createObservableUpDownCounter}
|
|
31
|
+
*/
|
|
32
|
+
createObservableUpDownCounter(_name: string, _options?: MetricOptions): ObservableUpDownCounter;
|
|
33
|
+
/**
|
|
34
|
+
* @see {@link Meter.addBatchObservableCallback}
|
|
35
|
+
*/
|
|
36
|
+
addBatchObservableCallback(_callback: BatchObservableCallback, _observables: Observable[]): void;
|
|
37
|
+
/**
|
|
38
|
+
* @see {@link Meter.removeBatchObservableCallback}
|
|
39
|
+
*/
|
|
40
|
+
removeBatchObservableCallback(_callback: BatchObservableCallback): void;
|
|
41
|
+
}
|
|
42
|
+
export declare class NoopMetric {
|
|
43
|
+
}
|
|
44
|
+
export declare class NoopCounterMetric extends NoopMetric implements Counter {
|
|
45
|
+
add(_value: number, _attributes: MetricAttributes): void;
|
|
46
|
+
}
|
|
47
|
+
export declare class NoopUpDownCounterMetric extends NoopMetric implements UpDownCounter {
|
|
48
|
+
add(_value: number, _attributes: MetricAttributes): void;
|
|
49
|
+
}
|
|
50
|
+
export declare class NoopHistogramMetric extends NoopMetric implements Histogram {
|
|
51
|
+
record(_value: number, _attributes: MetricAttributes): void;
|
|
52
|
+
}
|
|
53
|
+
export declare class NoopObservableMetric {
|
|
54
|
+
addCallback(_callback: ObservableCallback): void;
|
|
55
|
+
removeCallback(_callback: ObservableCallback): void;
|
|
56
|
+
}
|
|
57
|
+
export declare class NoopObservableCounterMetric extends NoopObservableMetric implements ObservableCounter {
|
|
58
|
+
}
|
|
59
|
+
export declare class NoopObservableGaugeMetric extends NoopObservableMetric implements ObservableGauge {
|
|
60
|
+
}
|
|
61
|
+
export declare class NoopObservableUpDownCounterMetric extends NoopObservableMetric implements ObservableUpDownCounter {
|
|
62
|
+
}
|
|
63
|
+
export declare const NOOP_METER: NoopMeter;
|
|
64
|
+
export declare const NOOP_COUNTER_METRIC: NoopCounterMetric;
|
|
65
|
+
export declare const NOOP_HISTOGRAM_METRIC: NoopHistogramMetric;
|
|
66
|
+
export declare const NOOP_UP_DOWN_COUNTER_METRIC: NoopUpDownCounterMetric;
|
|
67
|
+
export declare const NOOP_OBSERVABLE_COUNTER_METRIC: NoopObservableCounterMetric;
|
|
68
|
+
export declare const NOOP_OBSERVABLE_GAUGE_METRIC: NoopObservableGaugeMetric;
|
|
69
|
+
export declare const NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC: NoopObservableUpDownCounterMetric;
|
|
70
|
+
/**
|
|
71
|
+
* Create a no-op Meter
|
|
72
|
+
*/
|
|
73
|
+
export declare function createNoopMeter(): Meter;
|
|
74
|
+
//# sourceMappingURL=NoopMeter.d.ts.map
|