@codefresh-io/cf-telemetry 2.2.0-alpha.4 → 2.2.0-alpha.7

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.
@@ -5,9 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
8
  Object.defineProperty(exports, "__esModule", { value: true });
12
9
  exports.Logger = void 0;
13
10
  const common_1 = require("@nestjs/common");
@@ -26,7 +23,6 @@ let Logger = class Logger extends logger_1.Logger {
26
23
  };
27
24
  exports.Logger = Logger;
28
25
  exports.Logger = Logger = __decorate([
29
- (0, common_1.Injectable)({ scope: common_1.Scope.TRANSIENT }),
30
- __metadata("design:paramtypes", [Object])
26
+ (0, common_1.Injectable)({ scope: common_1.Scope.TRANSIENT })
31
27
  ], Logger);
32
28
  //# sourceMappingURL=logger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/logs/nest/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAmD;AACnD,sCAAiD;AAG1C,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,eAAU;IACpC,YAAY,GAAG,MAAgD;QAC7D,IAAI,OAAO,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;QACpD,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF,CAAA;AAVY,wBAAM;iBAAN,MAAM;IADlB,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,SAAS,EAAE,CAAC;;GAC1B,MAAM,CAUlB"}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/logs/nest/logger.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAmD;AACnD,sCAAiD;AAG1C,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,eAAU;IACpC,YAAY,GAAG,MAAgD;QAC7D,IAAI,OAAO,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;QACpD,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF,CAAA;AAVY,wBAAM;iBAAN,MAAM;IADlB,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,SAAS,EAAE,CAAC;GAC1B,MAAM,CAUlB"}
@@ -7,8 +7,10 @@ import { api } from '@opentelemetry/sdk-node';
7
7
  **/
8
8
  export declare const getTracer: () => api.Tracer;
9
9
  /**
10
- * Decorator wraps a method in an active span.
11
- * The span name is set to the method name and the class name.
12
- * The span kind is set to INTERNAL.
10
+ * Decorator wraps a class method in an active span.
11
+ *
12
+ * The span name is set to the `<ClassName> <methodName>`.
13
+ *
14
+ * @param kind {@link api.SpanKind|SpanKind}. Default is `SpanKind.INTERNAL`.
13
15
  */
14
- export declare const Span: (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<(...args: any[]) => any>) => TypedPropertyDescriptor<(...args: any[]) => any>;
16
+ export declare const Span: (kind?: api.SpanKind) => (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<(...args: any[]) => any>) => TypedPropertyDescriptor<(...args: any[]) => any>;
@@ -14,68 +14,72 @@ const getTracer = () => {
14
14
  };
15
15
  exports.getTracer = getTracer;
16
16
  /**
17
- * Decorator wraps a method in an active span.
18
- * The span name is set to the method name and the class name.
19
- * The span kind is set to INTERNAL.
17
+ * Decorator wraps a class method in an active span.
18
+ *
19
+ * The span name is set to the `<ClassName> <methodName>`.
20
+ *
21
+ * @param kind {@link api.SpanKind|SpanKind}. Default is `SpanKind.INTERNAL`.
20
22
  */
