@opentelemetry/api 1.7.0 → 1.9.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 +1 -2
- package/build/esm/experimental/index.d.ts +3 -0
- package/build/esm/experimental/index.js +17 -0
- package/build/esm/experimental/index.js.map +1 -0
- package/build/esm/experimental/trace/SugaredOptions.d.ts +13 -0
- package/build/esm/experimental/trace/SugaredOptions.js +17 -0
- package/build/esm/experimental/trace/SugaredOptions.js.map +1 -0
- package/build/esm/experimental/trace/SugaredTracer.d.ts +64 -0
- package/build/esm/experimental/trace/SugaredTracer.js +92 -0
- package/build/esm/experimental/trace/SugaredTracer.js.map +1 -0
- package/build/esm/index.d.ts +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/metrics/Meter.d.ts +7 -1
- package/build/esm/metrics/Meter.js.map +1 -1
- package/build/esm/metrics/Metric.d.ts +6 -0
- package/build/esm/metrics/Metric.js.map +1 -1
- package/build/esm/metrics/NoopMeter.d.ts +9 -1
- package/build/esm/metrics/NoopMeter.js +16 -0
- package/build/esm/metrics/NoopMeter.js.map +1 -1
- package/build/esm/trace/NonRecordingSpan.d.ts +3 -0
- package/build/esm/trace/NonRecordingSpan.js +6 -0
- package/build/esm/trace/NonRecordingSpan.js.map +1 -1
- package/build/esm/trace/span.d.ts +19 -0
- package/build/esm/trace/span.js.map +1 -1
- 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/esnext/experimental/index.d.ts +3 -0
- package/build/esnext/experimental/index.js +17 -0
- package/build/esnext/experimental/index.js.map +1 -0
- package/build/esnext/experimental/trace/SugaredOptions.d.ts +13 -0
- package/build/esnext/experimental/trace/SugaredOptions.js +17 -0
- package/build/esnext/experimental/trace/SugaredOptions.js.map +1 -0
- package/build/esnext/experimental/trace/SugaredTracer.d.ts +64 -0
- package/build/esnext/experimental/trace/SugaredTracer.js +88 -0
- package/build/esnext/experimental/trace/SugaredTracer.js.map +1 -0
- package/build/esnext/index.d.ts +1 -1
- package/build/esnext/index.js.map +1 -1
- package/build/esnext/metrics/Meter.d.ts +7 -1
- package/build/esnext/metrics/Meter.js.map +1 -1
- package/build/esnext/metrics/Metric.d.ts +6 -0
- package/build/esnext/metrics/Metric.js.map +1 -1
- package/build/esnext/metrics/NoopMeter.d.ts +9 -1
- package/build/esnext/metrics/NoopMeter.js +10 -0
- package/build/esnext/metrics/NoopMeter.js.map +1 -1
- package/build/esnext/trace/NonRecordingSpan.d.ts +3 -0
- package/build/esnext/trace/NonRecordingSpan.js +6 -0
- package/build/esnext/trace/NonRecordingSpan.js.map +1 -1
- package/build/esnext/trace/span.d.ts +19 -0
- package/build/esnext/trace/span.js.map +1 -1
- package/build/esnext/version.d.ts +1 -1
- package/build/esnext/version.js +1 -1
- package/build/esnext/version.js.map +1 -1
- package/build/src/experimental/index.d.ts +3 -0
- package/build/src/experimental/index.js +22 -0
- package/build/src/experimental/index.js.map +1 -0
- package/build/src/experimental/trace/SugaredOptions.d.ts +13 -0
- package/build/src/experimental/trace/SugaredOptions.js +18 -0
- package/build/src/experimental/trace/SugaredOptions.js.map +1 -0
- package/build/src/experimental/trace/SugaredTracer.d.ts +64 -0
- package/build/src/experimental/trace/SugaredTracer.js +93 -0
- package/build/src/experimental/trace/SugaredTracer.js.map +1 -0
- package/build/src/index.d.ts +1 -1
- package/build/src/index.js.map +1 -1
- package/build/src/metrics/Meter.d.ts +7 -1
- package/build/src/metrics/Meter.js.map +1 -1
- package/build/src/metrics/Metric.d.ts +6 -0
- package/build/src/metrics/Metric.js.map +1 -1
- package/build/src/metrics/NoopMeter.d.ts +9 -1
- package/build/src/metrics/NoopMeter.js +12 -1
- package/build/src/metrics/NoopMeter.js.map +1 -1
- package/build/src/trace/NonRecordingSpan.d.ts +3 -0
- package/build/src/trace/NonRecordingSpan.js +6 -0
- package/build/src/trace/NonRecordingSpan.js.map +1 -1
- package/build/src/trace/span.d.ts +19 -0
- package/build/src/trace/span.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 +24 -10
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ npm install @opentelemetry/api @opentelemetry/sdk-trace-base
|
|
|
36
36
|
|
|
37
37
|
### Trace Your Application
|
|
38
38
|
|
|
39
|
-
In order to get started with tracing, you will need to first register an SDK. The SDK you are using may provide a convenience method which calls the registration methods for you, but if you would like to call them directly they are documented here: [
|
|
39
|
+
In order to get started with tracing, you will need to first register an SDK. The SDK you are using may provide a convenience method which calls the registration methods for you, but if you would like to call them directly they are documented here: [SDK registration methods][docs-sdk-registration].
|
|
40
40
|
|
|
41
41
|
Once you have registered an SDK, you can start and end spans. A simple example of basic SDK registration and tracing a simple operation is below. The example should export spans to the console once per second. For more information, see the [tracing documentation][docs-tracing].
|
|
42
42
|
|
|
@@ -112,6 +112,5 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
|
|
|
112
112
|
|
|
113
113
|
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
|
|
114
114
|
[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/api/LICENSE
|
|
115
|
-
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
|
|
116
115
|
[docs-tracing]: https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/tracing.md
|
|
117
116
|
[docs-sdk-registration]: https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/sdk-registration.md
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright The OpenTelemetry Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export { wrapTracer, SugaredTracer } from './trace/SugaredTracer';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/experimental/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,uBAAuB,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 */\nexport { wrapTracer, SugaredTracer } from './trace/SugaredTracer';\nexport { SugaredSpanOptions } from './trace/SugaredOptions';\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Span, SpanOptions } from '../../';
|
|
2
|
+
/**
|
|
3
|
+
* Options needed for span creation
|
|
4
|
+
*/
|
|
5
|
+
export interface SugaredSpanOptions extends SpanOptions {
|
|
6
|
+
/**
|
|
7
|
+
* function to overwrite default exception behavior to record the exception. No exceptions should be thrown in the function.
|
|
8
|
+
* @param e Error which triggered this exception
|
|
9
|
+
* @param span current span from context
|
|
10
|
+
*/
|
|
11
|
+
onException?: (e: Error, span: Span) => void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=SugaredOptions.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright The OpenTelemetry Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=SugaredOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SugaredOptions.js","sourceRoot":"","sources":["../../../../src/experimental/trace/SugaredOptions.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 { Span, SpanOptions } from '../../';\n\n/**\n * Options needed for span creation\n */\nexport interface SugaredSpanOptions extends SpanOptions {\n /**\n * function to overwrite default exception behavior to record the exception. No exceptions should be thrown in the function.\n * @param e Error which triggered this exception\n * @param span current span from context\n */\n onException?: (e: Error, span: Span) => void;\n}\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { SugaredSpanOptions } from './SugaredOptions';
|
|
2
|
+
import { Context, Span, Tracer } from '../../';
|
|
3
|
+
/**
|
|
4
|
+
* return a new SugaredTracer created from the supplied one
|
|
5
|
+
* @param tracer
|
|
6
|
+
*/
|
|
7
|
+
export declare function wrapTracer(tracer: Tracer): SugaredTracer;
|
|
8
|
+
export declare class SugaredTracer implements Tracer {
|
|
9
|
+
private readonly _tracer;
|
|
10
|
+
constructor(tracer: Tracer);
|
|
11
|
+
startActiveSpan: Tracer['startActiveSpan'];
|
|
12
|
+
startSpan: Tracer['startSpan'];
|
|
13
|
+
/**
|
|
14
|
+
* Starts a new {@link Span} and calls the given function passing it the
|
|
15
|
+
* created span as first argument.
|
|
16
|
+
* Additionally, the new span gets set in context and this context is activated
|
|
17
|
+
* for the duration of the function call.
|
|
18
|
+
* The span will be closed after the function has executed.
|
|
19
|
+
* If an exception occurs, it is recorded, the status is set to ERROR and the exception is rethrown.
|
|
20
|
+
*
|
|
21
|
+
* @param name The name of the span
|
|
22
|
+
* @param [options] SugaredSpanOptions used for span creation
|
|
23
|
+
* @param [context] Context to use to extract parent
|
|
24
|
+
* @param fn function called in the context of the span and receives the newly created span as an argument
|
|
25
|
+
* @returns return value of fn
|
|
26
|
+
* @example
|
|
27
|
+
* const something = tracer.withActiveSpan('op', span => {
|
|
28
|
+
* // do some work
|
|
29
|
+
* });
|
|
30
|
+
* @example
|
|
31
|
+
* const something = await tracer.withActiveSpan('op', span => {
|
|
32
|
+
* // do some async work
|
|
33
|
+
* });
|
|
34
|
+
*/
|
|
35
|
+
withActiveSpan<F extends (span: Span) => ReturnType<F>>(name: string, fn: F): ReturnType<F>;
|
|
36
|
+
withActiveSpan<F extends (span: Span) => ReturnType<F>>(name: string, options: SugaredSpanOptions, fn: F): ReturnType<F>;
|
|
37
|
+
withActiveSpan<F extends (span: Span) => ReturnType<F>>(name: string, options: SugaredSpanOptions, context: Context, fn: F): ReturnType<F>;
|
|
38
|
+
/**
|
|
39
|
+
* Starts a new {@link Span} and ends it after execution of fn without setting it on context.
|
|
40
|
+
* The span will be closed after the function has executed.
|
|
41
|
+
* If an exception occurs, it is recorded, the status is et to ERROR and rethrown.
|
|
42
|
+
*
|
|
43
|
+
* This method does NOT modify the current Context.
|
|
44
|
+
*
|
|
45
|
+
* @param name The name of the span
|
|
46
|
+
* @param [options] SugaredSpanOptions used for span creation
|
|
47
|
+
* @param [context] Context to use to extract parent
|
|
48
|
+
* @param fn function called in the context of the span and receives the newly created span as an argument
|
|
49
|
+
* @returns Span The newly created span
|
|
50
|
+
* @example
|
|
51
|
+
* const something = tracer.withSpan('op', span => {
|
|
52
|
+
* // do some work
|
|
53
|
+
* });
|
|
54
|
+
* @example
|
|
55
|
+
* const something = await tracer.withSpan('op', span => {
|
|
56
|
+
* // do some async work
|
|
57
|
+
* });
|
|
58
|
+
*/
|
|
59
|
+
withSpan<F extends (span: Span) => ReturnType<F>>(name: string, fn: F): ReturnType<F>;
|
|
60
|
+
withSpan<F extends (span: Span) => ReturnType<F>>(name: string, options: SugaredSpanOptions, fn: F): ReturnType<F>;
|
|
61
|
+
withSpan<F extends (span: Span) => ReturnType<F>>(name: string, options: SugaredSpanOptions, context: Context, fn: F): ReturnType<F>;
|
|
62
|
+
withSpan<F extends (span: Span) => ReturnType<F>>(name: string, options: SugaredSpanOptions, context: Context, fn: F): ReturnType<F>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=SugaredTracer.d.ts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { context, SpanStatusCode } from '../../';
|
|
2
|
+
var defaultOnException = function (e, span) {
|
|
3
|
+
span.recordException(e);
|
|
4
|
+
span.setStatus({
|
|
5
|
+
code: SpanStatusCode.ERROR,
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* return a new SugaredTracer created from the supplied one
|
|
10
|
+
* @param tracer
|
|
11
|
+
*/
|
|
12
|
+
export function wrapTracer(tracer) {
|
|
13
|
+
return new SugaredTracer(tracer);
|
|
14
|
+
}
|
|
15
|
+
var SugaredTracer = /** @class */ (function () {
|
|
16
|
+
function SugaredTracer(tracer) {
|
|
17
|
+
this._tracer = tracer;
|
|
18
|
+
this.startSpan = tracer.startSpan.bind(this._tracer);
|
|
19
|
+
this.startActiveSpan = tracer.startActiveSpan.bind(this._tracer);
|
|
20
|
+
}
|
|
21
|
+
SugaredTracer.prototype.withActiveSpan = function (name, arg2, arg3, arg4) {
|
|
22
|
+
var _a = massageParams(arg2, arg3, arg4), opts = _a.opts, ctx = _a.ctx, fn = _a.fn;
|
|
23
|
+
return this._tracer.startActiveSpan(name, opts, ctx, function (span) {
|
|
24
|
+
return handleFn(span, opts, fn);
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
SugaredTracer.prototype.withSpan = function (name, arg2, arg3, arg4) {
|
|
28
|
+
var _a = massageParams(arg2, arg3, arg4), opts = _a.opts, ctx = _a.ctx, fn = _a.fn;
|
|
29
|
+
var span = this._tracer.startSpan(name, opts, ctx);
|
|
30
|
+
return handleFn(span, opts, fn);
|
|
31
|
+
};
|
|
32
|
+
return SugaredTracer;
|
|
33
|
+
}());
|
|
34
|
+
export { SugaredTracer };
|
|
35
|
+
/**
|
|
36
|
+
* Massages parameters of withSpan and withActiveSpan to allow signature overwrites
|
|
37
|
+
* @param arg
|
|
38
|
+
* @param arg2
|
|
39
|
+
* @param arg3
|
|
40
|
+
*/
|
|
41
|
+
function massageParams(arg, arg2, arg3) {
|
|
42
|
+
var opts;
|
|
43
|
+
var ctx;
|
|
44
|
+
var fn;
|
|
45
|
+
if (!arg2 && !arg3) {
|
|
46
|
+
fn = arg;
|
|
47
|
+
}
|
|
48
|
+
else if (!arg3) {
|
|
49
|
+
opts = arg;
|
|
50
|
+
fn = arg2;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
opts = arg;
|
|
54
|
+
ctx = arg2;
|
|
55
|
+
fn = arg3;
|
|
56
|
+
}
|
|
57
|
+
opts = opts !== null && opts !== void 0 ? opts : {};
|
|
58
|
+
ctx = ctx !== null && ctx !== void 0 ? ctx : context.active();
|
|
59
|
+
return { opts: opts, ctx: ctx, fn: fn };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Executes fn, returns results and runs onException in the case of exception to allow overwriting of error handling
|
|
63
|
+
* @param span
|
|
64
|
+
* @param opts
|
|
65
|
+
* @param fn
|
|
66
|
+
*/
|
|
67
|
+
function handleFn(span, opts, fn) {
|
|
68
|
+
var _a;
|
|
69
|
+
var onException = (_a = opts.onException) !== null && _a !== void 0 ? _a : defaultOnException;
|
|
70
|
+
var errorHandler = function (e) {
|
|
71
|
+
onException(e, span);
|
|
72
|
+
span.end();
|
|
73
|
+
throw e;
|
|
74
|
+
};
|
|
75
|
+
try {
|
|
76
|
+
var ret = fn(span);
|
|
77
|
+
// if fn is an async function, attach a recordException and spanEnd callback to the promise
|
|
78
|
+
if (typeof (ret === null || ret === void 0 ? void 0 : ret.then) === 'function') {
|
|
79
|
+
return ret.then(function (val) {
|
|
80
|
+
span.end();
|
|
81
|
+
return val;
|
|
82
|
+
}, errorHandler);
|
|
83
|
+
}
|
|
84
|
+
span.end();
|
|
85
|
+
return ret;
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
// add throw to signal the compiler that this will throw in the inner scope
|
|
89
|
+
throw errorHandler(e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=SugaredTracer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SugaredTracer.js","sourceRoot":"","sources":["../../../../src/experimental/trace/SugaredTracer.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAiB,cAAc,EAAU,MAAM,QAAQ,CAAC;AAExE,IAAM,kBAAkB,GAAG,UAAC,CAAQ,EAAE,IAAU;IAC9C,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,CAAC,SAAS,CAAC;QACb,IAAI,EAAE,cAAc,CAAC,KAAK;KAC3B,CAAC,CAA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;gBACX,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,YAAY,CAAkB,CAAC;SACnC;QACD,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,OAAO,GAAoB,CAAC;KAC7B;IAAC,OAAO,CAAC,EAAE;QACV,2EAA2E;QAC3E,MAAM,YAAY,CAAC,CAAC,CAAC,CAAC;KACvB;AACH,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 */\nimport { SugaredSpanOptions } from './SugaredOptions';\nimport { context, Context, Span, SpanStatusCode, Tracer } from '../../';\n\nconst defaultOnException = (e: Error, span: Span) => {\n span.recordException(e);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n });\n};\n\n/**\n * return a new SugaredTracer created from the supplied one\n * @param tracer\n */\nexport function wrapTracer(tracer: Tracer): SugaredTracer {\n return new SugaredTracer(tracer);\n}\n\nexport class SugaredTracer implements Tracer {\n private readonly _tracer: Tracer;\n\n constructor(tracer: Tracer) {\n this._tracer = tracer;\n this.startSpan = tracer.startSpan.bind(this._tracer);\n this.startActiveSpan = tracer.startActiveSpan.bind(this._tracer);\n }\n\n startActiveSpan: Tracer['startActiveSpan'];\n startSpan: Tracer['startSpan'];\n\n /**\n * Starts a new {@link Span} and calls the given function passing it the\n * created span as first argument.\n * Additionally, the new span gets set in context and this context is activated\n * for the duration of the function call.\n * The span will be closed after the function has executed.\n * If an exception occurs, it is recorded, the status is set to ERROR and the exception is rethrown.\n *\n * @param name The name of the span\n * @param [options] SugaredSpanOptions used for span creation\n * @param [context] Context to use to extract parent\n * @param fn function called in the context of the span and receives the newly created span as an argument\n * @returns return value of fn\n * @example\n * const something = tracer.withActiveSpan('op', span => {\n * // do some work\n * });\n * @example\n * const something = await tracer.withActiveSpan('op', span => {\n * // do some async work\n * });\n */\n withActiveSpan<F extends (span: Span) => ReturnType<F>>(\n name: string,\n fn: F\n ): ReturnType<F>;\n withActiveSpan<F extends (span: Span) => ReturnType<F>>(\n name: string,\n options: SugaredSpanOptions,\n fn: F\n ): ReturnType<F>;\n withActiveSpan<F extends (span: Span) => ReturnType<F>>(\n name: string,\n options: SugaredSpanOptions,\n context: Context,\n fn: F\n ): ReturnType<F>;\n withActiveSpan<F extends (span: Span) => ReturnType<F>>(\n name: string,\n arg2: F | SugaredSpanOptions,\n arg3?: F | Context,\n arg4?: F\n ): ReturnType<F> {\n const { opts, ctx, fn } = massageParams(arg2, arg3, arg4);\n\n return this._tracer.startActiveSpan(name, opts, ctx, (span: Span) =>\n handleFn(span, opts, fn)\n ) as ReturnType<F>;\n }\n\n /**\n * Starts a new {@link Span} and ends it after execution of fn without setting it on context.\n * The span will be closed after the function has executed.\n * If an exception occurs, it is recorded, the status is et to ERROR and rethrown.\n *\n * This method does NOT modify the current Context.\n *\n * @param name The name of the span\n * @param [options] SugaredSpanOptions used for span creation\n * @param [context] Context to use to extract parent\n * @param fn function called in the context of the span and receives the newly created span as an argument\n * @returns Span The newly created span\n * @example\n * const something = tracer.withSpan('op', span => {\n * // do some work\n * });\n * @example\n * const something = await tracer.withSpan('op', span => {\n * // do some async work\n * });\n */\n withSpan<F extends (span: Span) => ReturnType<F>>(\n name: string,\n fn: F\n ): ReturnType<F>;\n withSpan<F extends (span: Span) => ReturnType<F>>(\n name: string,\n options: SugaredSpanOptions,\n fn: F\n ): ReturnType<F>;\n withSpan<F extends (span: Span) => ReturnType<F>>(\n name: string,\n options: SugaredSpanOptions,\n context: Context,\n fn: F\n ): ReturnType<F>;\n withSpan<F extends (span: Span) => ReturnType<F>>(\n name: string,\n options: SugaredSpanOptions,\n context: Context,\n fn: F\n ): ReturnType<F>;\n withSpan<F extends (span: Span) => ReturnType<F>>(\n name: string,\n arg2: SugaredSpanOptions | F,\n arg3?: Context | F,\n arg4?: F\n ): ReturnType<F> {\n const { opts, ctx, fn } = massageParams(arg2, arg3, arg4);\n\n const span = this._tracer.startSpan(name, opts, ctx);\n return handleFn(span, opts, fn) as ReturnType<F>;\n }\n}\n\n/**\n * Massages parameters of withSpan and withActiveSpan to allow signature overwrites\n * @param arg\n * @param arg2\n * @param arg3\n */\nfunction massageParams<F extends (span: Span) => ReturnType<F>>(\n arg: F | SugaredSpanOptions,\n arg2?: F | Context,\n arg3?: F\n) {\n let opts: SugaredSpanOptions | undefined;\n let ctx: Context | undefined;\n let fn: F;\n\n if (!arg2 && !arg3) {\n fn = arg as F;\n } else if (!arg3) {\n opts = arg as SugaredSpanOptions;\n fn = arg2 as F;\n } else {\n opts = arg as SugaredSpanOptions;\n ctx = arg2 as Context;\n fn = arg3 as F;\n }\n opts = opts ?? {};\n ctx = ctx ?? context.active();\n\n return { opts, ctx, fn };\n}\n\n/**\n * Executes fn, returns results and runs onException in the case of exception to allow overwriting of error handling\n * @param span\n * @param opts\n * @param fn\n */\nfunction handleFn<F extends (span: Span) => ReturnType<F>>(\n span: Span,\n opts: SugaredSpanOptions,\n fn: F\n): ReturnType<F> {\n const onException = opts.onException ?? defaultOnException;\n const errorHandler = (e: Error) => {\n onException(e, span);\n span.end();\n throw e;\n };\n\n try {\n const ret = fn(span) as Promise<ReturnType<F>>;\n // if fn is an async function, attach a recordException and spanEnd callback to the promise\n if (typeof ret?.then === 'function') {\n return ret.then(val => {\n span.end();\n return val;\n }, errorHandler) as ReturnType<F>;\n }\n span.end();\n return ret as ReturnType<F>;\n } catch (e) {\n // add throw to signal the compiler that this will throw in the inner scope\n throw errorHandler(e);\n }\n}\n"]}
|
package/build/esm/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type { DiagAPI } from './api/diag';
|
|
|
12
12
|
export { createNoopMeter } from './metrics/NoopMeter';
|
|
13
13
|
export { MeterOptions, Meter } from './metrics/Meter';
|
|
14
14
|
export { MeterProvider } from './metrics/MeterProvider';
|
|
15
|
-
export { ValueType, Counter, Histogram, MetricOptions, Observable, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter, BatchObservableCallback, MetricAdvice, MetricAttributes, MetricAttributeValue, ObservableCallback, } from './metrics/Metric';
|
|
15
|
+
export { ValueType, Counter, Gauge, Histogram, MetricOptions, Observable, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter, BatchObservableCallback, MetricAdvice, MetricAttributes, MetricAttributeValue, ObservableCallback, } from './metrics/Metric';
|
|
16
16
|
export { BatchObservableResult, ObservableResult, } from './metrics/ObservableResult';
|
|
17
17
|
export type { MetricsAPI } from './api/metrics';
|
|
18
18
|
export { TextMapPropagator, TextMapSetter, TextMapGetter, defaultTextMapGetter, defaultTextMapSetter, } from './propagation/TextMapPropagator';
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAKjE,eAAe;AACf,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAInE,YAAY;AACZ,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAGL,YAAY,GAGb,MAAM,cAAc,CAAC;AAGtB,eAAe;AACf,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EACL,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAKjE,eAAe;AACf,OAAO,EAAE,gB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,EAAE,CAAC;AACtD,kBAAkB;AAClB,eAAe;IACb,OAAO,SAAA;IACP,IAAI,MAAA;IACJ,OAAO,SAAA;IACP,WAAW,aAAA;IACX,KAAK,OAAA;CACN,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\nexport { BaggageEntry, BaggageEntryMetadata, Baggage } from './baggage/types';\nexport { baggageEntryMetadataFromString } from './baggage/utils';\nexport { Exception } from './common/Exception';\nexport { HrTime, TimeInput } from './common/Time';\nexport { Attributes, AttributeValue } from './common/Attributes';\n\n// Context APIs\nexport { createContextKey, ROOT_CONTEXT } from './context/context';\nexport { Context, ContextManager } from './context/types';\nexport type { ContextAPI } from './api/context';\n\n// Diag APIs\nexport { DiagConsoleLogger } from './diag/consoleLogger';\nexport {\n DiagLogFunction,\n DiagLogger,\n DiagLogLevel,\n ComponentLoggerOptions,\n DiagLoggerOptions,\n} from './diag/types';\nexport type { DiagAPI } from './api/diag';\n\n// Metrics APIs\nexport { createNoopMeter } from './metrics/NoopMeter';\nexport { MeterOptions, Meter } from './metrics/Meter';\nexport { MeterProvider } from './metrics/MeterProvider';\nexport {\n ValueType,\n Counter,\n Gauge,\n Histogram,\n MetricOptions,\n Observable,\n ObservableCounter,\n ObservableGauge,\n ObservableUpDownCounter,\n UpDownCounter,\n BatchObservableCallback,\n MetricAdvice,\n MetricAttributes,\n MetricAttributeValue,\n ObservableCallback,\n} from './metrics/Metric';\nexport {\n BatchObservableResult,\n ObservableResult,\n} from './metrics/ObservableResult';\nexport type { MetricsAPI } from './api/metrics';\n\n// Propagation APIs\nexport {\n TextMapPropagator,\n TextMapSetter,\n TextMapGetter,\n defaultTextMapGetter,\n defaultTextMapSetter,\n} from './propagation/TextMapPropagator';\nexport type { PropagationAPI } from './api/propagation';\n\n// Trace APIs\nexport { SpanAttributes, SpanAttributeValue } from './trace/attributes';\nexport { Link } from './trace/link';\nexport { ProxyTracer, TracerDelegator } from './trace/ProxyTracer';\nexport { ProxyTracerProvider } from './trace/ProxyTracerProvider';\nexport { Sampler } from './trace/Sampler';\nexport { SamplingDecision, SamplingResult } from './trace/SamplingResult';\nexport { SpanContext } from './trace/span_context';\nexport { SpanKind } from './trace/span_kind';\nexport { Span } from './trace/span';\nexport { SpanOptions } from './trace/SpanOptions';\nexport { SpanStatus, SpanStatusCode } from './trace/status';\nexport { TraceFlags } from './trace/trace_flags';\nexport { TraceState } from './trace/trace_state';\nexport { createTraceState } from './trace/internal/utils';\nexport { TracerProvider } from './trace/tracer_provider';\nexport { Tracer } from './trace/tracer';\nexport { TracerOptions } from './trace/tracer_options';\nexport {\n isSpanContextValid,\n isValidTraceId,\n isValidSpanId,\n} from './trace/spancontext-utils';\nexport {\n INVALID_SPANID,\n INVALID_TRACEID,\n INVALID_SPAN_CONTEXT,\n} from './trace/invalid-span-constants';\nexport type { TraceAPI } from './api/trace';\n\n// Split module-level variable definition into separate files to allow\n// tree-shaking on each api instance.\nimport { context } from './context-api';\nimport { diag } from './diag-api';\nimport { metrics } from './metrics-api';\nimport { propagation } from './propagation-api';\nimport { trace } from './trace-api';\n\n// Named export.\nexport { context, diag, metrics, propagation, trace };\n// Default export.\nexport default {\n context,\n diag,\n metrics,\n propagation,\n trace,\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BatchObservableCallback, Counter, Histogram, MetricAttributes, MetricOptions, Observable, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter } from './Metric';
|
|
1
|
+
import { BatchObservableCallback, Counter, Gauge, Histogram, MetricAttributes, MetricOptions, Observable, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter } from './Metric';
|
|
2
2
|
/**
|
|
3
3
|
* An interface describes additional metadata of a meter.
|
|
4
4
|
*/
|
|
@@ -16,6 +16,12 @@ export interface MeterOptions {
|
|
|
16
16
|
* for the exported metric are deferred.
|
|
17
17
|
*/
|
|
18
18
|
export interface Meter {
|
|
19
|
+
/**
|
|
20
|
+
* Creates and returns a new `Gauge`.
|
|
21
|
+
* @param name the name of the metric.
|
|
22
|
+
* @param [options] the metric options.
|
|
23
|
+
*/
|
|
24
|
+
createGauge<AttributesTypes extends MetricAttributes = MetricAttributes>(name: string, options?: MetricOptions): Gauge<AttributesTypes>;
|
|
19
25
|
/**
|
|
20
26
|
* Creates and returns a new `Histogram`.
|
|
21
27
|
* @param name the name of the metric.
|
|
@@ -1 +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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\n name: string,\n options?: MetricOptions\n ): 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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\n callback: BatchObservableCallback<AttributesTypes>,\n observables: Observable<AttributesTypes>[]\n ): void;\n}\n"]}
|
|
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 Gauge,\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 `Gauge`.\n * @param name the name of the metric.\n * @param [options] the metric options.\n */\n createGauge<AttributesTypes extends MetricAttributes = MetricAttributes>(\n name: string,\n options?: MetricOptions\n ): Gauge<AttributesTypes>;\n\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\n name: string,\n options?: MetricOptions\n ): 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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n >(\n callback: BatchObservableCallback<AttributesTypes>,\n observables: Observable<AttributesTypes>[]\n ): void;\n}\n"]}
|
|
@@ -69,6 +69,12 @@ export interface UpDownCounter<AttributesTypes extends MetricAttributes = Metric
|
|
|
69
69
|
*/
|
|
70
70
|
add(value: number, attributes?: AttributesTypes, context?: Context): void;
|
|
71
71
|
}
|
|
72
|
+
export interface Gauge<AttributesTypes extends MetricAttributes = MetricAttributes> {
|
|
73
|
+
/**
|
|
74
|
+
* Records a measurement.
|
|
75
|
+
*/
|
|
76
|
+
record(value: number, attributes?: AttributesTypes, context?: Context): void;
|
|
77
|
+
}
|
|
72
78
|
export interface Histogram<AttributesTypes extends MetricAttributes = MetricAttributes> {
|
|
73
79
|
/**
|
|
74
80
|
* Records a measurement. Value of the measurement must not be negative.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Metric.js","sourceRoot":"","sources":["../../../src/metrics/Metric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA+CH,gEAAgE;AAChE,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,uCAAG,CAAA;IACH,6CAAM,CAAA;AACR,CAAC,EAHW,SAAS,KAAT,SAAS,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 * Advisory options influencing aggregation configuration parameters.\n * @experimental\n */\nexport interface MetricAdvice {\n /**\n * Hint the explicit bucket boundaries for SDK if the metric is been\n * aggregated with a HistogramAggregator.\n */\n explicitBucketBoundaries?: number[];\n}\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 advice influencing aggregation configuration parameters.\n * @experimental\n */\n advice?: MetricAdvice;\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> {\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> {\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> {\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/**\n * @deprecated please use {@link Attributes}\n */\nexport type MetricAttributes = Attributes;\n\n/**\n * @deprecated please use {@link AttributeValue}\n */\nexport type MetricAttributeValue = AttributeValue;\n\n/**\n * The observable callback for Observable instruments.\n */\nexport type ObservableCallback<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> = (\n observableResult: ObservableResult<AttributesTypes>\n) => void | Promise<void>;\n\n/**\n * The observable callback for a batch of Observable instruments.\n */\nexport type BatchObservableCallback<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> = (\n observableResult: BatchObservableResult<AttributesTypes>\n) => void | Promise<void>;\n\nexport interface Observable<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> {\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> = Observable<AttributesTypes>;\nexport type ObservableUpDownCounter<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> = Observable<AttributesTypes>;\nexport type ObservableGauge<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> = Observable<AttributesTypes>;\n"]}
|
|
1
|
+
{"version":3,"file":"Metric.js","sourceRoot":"","sources":["../../../src/metrics/Metric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA+CH,gEAAgE;AAChE,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,uCAAG,CAAA;IACH,6CAAM,CAAA;AACR,CAAC,EAHW,SAAS,KAAT,SAAS,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 * Advisory options influencing aggregation configuration parameters.\n * @experimental\n */\nexport interface MetricAdvice {\n /**\n * Hint the explicit bucket boundaries for SDK if the metric is been\n * aggregated with a HistogramAggregator.\n */\n explicitBucketBoundaries?: number[];\n}\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 advice influencing aggregation configuration parameters.\n * @experimental\n */\n advice?: MetricAdvice;\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> {\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> {\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 Gauge<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> {\n /**\n * Records a measurement.\n */\n record(value: number, attributes?: AttributesTypes, context?: Context): void;\n}\n\nexport interface Histogram<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> {\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/**\n * @deprecated please use {@link Attributes}\n */\nexport type MetricAttributes = Attributes;\n\n/**\n * @deprecated please use {@link AttributeValue}\n */\nexport type MetricAttributeValue = AttributeValue;\n\n/**\n * The observable callback for Observable instruments.\n */\nexport type ObservableCallback<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> = (\n observableResult: ObservableResult<AttributesTypes>\n) => void | Promise<void>;\n\n/**\n * The observable callback for a batch of Observable instruments.\n */\nexport type BatchObservableCallback<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> = (\n observableResult: BatchObservableResult<AttributesTypes>\n) => void | Promise<void>;\n\nexport interface Observable<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> {\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<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> = Observable<AttributesTypes>;\nexport type ObservableUpDownCounter<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> = Observable<AttributesTypes>;\nexport type ObservableGauge<\n AttributesTypes extends MetricAttributes = MetricAttributes,\n> = Observable<AttributesTypes>;\n"]}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Meter } from './Meter';
|
|
2
|
-
import { BatchObservableCallback, Counter, Histogram, MetricOptions, ObservableCallback, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter
|
|
2
|
+
import { BatchObservableCallback, Counter, Gauge, Histogram, MetricAttributes, MetricOptions, Observable, ObservableCallback, ObservableCounter, ObservableGauge, ObservableUpDownCounter, UpDownCounter } from './Metric';
|
|
3
3
|
/**
|
|
4
4
|
* NoopMeter is a noop implementation of the {@link Meter} interface. It reuses
|
|
5
5
|
* constant NoopMetrics for all of its methods.
|
|
6
6
|
*/
|
|
7
7
|
export declare class NoopMeter implements Meter {
|
|
8
8
|
constructor();
|
|
9
|
+
/**
|
|
10
|
+
* @see {@link Meter.createGauge}
|
|
11
|
+
*/
|
|
12
|
+
createGauge(_name: string, _options?: MetricOptions): Gauge;
|
|
9
13
|
/**
|
|
10
14
|
* @see {@link Meter.createHistogram}
|
|
11
15
|
*/
|
|
@@ -47,6 +51,9 @@ export declare class NoopCounterMetric extends NoopMetric implements Counter {
|
|
|
47
51
|
export declare class NoopUpDownCounterMetric extends NoopMetric implements UpDownCounter {
|
|
48
52
|
add(_value: number, _attributes: MetricAttributes): void;
|
|
49
53
|
}
|
|
54
|
+
export declare class NoopGaugeMetric extends NoopMetric implements Gauge {
|
|
55
|
+
record(_value: number, _attributes: MetricAttributes): void;
|
|
56
|
+
}
|
|
50
57
|
export declare class NoopHistogramMetric extends NoopMetric implements Histogram {
|
|
51
58
|
record(_value: number, _attributes: MetricAttributes): void;
|
|
52
59
|
}
|
|
@@ -62,6 +69,7 @@ export declare class NoopObservableUpDownCounterMetric extends NoopObservableMet
|
|
|
62
69
|
}
|
|
63
70
|
export declare const NOOP_METER: NoopMeter;
|
|
64
71
|
export declare const NOOP_COUNTER_METRIC: NoopCounterMetric;
|
|
72
|
+
export declare const NOOP_GAUGE_METRIC: NoopGaugeMetric;
|
|
65
73
|
export declare const NOOP_HISTOGRAM_METRIC: NoopHistogramMetric;
|
|
66
74
|
export declare const NOOP_UP_DOWN_COUNTER_METRIC: NoopUpDownCounterMetric;
|
|
67
75
|
export declare const NOOP_OBSERVABLE_COUNTER_METRIC: NoopObservableCounterMetric;
|
|
@@ -35,6 +35,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
35
35
|
var NoopMeter = /** @class */ (function () {
|
|
36
36
|
function NoopMeter() {
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* @see {@link Meter.createGauge}
|
|
40
|
+
*/
|
|
41
|
+
NoopMeter.prototype.createGauge = function (_name, _options) {
|
|
42
|
+
return NOOP_GAUGE_METRIC;
|
|
43
|
+
};
|
|
38
44
|
/**
|
|
39
45
|
* @see {@link Meter.createHistogram}
|
|
40
46
|
*/
|
|
@@ -106,6 +112,15 @@ var NoopUpDownCounterMetric = /** @class */ (function (_super) {
|
|
|
106
112
|
return NoopUpDownCounterMetric;
|
|
107
113
|
}(NoopMetric));
|
|
108
114
|
export { NoopUpDownCounterMetric };
|
|
115
|
+
var NoopGaugeMetric = /** @class */ (function (_super) {
|
|
116
|
+
__extends(NoopGaugeMetric, _super);
|
|
117
|
+
function NoopGaugeMetric() {
|
|
118
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
119
|
+
}
|
|
120
|
+
NoopGaugeMetric.prototype.record = function (_value, _attributes) { };
|
|
121
|
+
return NoopGaugeMetric;
|
|
122
|
+
}(NoopMetric));
|
|
123
|
+
export { NoopGaugeMetric };
|
|
109
124
|
var NoopHistogramMetric = /** @class */ (function (_super) {
|
|
110
125
|
__extends(NoopHistogramMetric, _super);
|
|
111
126
|
function NoopHistogramMetric() {
|
|
@@ -150,6 +165,7 @@ export { NoopObservableUpDownCounterMetric };
|
|
|
150
165
|
export var NOOP_METER = new NoopMeter();
|
|
151
166
|
// Synchronous instruments
|
|
152
167
|
export var NOOP_COUNTER_METRIC = new NoopCounterMetric();
|
|
168
|
+
export var NOOP_GAUGE_METRIC = new NoopGaugeMetric();
|
|
153
169
|
export var NOOP_HISTOGRAM_METRIC = new NoopHistogramMetric();
|
|
154
170
|
export var NOOP_UP_DOWN_COUNTER_METRIC = new NoopUpDownCounterMetric();
|
|
155
171
|
// Asynchronous instruments
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoopMeter.js","sourceRoot":"","sources":["../../../src/metrics/NoopMeter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"NoopMeter.js","sourceRoot":"","sources":["../../../src/metrics/NoopMeter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAkBH;;;GAGG;AACH;IACE;IAAe,CAAC;IAEh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C;AAE1C;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,UAAU,CAAC;AACpB,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 { Meter } from './Meter';\nimport {\n BatchObservableCallback,\n Counter,\n Gauge,\n Histogram,\n MetricAttributes,\n MetricOptions,\n Observable,\n ObservableCallback,\n ObservableCounter,\n ObservableGauge,\n ObservableUpDownCounter,\n UpDownCounter,\n} from './Metric';\n\n/**\n * NoopMeter is a noop implementation of the {@link Meter} interface. It reuses\n * constant NoopMetrics for all of its methods.\n */\nexport class NoopMeter implements Meter {\n constructor() {}\n\n /**\n * @see {@link Meter.createGauge}\n */\n createGauge(_name: string, _options?: MetricOptions): Gauge {\n return NOOP_GAUGE_METRIC;\n }\n\n /**\n * @see {@link Meter.createHistogram}\n */\n createHistogram(_name: string, _options?: MetricOptions): Histogram {\n return NOOP_HISTOGRAM_METRIC;\n }\n\n /**\n * @see {@link Meter.createCounter}\n */\n createCounter(_name: string, _options?: MetricOptions): Counter {\n return NOOP_COUNTER_METRIC;\n }\n\n /**\n * @see {@link Meter.createUpDownCounter}\n */\n createUpDownCounter(_name: string, _options?: MetricOptions): UpDownCounter {\n return NOOP_UP_DOWN_COUNTER_METRIC;\n }\n\n /**\n * @see {@link Meter.createObservableGauge}\n */\n createObservableGauge(\n _name: string,\n _options?: MetricOptions\n ): ObservableGauge {\n return NOOP_OBSERVABLE_GAUGE_METRIC;\n }\n\n /**\n * @see {@link Meter.createObservableCounter}\n */\n createObservableCounter(\n _name: string,\n _options?: MetricOptions\n ): ObservableCounter {\n return NOOP_OBSERVABLE_COUNTER_METRIC;\n }\n\n /**\n * @see {@link Meter.createObservableUpDownCounter}\n */\n createObservableUpDownCounter(\n _name: string,\n _options?: MetricOptions\n ): ObservableUpDownCounter {\n return NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC;\n }\n\n /**\n * @see {@link Meter.addBatchObservableCallback}\n */\n addBatchObservableCallback(\n _callback: BatchObservableCallback,\n _observables: Observable[]\n ): void {}\n\n /**\n * @see {@link Meter.removeBatchObservableCallback}\n */\n removeBatchObservableCallback(_callback: BatchObservableCallback): void {}\n}\n\nexport class NoopMetric {}\n\nexport class NoopCounterMetric extends NoopMetric implements Counter {\n add(_value: number, _attributes: MetricAttributes): void {}\n}\n\nexport class NoopUpDownCounterMetric\n extends NoopMetric\n implements UpDownCounter\n{\n add(_value: number, _attributes: MetricAttributes): void {}\n}\n\nexport class NoopGaugeMetric extends NoopMetric implements Gauge {\n record(_value: number, _attributes: MetricAttributes): void {}\n}\n\nexport class NoopHistogramMetric extends NoopMetric implements Histogram {\n record(_value: number, _attributes: MetricAttributes): void {}\n}\n\nexport class NoopObservableMetric {\n addCallback(_callback: ObservableCallback) {}\n\n removeCallback(_callback: ObservableCallback) {}\n}\n\nexport class NoopObservableCounterMetric\n extends NoopObservableMetric\n implements ObservableCounter {}\n\nexport class NoopObservableGaugeMetric\n extends NoopObservableMetric\n implements ObservableGauge {}\n\nexport class NoopObservableUpDownCounterMetric\n extends NoopObservableMetric\n implements ObservableUpDownCounter {}\n\nexport const NOOP_METER = new NoopMeter();\n\n// Synchronous instruments\nexport const NOOP_COUNTER_METRIC = new NoopCounterMetric();\nexport const NOOP_GAUGE_METRIC = new NoopGaugeMetric();\nexport const NOOP_HISTOGRAM_METRIC = new NoopHistogramMetric();\nexport const NOOP_UP_DOWN_COUNTER_METRIC = new NoopUpDownCounterMetric();\n\n// Asynchronous instruments\nexport const NOOP_OBSERVABLE_COUNTER_METRIC = new NoopObservableCounterMetric();\nexport const NOOP_OBSERVABLE_GAUGE_METRIC = new NoopObservableGaugeMetric();\nexport const NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC =\n new NoopObservableUpDownCounterMetric();\n\n/**\n * Create a no-op Meter\n */\nexport function createNoopMeter(): Meter {\n return NOOP_METER;\n}\n"]}
|
|
@@ -4,6 +4,7 @@ import { SpanAttributes } from './attributes';
|
|
|
4
4
|
import { Span } from './span';
|
|
5
5
|
import { SpanContext } from './span_context';
|
|
6
6
|
import { SpanStatus } from './status';
|
|
7
|
+
import { Link } from './link';
|
|
7
8
|
/**
|
|
8
9
|
* The NonRecordingSpan is the default {@link Span} that is used when no Span
|
|
9
10
|
* implementation is available. All operations are no-op including context
|
|
@@ -16,6 +17,8 @@ export declare class NonRecordingSpan implements Span {
|
|
|
16
17
|
setAttribute(_key: string, _value: unknown): this;
|
|
17
18
|
setAttributes(_attributes: SpanAttributes): this;
|
|
18
19
|
addEvent(_name: string, _attributes?: SpanAttributes): this;
|
|
20
|
+
addLink(_link: Link): this;
|
|
21
|
+
addLinks(_links: Link[]): this;
|
|
19
22
|
setStatus(_status: SpanStatus): this;
|
|
20
23
|
updateName(_name: string): this;
|
|
21
24
|
end(_endTime?: TimeInput): void;
|
|
@@ -40,6 +40,12 @@ var NonRecordingSpan = /** @class */ (function () {
|
|
|
40
40
|
NonRecordingSpan.prototype.addEvent = function (_name, _attributes) {
|
|
41
41
|
return this;
|
|
42
42
|
};
|
|
43
|
+
NonRecordingSpan.prototype.addLink = function (_link) {
|
|
44
|
+
return this;
|
|
45
|
+
};
|
|
46
|
+
NonRecordingSpan.prototype.addLinks = function (_links) {
|
|
47
|
+
return this;
|
|
48
|
+
};
|
|
43
49
|
// By default does nothing
|
|
44
50
|
NonRecordingSpan.prototype.setStatus = function (_status) {
|
|
45
51
|
return this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NonRecordingSpan.js","sourceRoot":"","sources":["../../../src/trace/NonRecordingSpan.ts"],"names":[],"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E,uBAAC;AAAD,CAAC,AArDD,IAqDC","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 { Exception } from '../common/Exception';\nimport { TimeInput } from '../common/Time';\nimport { SpanAttributes } from './attributes';\nimport { INVALID_SPAN_CONTEXT } from './invalid-span-constants';\nimport { Span } from './span';\nimport { SpanContext } from './span_context';\nimport { SpanStatus } from './status';\nimport { Link } from './link';\n\n/**\n * The NonRecordingSpan is the default {@link Span} that is used when no Span\n * implementation is available. All operations are no-op including context\n * propagation.\n */\nexport class NonRecordingSpan implements Span {\n constructor(\n private readonly _spanContext: SpanContext = INVALID_SPAN_CONTEXT\n ) {}\n\n // Returns a SpanContext.\n spanContext(): SpanContext {\n return this._spanContext;\n }\n\n // By default does nothing\n setAttribute(_key: string, _value: unknown): this {\n return this;\n }\n\n // By default does nothing\n setAttributes(_attributes: SpanAttributes): this {\n return this;\n }\n\n // By default does nothing\n addEvent(_name: string, _attributes?: SpanAttributes): this {\n return this;\n }\n\n addLink(_link: Link): this {\n return this;\n }\n\n addLinks(_links: Link[]): this {\n return this;\n }\n\n // By default does nothing\n setStatus(_status: SpanStatus): this {\n return this;\n }\n\n // By default does nothing\n updateName(_name: string): this {\n return this;\n }\n\n // By default does nothing\n end(_endTime?: TimeInput): void {}\n\n // isRecording always returns false for NonRecordingSpan.\n isRecording(): boolean {\n return false;\n }\n\n // By default does nothing\n recordException(_exception: Exception, _time?: TimeInput): void {}\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import { TimeInput } from '../common/Time';
|
|
|
3
3
|
import { SpanAttributes, SpanAttributeValue } from './attributes';
|
|
4
4
|
import { SpanContext } from './span_context';
|
|
5
5
|
import { SpanStatus } from './status';
|
|
6
|
+
import { Link } from './link';
|
|
6
7
|
/**
|
|
7
8
|
* An interface that represents a span. A span represents a single operation
|
|
8
9
|
* within a trace. Examples of span might include remote procedure calls or a
|
|
@@ -51,6 +52,24 @@ export interface Span {
|
|
|
51
52
|
* @param [startTime] start time of the event.
|
|
52
53
|
*/
|
|
53
54
|
addEvent(name: string, attributesOrStartTime?: SpanAttributes | TimeInput, startTime?: TimeInput): this;
|
|
55
|
+
/**
|
|
56
|
+
* Adds a single link to the span.
|
|
57
|
+
*
|
|
58
|
+
* Links added after the creation will not affect the sampling decision.
|
|
59
|
+
* It is preferred span links be added at span creation.
|
|
60
|
+
*
|
|
61
|
+
* @param link the link to add.
|
|
62
|
+
*/
|
|
63
|
+
addLink(link: Link): this;
|
|
64
|
+
/**
|
|
65
|
+
* Adds multiple links to the span.
|
|
66
|
+
*
|
|
67
|
+
* Links added after the creation will not affect the sampling decision.
|
|
68
|
+
* It is preferred span links be added at span creation.
|
|
69
|
+
*
|
|
70
|
+
* @param links the links to add.
|
|
71
|
+
*/
|
|
72
|
+
addLinks(links: Link[]): this;
|
|
54
73
|
/**
|
|
55
74
|
* Sets a status to the span. If used, this will override the default Span
|
|
56
75
|
* status. Default is {@link SpanStatusCode.UNSET}. SetStatus overrides the value
|