@codefresh-io/cf-telemetry 2.2.0-alpha.10 → 2.2.0-alpha.11
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.
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { api } from '@opentelemetry/sdk-node';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator wraps a class method in an active span. Both sync and async methods are supported.
|
|
4
|
+
*
|
|
4
5
|
* If an error is thrown by decorated method, span status is set to `ERROR`
|
|
5
6
|
* and the exception is recorded to span events.
|
|
6
7
|
*
|
|
7
|
-
* The span
|
|
8
|
-
*
|
|
9
|
-
* @param kind {@link api.SpanKind|SpanKind}. Default is `SpanKind.INTERNAL`.
|
|
8
|
+
* @param name The name of the span. If not provided, defaults to `<ClassName>.<methodName>`.
|
|
9
|
+
* @param options {@link api.SpanOptions|SpanOptions} used for span creation.
|
|
10
10
|
*/
|
|
11
|
-
export declare const Span: (
|
|
11
|
+
export declare const Span: (name?: string, options?: api.SpanOptions) => (_target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<(...args: any[]) => any>) => TypedPropertyDescriptor<(...args: any[]) => any>;
|
|
@@ -5,19 +5,19 @@ const sdk_node_1 = require("@opentelemetry/sdk-node");
|
|
|
5
5
|
const helpers_1 = require("./helpers");
|
|
6
6
|
/**
|
|
7
7
|
* Decorator wraps a class method in an active span. Both sync and async methods are supported.
|
|
8
|
+
*
|
|
8
9
|
* If an error is thrown by decorated method, span status is set to `ERROR`
|
|
9
10
|
* and the exception is recorded to span events.
|
|
10
11
|
*
|
|
11
|
-
* The span
|
|
12
|
-
*
|
|
13
|
-
* @param kind {@link api.SpanKind|SpanKind}. Default is `SpanKind.INTERNAL`.
|
|
12
|
+
* @param name The name of the span. If not provided, defaults to `<ClassName>.<methodName>`.
|
|
13
|
+
* @param options {@link api.SpanOptions|SpanOptions} used for span creation.
|
|
14
14
|
*/
|
|
15
|
-
const Span = (
|
|
15
|
+
const Span = (name, options) => {
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types, @typescript-eslint/no-explicit-any
|
|
17
|
-
return (
|
|
17
|
+
return (_target, propertyKey, descriptor) => {
|
|
18
18
|
const originalMethod = descriptor.value;
|
|
19
19
|
descriptor.value = function (...args) {
|
|
20
|
-
return (0, helpers_1.getTracer)().startActiveSpan(`${
|
|
20
|
+
return (0, helpers_1.getTracer)().startActiveSpan(name ?? `${this.constructor.name}.${String(propertyKey)}`, options ?? {}, (span) => {
|
|
21
21
|
try {
|
|
22
22
|
const result = originalMethod.apply(this, args);
|
|
23
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"span.decorator.js","sourceRoot":"","sources":["../../../src/otel/cf/span.decorator.ts"],"names":[],"mappings":";;;AAAA,sDAA8C;AAC9C,uCAAsC;AAEtC;;;;;;;;GAQG;AACI,MAAM,IAAI,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"span.decorator.js","sourceRoot":"","sources":["../../../src/otel/cf/span.decorator.ts"],"names":[],"mappings":";;;AAAA,sDAA8C;AAC9C,uCAAsC;AAEtC;;;;;;;;GAQG;AACI,MAAM,IAAI,GAAG,CAAC,IAAa,EAAE,OAAyB,EAAE,EAAE;IAC/D,0GAA0G;IAC1G,OAAO,CAAC,OAAe,EAAE,WAA4B,EAAE,UAA4D,EAAE,EAAE;QACrH,MAAM,cAAc,GAAG,UAAU,CAAC,KAAM,CAAC;QACzC,UAAU,CAAC,KAAK,GAAG,UAAU,GAAG,IAAe;YAC7C,OAAO,IAAA,mBAAS,GAAE,CAAC,eAAe,CAChC,IAAI,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,EACzD,OAAO,IAAI,EAAE,EACb,CAAC,IAAI,EAAE,EAAE;gBACP,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC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