21
- // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types, @typescript-eslint/no-explicit-any
22
- const Span = (target, propertyKey, descriptor) => {
23
- const originalMethod = descriptor.value;
24
- descriptor.value = function (...args) {
25
- return (0, exports.getTracer)().startActiveSpan(`${target.constructor.name} ${String(propertyKey)}`, { kind: sdk_node_1.api.SpanKind.INTERNAL }, (span) => {
26
- try {
27
- const result = originalMethod.apply(target, args);
28
- /**
29
- * It is crucial to check for thenables instead of Promises,
30
- * because multiple libs (like mongoose) use a custom Promise implementation.
31
- */
32
- if (typeof result?.then === 'function') {
33
- return result
34
- .then((res) => {
35
- // Async success handling
36
- span.setStatus({ code: sdk_node_1.api.SpanStatusCode.OK });
37
- span.end();
38
- return res;
39
- })
40
- .catch((exception) => {
41
- // Async error handling
42
- if (exception instanceof Error) {
43
- span.recordException(exception);
44
- span.setStatus({
45
- code: sdk_node_1.api.SpanStatusCode.ERROR,
46
- message: exception.message,
47
- });
48
- }
49
- else {
50
- span.setStatus({ code: sdk_node_1.api.SpanStatusCode.ERROR });
51
- }
52
- span.end();
53
- throw exception;
54
- });
55
- }
56
- // Sync success handling
57
- span.setStatus({ code: sdk_node_1.api.SpanStatusCode.OK });
58
- span.end();
59
- return result;
60
- }
61
- catch (exception) {
62
- // Sync error handling
63
- if (exception instanceof Error) {
64
- span.recordException(exception);
65
- span.setStatus({
66
- code: sdk_node_1.api.SpanStatusCode.ERROR,
67
- message: exception.message,
68
- });
23
+ const Span = (kind = sdk_node_1.api.SpanKind.INTERNAL) => {
24
+ // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types, @typescript-eslint/no-explicit-any
25
+ return (target, propertyKey, descriptor) => {
26
+ const originalMethod = descriptor.value;
27
+ descriptor.value = function (...args) {
28
+ return (0, exports.getTracer)().startActiveSpan(`${target.constructor.name} ${String(propertyKey)}`, { kind }, (span) => {
29
+ try {
30
+ const result = originalMethod.apply(this, args);
31
+ /**
32
+ * It is crucial to check for thenables instead of Promises,
33
+ * because multiple libs (like mongoose) use a custom Promise implementation.
34
+ */
35
+ if (typeof result?.then === 'function') {
36
+ return result
37
+ .then((res) => {
38
+ // Async success handling
39
+ span.setStatus({ code: sdk_node_1.api.SpanStatusCode.OK });
40
+ span.end();
41
+ return res;
42
+ })
43
+ .catch((exception) => {
44
+ // Async error handling
45
+ if (exception instanceof Error) {
46
+ span.recordException(exception);
47
+ span.setStatus({
48
+ code: sdk_node_1.api.SpanStatusCode.ERROR,
49
+ message: exception.message,
50
+ });
51
+ }
52
+ else {
53
+ span.setStatus({ code: sdk_node_1.api.SpanStatusCode.ERROR });
54
+ }
55
+ span.end();
56
+ throw exception;
57
+ });
58
+ }
59
+ // Sync success handling
60
+ span.setStatus({ code: sdk_node_1.api.SpanStatusCode.OK });
61
+ span.end();
62
+ return result;
69
63
  }
70
- else {
71
- span.setStatus({ code: sdk_node_1.api.SpanStatusCode.ERROR });
64
+ catch (exception) {
65
+ // Sync error handling
66
+ if (exception instanceof Error) {
67
+ span.recordException(exception);
68
+ span.setStatus({
69
+ code: sdk_node_1.api.SpanStatusCode.ERROR,
70
+ message: exception.message,
71
+ });
72
+ }
73
+ else {
74
+ span.setStatus({ code: sdk_node_1.api.SpanStatusCode.ERROR });
75
+ }
76
+ span.end();
77
+ throw exception;
72
78
  }
73
- span.end();
74
- throw exception;
75
- }
76
- });
79
+ });
80
+ };
81
+ return descriptor;
77
82
  };
78
- return descriptor;
79
83
  };
80
84
  exports.Span = Span;
81
85
  //# sourceMappingURL=cf-helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cf-helpers.js","sourceRoot":"","sources":["../../src/otel/cf-helpers.ts"],"names":[],"mappings":";;;AAAA,sDAA8C;AAC9C,oDAAgD;AAEhD;;;;;IAKI;AACG,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,OAAO,cAAG,CAAC,KAAK,CAAC,SAAS,CAAC,4BAAY,CAAC,WAAW,EAAE,4BAAY,CAAC,cAAc,CAAC,CAAC;AACpF,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB;AAEF;;;;GAIG;AACH,0GAA0G;AACnG,MAAM,IAAI,GAAG,CAAC,MAAc,EAAE,WAA4B,EAAE,UAA4D,EAAE,EAAE;IACjI,MAAM,cAAc,GAAG,UAAU,CAAC,KAAM,CAAC;IACzC,UAAU,CAAC,KAAK,GAAG,UAAU,GAAG,IAAe;QAC7C,OAAO,IAAA,iBAAS,GAAE,CAAC,eAAe,CAChC,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,EACnD,EAAE,IAAI,EAAE,cAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAC/B,CAAC,IAAI,EAAE,EAAE;YACP,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAClD;;;mBAGG;gBACH,IAAI,OAAO,MAAM,EAAE,IAAI,KAAK,UAAU,EAAE,CAAC;oBACvC,OAAO,MAAM;yBACV,IAAI,CAAC,CAAC,GAAY,EAAE,EAAE;wBACrB,yBAAyB;wBACzB,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,cAAG,CAAC,cAAc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KAAK,EAAE,CAAC,CAAC;oBACrD,CAAC;oBACD,IAAI,CAAC,GAAG,EAAE,CAAC;oBACX,MAAM,SAAS,CAAC;gBAClB,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC,CAAC;AA7DW,QAAA,IAAI,QA6Df"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codefresh-io/cf-telemetry",
3
- "version": "2.2.0-alpha.4",
3
+ "version": "2.2.0-alpha.7",
4
4
  "exports": {
5
5
  "./init": {
6
6
  "import": "./dist/init.mjs",