@coast/service-common-nest 1.0.70 → 1.0.75
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/dist/lib/logger/LogMethod.d.ts +2 -1
- package/dist/lib/logger/LogMethod.js +21 -8
- package/dist/lib/logger/LogMethod.js.map +1 -1
- package/dist/lib/logger/LogMethodOptions.d.ts +4 -0
- package/dist/lib/logger/LogMethodOptions.js +3 -0
- package/dist/lib/logger/LogMethodOptions.js.map +1 -0
- package/dist/lib/logger/test/TestLoggedMethods.d.ts +8 -0
- package/dist/lib/logger/test/TestLoggedMethods.js +76 -0
- package/dist/lib/logger/test/TestLoggedMethods.js.map +1 -1
- package/dist/lib/metrics/CoastMetrics.d.ts +14 -0
- package/dist/lib/metrics/CoastMetrics.js +37 -0
- package/dist/lib/metrics/CoastMetrics.js.map +1 -0
- package/dist/lib/metrics/CoastMetricsModule.d.ts +2 -0
- package/dist/lib/metrics/CoastMetricsModule.js +22 -0
- package/dist/lib/metrics/CoastMetricsModule.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -3
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { LogMethodOptions } from './LogMethodOptions';
|
|
2
|
+
export declare function LogMethod(options?: LogMethodOptions): MethodDecorator;
|
|
@@ -9,7 +9,8 @@ const SensitiveSymbol_1 = require("@coast/service-common/logger/redaction/Sensit
|
|
|
9
9
|
const common_1 = require("@nestjs/common");
|
|
10
10
|
const lodash_1 = __importDefault(require("lodash"));
|
|
11
11
|
const Constants_1 = require("../Constants");
|
|
12
|
-
function LogMethod() {
|
|
12
|
+
function LogMethod(options) {
|
|
13
|
+
const extraLogFields = options?.extraLogFields;
|
|
13
14
|
const injectLogger = (0, common_1.Inject)(Constants_1.Constants.COAST_LOGGER);
|
|
14
15
|
return (target, method, descriptor) => {
|
|
15
16
|
if (descriptor === undefined) {
|
|
@@ -22,6 +23,7 @@ function LogMethod() {
|
|
|
22
23
|
const coastLogger = this.logger;
|
|
23
24
|
const className = target.constructor?.name;
|
|
24
25
|
let callSucceeded = true;
|
|
26
|
+
let capturedError;
|
|
25
27
|
const sensitiveParameters = Reflect.getOwnMetadata(SensitiveSymbol_1.SENSITIVE, target, method);
|
|
26
28
|
const indexesToSkip = new Set([]);
|
|
27
29
|
if (sensitiveParameters) {
|
|
@@ -39,7 +41,7 @@ function LogMethod() {
|
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
|
-
logMethodStart(className, method.toString(), coastLogger, loggableArguments);
|
|
44
|
+
logMethodStart(className, method.toString(), coastLogger, loggableArguments, extraLogFields);
|
|
43
45
|
const startTime = process.hrtime.bigint();
|
|
44
46
|
try {
|
|
45
47
|
const result = originalMethod.apply(this, arguments);
|
|
@@ -47,16 +49,18 @@ function LogMethod() {
|
|
|
47
49
|
return (result
|
|
48
50
|
.catch((e) => {
|
|
49
51
|
callSucceeded = false;
|
|
52
|
+
capturedError = e;
|
|
50
53
|
throw e;
|
|
51
54
|
})
|
|
52
|
-
.finally(() => logMethodResult(className, method, callSucceeded, startTime, coastLogger)));
|
|
55
|
+
.finally(() => logMethodResult(className, method, callSucceeded, startTime, coastLogger, extraLogFields, capturedError)));
|
|
53
56
|
}
|
|
54
|
-
logMethodResult(className, method, callSucceeded, startTime, coastLogger);
|
|
57
|
+
logMethodResult(className, method, callSucceeded, startTime, coastLogger, extraLogFields, capturedError);
|
|
55
58
|
return result;
|
|
56
59
|
}
|
|
57
60
|
catch (e) {
|
|
58
61
|
callSucceeded = false;
|
|
59
|
-
|
|
62
|
+
capturedError = e;
|
|
63
|
+
logMethodResult(className, method, callSucceeded, startTime, coastLogger, extraLogFields, capturedError);
|
|
60
64
|
throw e;
|
|
61
65
|
}
|
|
62
66
|
};
|
|
@@ -64,7 +68,7 @@ function LogMethod() {
|
|
|
64
68
|
return descriptor;
|
|
65
69
|
};
|
|
66
70
|
}
|
|
67
|
-
function logMethodStart(className, methodName, coastLogger, loggableArguments) {
|
|
71
|
+
function logMethodStart(className, methodName, coastLogger, loggableArguments, extraLogFields) {
|
|
68
72
|
const loggableArgs = loggableArguments
|
|
69
73
|
.map(({ value, redaction }) => {
|
|
70
74
|
if (typeof redaction === 'object') {
|
|
@@ -78,13 +82,22 @@ function logMethodStart(className, methodName, coastLogger, loggableArguments) {
|
|
|
78
82
|
})
|
|
79
83
|
.join(', ');
|
|
80
84
|
coastLogger?.log({
|
|
85
|
+
...extraLogFields,
|
|
81
86
|
method: `${className}.${methodName.toString()}`,
|
|
82
87
|
msg: `Method start: ${className}.${methodName.toString()}(${loggableArgs})`,
|
|
83
88
|
});
|
|
84
89
|
}
|
|
85
|
-
function logMethodResult(className, methodName, callSucceeded, startTime, coastLogger) {
|
|
90
|
+
function logMethodResult(className, methodName, callSucceeded, startTime, coastLogger, extraLogFields, error) {
|
|
86
91
|
const endTime = process.hrtime.bigint();
|
|
87
92
|
const latencyMs = Number(endTime - startTime) / 1_000_000;
|
|
88
|
-
|
|
93
|
+
const errorFields = error instanceof Error ? { errorClass: error.constructor.name } : undefined;
|
|
94
|
+
coastLogger?.log({
|
|
95
|
+
...extraLogFields,
|
|
96
|
+
method: `${className}.${methodName.toString()}`,
|
|
97
|
+
callSucceeded,
|
|
98
|
+
latencyMs,
|
|
99
|
+
...errorFields,
|
|
100
|
+
msg: 'Method ended',
|
|
101
|
+
});
|
|
89
102
|
}
|
|
90
103
|
//# sourceMappingURL=LogMethod.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogMethod.js","sourceRoot":"","sources":["../../../lib/logger/LogMethod.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"LogMethod.js","sourceRoot":"","sources":["../../../lib/logger/LogMethod.ts"],"names":[],"mappings":";;;;;AAiBA,8BAgGC;AA5GD,0FAAuF;AACvF,4FAAmF;AACnF,2CAAwC;AACxC,oDAAuB;AAEvB,4CAAyC;AAOzC,SAAgB,SAAS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AC;AAED,SAAS,eAAe,CACpB,SAAiB,EACjB,UAA2B,EAC3B,aAAsB,EACtB,SAAiB,EACjB,WAAoC,EACpC,cAA8B,EAC9B,KAAc;IAEd,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACxC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IAC1D,MAAM,WAAW,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAEhG,WAAW,EAAE,GAAG,CAAC;QACb,GAAG,cAAc;QACjB,MAAM,EAAE,GAAG,SAAS,IAAI,UAAU,CAAC,QAAQ,EAAE,EAAE;QAC/C,aAAa;QACb,SAAS;QACT,GAAG,WAAW;QACd,GAAG,EAAE,cAAc;KACtB,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogMethodOptions.js","sourceRoot":"","sources":["../../../lib/logger/LogMethodOptions.ts"],"names":[],"mappings":""}
|
|
@@ -13,4 +13,12 @@ export declare class TestLoggedMethods {
|
|
|
13
13
|
baz: number;
|
|
14
14
|
};
|
|
15
15
|
}): void;
|
|
16
|
+
logWithExtraFields(): void;
|
|
17
|
+
logAsyncWithExtraFields(): Promise<void>;
|
|
18
|
+
logAsyncRejectsWithExtraFields(): Promise<void>;
|
|
19
|
+
logThrowsWithExtraFields(): void;
|
|
20
|
+
logWithReservedKeyCollision(): void;
|
|
21
|
+
logThrowsFakeError(): void;
|
|
22
|
+
logRejectsFakeError(): Promise<void>;
|
|
23
|
+
logThrowsString(): void;
|
|
16
24
|
}
|
|
@@ -16,11 +16,39 @@ exports.TestLoggedMethods = void 0;
|
|
|
16
16
|
const Sensitive_1 = require("@coast/service-common/logger/redaction/Sensitive");
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const LogMethod_1 = require("../LogMethod");
|
|
19
|
+
class FakeError extends Error {
|
|
20
|
+
constructor() {
|
|
21
|
+
super('validation failed');
|
|
22
|
+
this.name = 'FakeError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
19
25
|
let TestLoggedMethods = class TestLoggedMethods {
|
|
20
26
|
logStartAndEnd() { }
|
|
21
27
|
logAllParams(a, b, c, d) { }
|
|
22
28
|
logWithRedactSensitive(a, b) { }
|
|
23
29
|
logWithRedactNestedSensitive(a, b) { }
|
|
30
|
+
logWithExtraFields() { }
|
|
31
|
+
async logAsyncWithExtraFields() {
|
|
32
|
+
await Promise.resolve();
|
|
33
|
+
}
|
|
34
|
+
async logAsyncRejectsWithExtraFields() {
|
|
35
|
+
await Promise.resolve();
|
|
36
|
+
throw new Error('async boom');
|
|
37
|
+
}
|
|
38
|
+
logThrowsWithExtraFields() {
|
|
39
|
+
throw new Error('boom');
|
|
40
|
+
}
|
|
41
|
+
logWithReservedKeyCollision() { }
|
|
42
|
+
logThrowsFakeError() {
|
|
43
|
+
throw new FakeError();
|
|
44
|
+
}
|
|
45
|
+
async logRejectsFakeError() {
|
|
46
|
+
await Promise.resolve();
|
|
47
|
+
throw new FakeError();
|
|
48
|
+
}
|
|
49
|
+
logThrowsString() {
|
|
50
|
+
throw 'bare string failure';
|
|
51
|
+
}
|
|
24
52
|
};
|
|
25
53
|
exports.TestLoggedMethods = TestLoggedMethods;
|
|
26
54
|
__decorate([
|
|
@@ -49,6 +77,54 @@ __decorate([
|
|
|
49
77
|
__metadata("design:paramtypes", [String, Object]),
|
|
50
78
|
__metadata("design:returntype", void 0)
|
|
51
79
|
], TestLoggedMethods.prototype, "logWithRedactNestedSensitive", null);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, LogMethod_1.LogMethod)({ extraLogFields: { toolName: 'noop_tool' } }),
|
|
82
|
+
__metadata("design:type", Function),
|
|
83
|
+
__metadata("design:paramtypes", []),
|
|
84
|
+
__metadata("design:returntype", void 0)
|
|
85
|
+
], TestLoggedMethods.prototype, "logWithExtraFields", null);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, LogMethod_1.LogMethod)({ extraLogFields: { experiment: 'exp-42', toolName: 'async_tool' } }),
|
|
88
|
+
__metadata("design:type", Function),
|
|
89
|
+
__metadata("design:paramtypes", []),
|
|
90
|
+
__metadata("design:returntype", Promise)
|
|
91
|
+
], TestLoggedMethods.prototype, "logAsyncWithExtraFields", null);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, LogMethod_1.LogMethod)({ extraLogFields: { toolName: 'rejecting_tool' } }),
|
|
94
|
+
__metadata("design:type", Function),
|
|
95
|
+
__metadata("design:paramtypes", []),
|
|
96
|
+
__metadata("design:returntype", Promise)
|
|
97
|
+
], TestLoggedMethods.prototype, "logAsyncRejectsWithExtraFields", null);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, LogMethod_1.LogMethod)({ extraLogFields: { toolName: 'throwing_tool' } }),
|
|
100
|
+
__metadata("design:type", Function),
|
|
101
|
+
__metadata("design:paramtypes", []),
|
|
102
|
+
__metadata("design:returntype", void 0)
|
|
103
|
+
], TestLoggedMethods.prototype, "logThrowsWithExtraFields", null);
|
|
104
|
+
__decorate([
|
|
105
|
+
(0, LogMethod_1.LogMethod)({ extraLogFields: { method: 'overridden', toolName: 'collision_tool' } }),
|
|
106
|
+
__metadata("design:type", Function),
|
|
107
|
+
__metadata("design:paramtypes", []),
|
|
108
|
+
__metadata("design:returntype", void 0)
|
|
109
|
+
], TestLoggedMethods.prototype, "logWithReservedKeyCollision", null);
|
|
110
|
+
__decorate([
|
|
111
|
+
(0, LogMethod_1.LogMethod)(),
|
|
112
|
+
__metadata("design:type", Function),
|
|
113
|
+
__metadata("design:paramtypes", []),
|
|
114
|
+
__metadata("design:returntype", void 0)
|
|
115
|
+
], TestLoggedMethods.prototype, "logThrowsFakeError", null);
|
|
116
|
+
__decorate([
|
|
117
|
+
(0, LogMethod_1.LogMethod)(),
|
|
118
|
+
__metadata("design:type", Function),
|
|
119
|
+
__metadata("design:paramtypes", []),
|
|
120
|
+
__metadata("design:returntype", Promise)
|
|
121
|
+
], TestLoggedMethods.prototype, "logRejectsFakeError", null);
|
|
122
|
+
__decorate([
|
|
123
|
+
(0, LogMethod_1.LogMethod)(),
|
|
124
|
+
__metadata("design:type", Function),
|
|
125
|
+
__metadata("design:paramtypes", []),
|
|
126
|
+
__metadata("design:returntype", void 0)
|
|
127
|
+
], TestLoggedMethods.prototype, "logThrowsString", null);
|
|
52
128
|
exports.TestLoggedMethods = TestLoggedMethods = __decorate([
|
|
53
129
|
(0, common_1.Injectable)()
|
|
54
130
|
], TestLoggedMethods);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestLoggedMethods.js","sourceRoot":"","sources":["../../../../lib/logger/test/TestLoggedMethods.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gFAA6E;AAC7E,2CAA4C;AAE5C,4CAAyC;
|
|
1
|
+
{"version":3,"file":"TestLoggedMethods.js","sourceRoot":"","sources":["../../../../lib/logger/test/TestLoggedMethods.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gFAA6E;AAC7E,2CAA4C;AAE5C,4CAAyC;AAEzC,MAAM,SAAU,SAAQ,KAAK;IACzB;QACI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC5B,CAAC;CACJ;AAGM,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAE1B,cAAc,KAAU,CAAC;IAIzB,YAAY,CAAC,CAAS,EAAE,CAAS,EAAE,CAAU,EAAE,CAAwC,IAAS,CAAC;IAIjG,sBAAsB,CAAC,CAAS,EAAe,CAAS,IAAS,CAAC;IAIlE,4BAA4B,CAAC,CAAS,EAAgC,CAAwC,IAAS,CAAC;IAGxH,kBAAkB,KAAU,CAAC;IAGvB,AAAN,KAAK,CAAC,uBAAuB;QACzB,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EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE,CAAC;;;;iEAG5D;AAGD;IADC,IAAA,qBAAS,EAAC,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC;;;;oEAC9C;AAGtC;IADC,IAAA,qBAAS,GAAE;;;;2DAGX;AAGK;IADL,IAAA,qBAAS,GAAE;;;;4DAIX;AAGD;IADC,IAAA,qBAAS,GAAE;;;;wDAGX;4BApDQ,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAqD7B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Attributes } from '@opentelemetry/api';
|
|
2
|
+
import { MetricService } from 'nestjs-otel';
|
|
3
|
+
interface CoastMetricOptions {
|
|
4
|
+
description?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class CoastMetrics {
|
|
7
|
+
private readonly metrics;
|
|
8
|
+
constructor(metrics: MetricService);
|
|
9
|
+
counter(name: string, value: number, attributes?: Attributes, opts?: CoastMetricOptions): void;
|
|
10
|
+
histogram(name: string, value: number, attributes?: Attributes, opts?: CoastMetricOptions): void;
|
|
11
|
+
gauge(name: string, value: number, attributes?: Attributes, opts?: CoastMetricOptions): void;
|
|
12
|
+
private namespace;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CoastMetrics = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const nestjs_otel_1 = require("nestjs-otel");
|
|
15
|
+
let CoastMetrics = class CoastMetrics {
|
|
16
|
+
constructor(metrics) {
|
|
17
|
+
this.metrics = metrics;
|
|
18
|
+
}
|
|
19
|
+
counter(name, value, attributes, opts) {
|
|
20
|
+
this.metrics.getUpDownCounter(this.namespace(name), opts).add(value, attributes);
|
|
21
|
+
}
|
|
22
|
+
histogram(name, value, attributes, opts) {
|
|
23
|
+
this.metrics.getHistogram(this.namespace(name), opts).record(value, attributes);
|
|
24
|
+
}
|
|
25
|
+
gauge(name, value, attributes, opts) {
|
|
26
|
+
this.metrics.getGauge(this.namespace(name), opts).record(value, attributes);
|
|
27
|
+
}
|
|
28
|
+
namespace(name) {
|
|
29
|
+
return name.startsWith('coast.') ? name : `coast.${name}`;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.CoastMetrics = CoastMetrics;
|
|
33
|
+
exports.CoastMetrics = CoastMetrics = __decorate([
|
|
34
|
+
(0, common_1.Injectable)(),
|
|
35
|
+
__metadata("design:paramtypes", [nestjs_otel_1.MetricService])
|
|
36
|
+
], CoastMetrics);
|
|
37
|
+
//# sourceMappingURL=CoastMetrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoastMetrics.js","sourceRoot":"","sources":["../../../lib/metrics/CoastMetrics.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAE5C,6CAA4C;AAWrC,IAAM,YAAY,GAAlB,MAAM,YAAY;IACrB,YAAoC,OAAsB;QAAtB,YAAO,GAAP,OAAO,CAAe;IAAG,CAAC;IAEvD,OAAO,CAAC,IAAY,EAAE,KAAa,EAAE,UAAuB,EAAE,IAAyB;QAC1F,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACrF,CAAC;IAEM,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,UAAuB,EAAE,IAAyB;QAC5F,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACpF,CAAC;IAEM,KAAK,CAAC,IAAY,EAAE,KAAa,EAAE,UAAuB,EAAE,IAAyB;QACxF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAChF,CAAC;IAEO,SAAS,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC;IAC9D,CAAC;CACJ,CAAA;AAlBY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;qCAEoC,2BAAa;GADjD,YAAY,CAkBxB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CoastMetricsModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const nestjs_otel_1 = require("nestjs-otel");
|
|
12
|
+
const CoastMetrics_1 = require("./CoastMetrics");
|
|
13
|
+
let CoastMetricsModule = class CoastMetricsModule {
|
|
14
|
+
};
|
|
15
|
+
exports.CoastMetricsModule = CoastMetricsModule;
|
|
16
|
+
exports.CoastMetricsModule = CoastMetricsModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
providers: [CoastMetrics_1.CoastMetrics, nestjs_otel_1.MetricService],
|
|
19
|
+
exports: [CoastMetrics_1.CoastMetrics],
|
|
20
|
+
})
|
|
21
|
+
], CoastMetricsModule);
|
|
22
|
+
//# sourceMappingURL=CoastMetricsModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoastMetricsModule.js","sourceRoot":"","sources":["../../../lib/metrics/CoastMetricsModule.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAA4C;AAE5C,iDAA8C;AAMvC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAJ9B,IAAA,eAAM,EAAC;QACJ,SAAS,EAAE,CAAC,2BAAY,EAAE,2BAAa,CAAC;QACxC,OAAO,EAAE,CAAC,2BAAY,CAAC;KAC1B,CAAC;GACW,kBAAkB,CAAG"}
|