franchising 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dist/cli.js +109 -109
- package/dist/core-BidJDmSN.cjs +759 -0
- package/dist/core-BidJDmSN.cjs.map +1 -0
- package/dist/core-C-EFrEd6.js +710 -0
- package/dist/core-C-EFrEd6.js.map +1 -0
- package/dist/{index-Cj-10Q5F.d.cts → index--EJQTnHy.d.cts} +2 -2
- package/dist/index-B3aVdDMV.d.cts +51 -0
- package/dist/{index-CYT1PFzo.d.cts → index-BDYdEWl2.d.cts} +157 -3
- package/dist/{index-B3UOHsA9.d.ts → index-BDYdEWl2.d.ts} +157 -3
- package/dist/index-ByS2IC02.d.ts +51 -0
- package/dist/{index-C1KmT8dQ.d.ts → index-u3ArUXO0.d.ts} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/messaging/index.cjs +1 -1
- package/dist/messaging/index.d.cts +120 -5
- package/dist/messaging/index.d.ts +120 -5
- package/dist/messaging/index.js +1 -1
- package/dist/sdk-B2Lp3JCz.cjs +45 -0
- package/dist/sdk-B2Lp3JCz.cjs.map +1 -0
- package/dist/sdk-IGOHpAeG.js +22 -0
- package/dist/sdk-IGOHpAeG.js.map +1 -0
- package/dist/sso/client.d.cts +1 -2
- package/dist/sso/client.d.ts +1 -2
- package/dist/sso/index.d.cts +1 -2
- package/dist/sso/index.d.ts +1 -2
- package/dist/sso/nestjs.d.cts +2 -2
- package/dist/sso/nestjs.d.ts +2 -2
- package/dist/sso/resource.d.cts +2 -2
- package/dist/sso/resource.d.ts +2 -2
- package/dist/telemetry/core.cjs +11 -0
- package/dist/telemetry/core.d.cts +4 -0
- package/dist/telemetry/core.d.ts +4 -0
- package/dist/telemetry/core.js +5 -0
- package/dist/telemetry/index.cjs +86 -799
- package/dist/telemetry/index.cjs.map +1 -1
- package/dist/telemetry/index.d.cts +9 -55
- package/dist/telemetry/index.d.ts +9 -55
- package/dist/telemetry/index.js +67 -773
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/register.cjs +86 -4
- package/dist/telemetry/register.cjs.map +1 -0
- package/dist/telemetry/register.d.cts +4 -4
- package/dist/telemetry/register.d.ts +4 -4
- package/dist/telemetry/register.js +84 -2
- package/dist/telemetry/register.js.map +1 -0
- package/dist/version-BNLcT13l.js +1 -0
- package/dist/{version-CfUi3iAV.cjs → version-BrUpZnZ7.cjs} +1 -1
- package/package.json +18 -2
- package/dist/runtime-C95UYYLb.cjs +0 -111
- package/dist/runtime-C95UYYLb.cjs.map +0 -1
- package/dist/runtime-DG2oBFYw.js +0 -88
- package/dist/runtime-DG2oBFYw.js.map +0 -1
- package/dist/team-CJVAg4HH.d.cts +0 -157
- package/dist/team-CJVAg4HH.d.ts +0 -157
- package/dist/version-CPunTYCY.js +0 -1
package/dist/telemetry/index.js
CHANGED
|
@@ -1,745 +1,20 @@
|
|
|
1
|
+
import { a as Telemetry, c as TelemetryContext, i as CheckedTelemetry, n as createTelemetry, o as TelemetryOperationalState, r as TelemetryService, s as createTelemetryPinoHooks, t as Trace } from "../core-C-EFrEd6.js";
|
|
2
|
+
import { t as createTelemetryMock } from "../telemetry.mock-BZRpy63c.js";
|
|
1
3
|
import { n as TelemetryError, t as TelemetryAdapterDispatcher } from "../dispatcher-DA_l1Vkv.js";
|
|
2
|
-
import { i as readEnv, r as shutdownTelemetry, t as isTelemetryRegistered } from "../runtime-DG2oBFYw.js";
|
|
3
4
|
import { n as __decorateMetadata, t as __decorate } from "../decorate-BR5FVX5x.js";
|
|
5
|
+
import { a as sanitize, c as sanitizeText, s as sanitizeError, t as DEFAULT_REDACT_PATHS } from "../redaction-DhuHTlHA.js";
|
|
4
6
|
import { t as __decorateParam } from "../decorateParam-CKE7_J1s.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Catch, HttpException, Inject, Injectable, Module, Optional, RequestMethod } from "@nestjs/common";
|
|
7
|
+
import { t as isTelemetryRegistered } from "../sdk-IGOHpAeG.js";
|
|
8
|
+
import { Catch, HttpException, Inject, Injectable, Module, RequestMethod } from "@nestjs/common";
|
|
8
9
|
import { APP_FILTER, APP_INTERCEPTOR, BaseExceptionFilter } from "@nestjs/core";
|
|
9
|
-
import pino from "pino";
|
|
10
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
|
-
import { SpanStatusCode, context, metrics, propagation, trace } from "@opentelemetry/api";
|
|
12
10
|
import { LoggerModule, PinoLogger } from "nestjs-pino";
|
|
13
|
-
import { SeverityNumber, logs } from "@opentelemetry/api-logs";
|
|
14
11
|
import { LogController } from "fastify";
|
|
15
12
|
import { Observable } from "rxjs";
|
|
16
13
|
import { finalize, tap } from "rxjs/operators";
|
|
17
14
|
|
|
18
|
-
// src/modules/telemetry/shared/context/context.ts
|
|
19
|
-
const storage = new AsyncLocalStorage();
|
|
20
|
-
function baseContext() {
|
|
21
|
-
const span = trace.getActiveSpan()?.spanContext();
|
|
22
|
-
return {
|
|
23
|
-
service: readEnv("OTEL_SERVICE_NAME", "SERVICE_NAME") ?? "unknown-service",
|
|
24
|
-
product: readEnv("TELEMETRY_PRODUCT"),
|
|
25
|
-
environment: readEnv("NODE_ENV") ?? "development",
|
|
26
|
-
release: readEnv("OTEL_SERVICE_VERSION", "RELEASE", "RAILWAY_DEPLOYMENT_ID", "GIT_SHA"),
|
|
27
|
-
traceId: span?.traceId,
|
|
28
|
-
spanId: span?.spanId,
|
|
29
|
-
...storage.getStore()
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
let TelemetryContext = class TelemetryContext {
|
|
33
|
-
logger;
|
|
34
|
-
constructor(logger) {
|
|
35
|
-
this.logger = logger;
|
|
36
|
-
}
|
|
37
|
-
get() {
|
|
38
|
-
return baseContext();
|
|
39
|
-
}
|
|
40
|
-
assign(context) {
|
|
41
|
-
const current = storage.getStore();
|
|
42
|
-
if (current) Object.assign(current, context);
|
|
43
|
-
try {
|
|
44
|
-
this.logger?.assign({
|
|
45
|
-
actor_id: context.actorId,
|
|
46
|
-
organization_id: context.organizationId,
|
|
47
|
-
job_id: context.jobId,
|
|
48
|
-
correlation_id: context.correlationId
|
|
49
|
-
});
|
|
50
|
-
} catch {}
|
|
51
|
-
}
|
|
52
|
-
identify(actorId) {
|
|
53
|
-
this.assign({ actorId });
|
|
54
|
-
}
|
|
55
|
-
organization(organizationId) {
|
|
56
|
-
this.assign({ organizationId });
|
|
57
|
-
}
|
|
58
|
-
run(context, fn) {
|
|
59
|
-
return storage.run({
|
|
60
|
-
...storage.getStore(),
|
|
61
|
-
...context
|
|
62
|
-
}, fn);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
TelemetryContext = __decorate([
|
|
66
|
-
Injectable(),
|
|
67
|
-
__decorateParam(0, Optional()),
|
|
68
|
-
__decorateParam(0, Inject(PinoLogger)),
|
|
69
|
-
__decorateMetadata("design:paramtypes", [Object])
|
|
70
|
-
], TelemetryContext);
|
|
71
|
-
|
|
72
|
-
// src/modules/telemetry/shared/logging/otel.ts
|
|
73
|
-
const otelLogger = logs.getLogger("@rockdev/telemetry", void 0, { includeTraceContext: true });
|
|
74
|
-
function severity(level) {
|
|
75
|
-
if (level >= 60) return {
|
|
76
|
-
text: "fatal",
|
|
77
|
-
number: SeverityNumber.FATAL
|
|
78
|
-
};
|
|
79
|
-
if (level >= 50) return {
|
|
80
|
-
text: "error",
|
|
81
|
-
number: SeverityNumber.ERROR
|
|
82
|
-
};
|
|
83
|
-
if (level >= 40) return {
|
|
84
|
-
text: "warn",
|
|
85
|
-
number: SeverityNumber.WARN
|
|
86
|
-
};
|
|
87
|
-
if (level >= 30) return {
|
|
88
|
-
text: "info",
|
|
89
|
-
number: SeverityNumber.INFO
|
|
90
|
-
};
|
|
91
|
-
if (level >= 20) return {
|
|
92
|
-
text: "debug",
|
|
93
|
-
number: SeverityNumber.DEBUG
|
|
94
|
-
};
|
|
95
|
-
return {
|
|
96
|
-
text: "trace",
|
|
97
|
-
number: SeverityNumber.TRACE
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function toAnyValue(value) {
|
|
101
|
-
if (value instanceof Error) {
|
|
102
|
-
const safeError = sanitizeError(value);
|
|
103
|
-
return toAnyValue({
|
|
104
|
-
name: safeError.name,
|
|
105
|
-
message: safeError.message,
|
|
106
|
-
...safeError.stack ? { stack: safeError.stack } : {}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
if (typeof value === "string") return sanitizeText(value);
|
|
110
|
-
if (Array.isArray(value)) return value.map(toAnyValue);
|
|
111
|
-
if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, isSensitiveKey(key) ? "[REDACTED]" : toAnyValue(child)]));
|
|
112
|
-
if (typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) return value;
|
|
113
|
-
return String(value);
|
|
114
|
-
}
|
|
115
|
-
function toLogRecord(args, level) {
|
|
116
|
-
const [first, second, ...rest] = args;
|
|
117
|
-
const body = {};
|
|
118
|
-
if (first && typeof first === "object" && !Array.isArray(first)) {
|
|
119
|
-
const safe = toAnyValue(first);
|
|
120
|
-
if (safe && typeof safe === "object" && !Array.isArray(safe)) Object.assign(body, safe);
|
|
121
|
-
if (second !== void 0 && typeof second !== "string") body.arguments = toAnyValue(second);
|
|
122
|
-
} else if (first !== void 0) body.message = typeof first === "string" ? sanitizeText(first) : toAnyValue(first);
|
|
123
|
-
if (typeof second === "string") body.message = sanitizeText(second);
|
|
124
|
-
if (rest.length > 0) body.arguments = toAnyValue(rest);
|
|
125
|
-
const currentSeverity = severity(level);
|
|
126
|
-
return {
|
|
127
|
-
body,
|
|
128
|
-
severityNumber: currentSeverity.number,
|
|
129
|
-
severityText: currentSeverity.text,
|
|
130
|
-
...typeof body.event === "string" ? { eventName: body.event } : {}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function emitPinoLog(args, level) {
|
|
134
|
-
if (process.env.TELEMETRY_ENABLED === "false" || process.env.TELEMETRY_LOGS_ENABLED === "false") return;
|
|
135
|
-
try {
|
|
136
|
-
otelLogger.emit(toLogRecord(args, level));
|
|
137
|
-
} catch {}
|
|
138
|
-
}
|
|
139
|
-
function createTelemetryPinoHooks() {
|
|
140
|
-
return { logMethod(args, method, level) {
|
|
141
|
-
emitPinoLog(args, level);
|
|
142
|
-
method.apply(this, args);
|
|
143
|
-
} };
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// src/modules/telemetry/shared/state/operational.ts
|
|
147
|
-
let TelemetryOperationalState = class TelemetryOperationalState {
|
|
148
|
-
signals = new Map([
|
|
149
|
-
"errors",
|
|
150
|
-
"events",
|
|
151
|
-
"logs",
|
|
152
|
-
"metrics",
|
|
153
|
-
"tracing"
|
|
154
|
-
].map((signal) => [signal, {
|
|
155
|
-
failed: false,
|
|
156
|
-
failureCount: 0
|
|
157
|
-
}]));
|
|
158
|
-
recordFailure(signal) {
|
|
159
|
-
const current = this.signals.get(signal);
|
|
160
|
-
if (!current) return;
|
|
161
|
-
current.failed = true;
|
|
162
|
-
current.failureCount += 1;
|
|
163
|
-
current.lastFailureAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
164
|
-
}
|
|
165
|
-
status(signal) {
|
|
166
|
-
return { ...this.signals.get(signal) ?? {
|
|
167
|
-
failed: false,
|
|
168
|
-
failureCount: 0
|
|
169
|
-
} };
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
TelemetryOperationalState = __decorate([Injectable()], TelemetryOperationalState);
|
|
173
|
-
|
|
174
|
-
// src/modules/telemetry/types/telemetry.ts
|
|
175
|
-
var Telemetry = class {};
|
|
176
|
-
|
|
177
|
-
// src/modules/telemetry/core/checked-telemetry.ts
|
|
178
|
-
var CheckedTelemetry = class extends Telemetry {
|
|
179
|
-
target;
|
|
180
|
-
adapters;
|
|
181
|
-
options;
|
|
182
|
-
constructor(target, adapters, options = {}) {
|
|
183
|
-
super();
|
|
184
|
-
this.target = target;
|
|
185
|
-
this.adapters = adapters;
|
|
186
|
-
this.options = options;
|
|
187
|
-
}
|
|
188
|
-
debug(event, attributes) {
|
|
189
|
-
this.require("logs", "telemetry.debug()");
|
|
190
|
-
this.target.debug(event, attributes);
|
|
191
|
-
}
|
|
192
|
-
info(event, attributes) {
|
|
193
|
-
this.require("logs", "telemetry.info()");
|
|
194
|
-
this.target.info(event, attributes);
|
|
195
|
-
}
|
|
196
|
-
warn(event, attributes) {
|
|
197
|
-
this.require("logs", "telemetry.warn()");
|
|
198
|
-
this.target.warn(event, attributes);
|
|
199
|
-
}
|
|
200
|
-
error(event, error, attributes) {
|
|
201
|
-
this.require("logs", "telemetry.error()");
|
|
202
|
-
this.target.error(event, error, attributes);
|
|
203
|
-
}
|
|
204
|
-
event(event, attributes) {
|
|
205
|
-
this.require("events", "telemetry.event()");
|
|
206
|
-
this.target.event(event, attributes);
|
|
207
|
-
}
|
|
208
|
-
captureException(error, attributes, options) {
|
|
209
|
-
this.require("errors", "telemetry.captureException()");
|
|
210
|
-
this.target.captureException(error, attributes, options);
|
|
211
|
-
}
|
|
212
|
-
async span(name, fn, attributes) {
|
|
213
|
-
this.require("tracing", "telemetry.span()");
|
|
214
|
-
return this.target.span(name, fn, attributes);
|
|
215
|
-
}
|
|
216
|
-
increment(name, value, attributes) {
|
|
217
|
-
this.require("metrics", "telemetry.increment()");
|
|
218
|
-
this.target.increment(name, value, attributes);
|
|
219
|
-
}
|
|
220
|
-
histogram(name, value, attributes) {
|
|
221
|
-
this.require("metrics", "telemetry.histogram()");
|
|
222
|
-
this.target.histogram(name, value, attributes);
|
|
223
|
-
}
|
|
224
|
-
async trackDependency(options, fn) {
|
|
225
|
-
this.requireDependency("telemetry.trackDependency()");
|
|
226
|
-
return this.target.trackDependency(options, fn);
|
|
227
|
-
}
|
|
228
|
-
runJob(options, fn) {
|
|
229
|
-
try {
|
|
230
|
-
this.requireDependency("telemetry.runJob()");
|
|
231
|
-
} catch (error) {
|
|
232
|
-
return Promise.reject(error);
|
|
233
|
-
}
|
|
234
|
-
return this.target.runJob(options, fn);
|
|
235
|
-
}
|
|
236
|
-
async fetch(input, init, options) {
|
|
237
|
-
this.requireDependency("telemetry.fetch()");
|
|
238
|
-
return this.target.fetch(input, init, options);
|
|
239
|
-
}
|
|
240
|
-
traceparent() {
|
|
241
|
-
return this.target.traceparent();
|
|
242
|
-
}
|
|
243
|
-
getContext() {
|
|
244
|
-
return this.target.getContext();
|
|
245
|
-
}
|
|
246
|
-
shutdown() {
|
|
247
|
-
return this.target.shutdown();
|
|
248
|
-
}
|
|
249
|
-
disabled(capability) {
|
|
250
|
-
if (process.env.TELEMETRY_ENABLED === "false") return true;
|
|
251
|
-
if (capability === "metrics") return process.env.TELEMETRY_METRICS_ENABLED === "false";
|
|
252
|
-
if (capability === "tracing") return this.options.tracing === false || process.env.TELEMETRY_TRACING_ENABLED === "false";
|
|
253
|
-
if (capability === "errors") return this.options.errors === false;
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
|
-
require(capability, operation) {
|
|
257
|
-
if (this.disabled(capability)) return;
|
|
258
|
-
this.adapters.assertSupports(capability, operation);
|
|
259
|
-
}
|
|
260
|
-
requireDependency(operation) {
|
|
261
|
-
this.require("tracing", operation);
|
|
262
|
-
this.require("metrics", operation);
|
|
263
|
-
this.require("errors", operation);
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
// src/modules/telemetry/shared/context/adapter.ts
|
|
268
|
-
function adapterContext(context) {
|
|
269
|
-
return sanitizeAttributes({ ...context });
|
|
270
|
-
}
|
|
271
|
-
|
|
272
15
|
// src/modules/telemetry/shared/di/tokens.ts
|
|
273
16
|
const TELEMETRY_OPTIONS = Symbol("TELEMETRY_OPTIONS");
|
|
274
17
|
|
|
275
|
-
// src/modules/telemetry/shared/utils/case.ts
|
|
276
|
-
function snakeCase(value) {
|
|
277
|
-
return value.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[.-]/g, "_").toLowerCase();
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// src/modules/telemetry/shared/logging/attributes.ts
|
|
281
|
-
function logAttributes(context, attributes) {
|
|
282
|
-
const record = {};
|
|
283
|
-
for (const [key, value] of Object.entries({
|
|
284
|
-
requestId: context.requestId,
|
|
285
|
-
traceId: context.traceId,
|
|
286
|
-
spanId: context.spanId,
|
|
287
|
-
service: context.service,
|
|
288
|
-
product: context.product,
|
|
289
|
-
environment: context.environment,
|
|
290
|
-
release: context.release,
|
|
291
|
-
actorId: context.actorId,
|
|
292
|
-
organizationId: context.organizationId,
|
|
293
|
-
jobId: context.jobId,
|
|
294
|
-
correlationId: context.correlationId,
|
|
295
|
-
...attributes
|
|
296
|
-
})) if (value !== void 0) record[snakeCase(key)] = value;
|
|
297
|
-
return sanitizeAttributes(record);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// src/modules/telemetry/shared/metrics/instruments.ts
|
|
301
|
-
const meter = metrics.getMeter("@rockdev/telemetry");
|
|
302
|
-
const counters = /* @__PURE__ */ new Map();
|
|
303
|
-
const histograms = /* @__PURE__ */ new Map();
|
|
304
|
-
|
|
305
|
-
// src/modules/telemetry/shared/metrics/metrics.ts
|
|
306
|
-
const ALLOWED_METRIC_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
307
|
-
"service",
|
|
308
|
-
"route",
|
|
309
|
-
"method",
|
|
310
|
-
"status",
|
|
311
|
-
"statusCode",
|
|
312
|
-
"statusClass",
|
|
313
|
-
"result",
|
|
314
|
-
"dependency",
|
|
315
|
-
"operation",
|
|
316
|
-
"queue",
|
|
317
|
-
"job",
|
|
318
|
-
"product",
|
|
319
|
-
"channel",
|
|
320
|
-
"provider",
|
|
321
|
-
"priority",
|
|
322
|
-
"reason"
|
|
323
|
-
]);
|
|
324
|
-
function validValue(key, value) {
|
|
325
|
-
if (typeof value !== "string" || value.length === 0 || value.length > 100) return false;
|
|
326
|
-
if (containsSensitiveText(value) || isLikelyIdentifier(value)) return false;
|
|
327
|
-
if (key === "route") return (value === "unmatched" || value.startsWith("/")) && !value.includes("?") && !value.includes("://") && !value.split("/").some((segment) => /^\d+$/.test(segment));
|
|
328
|
-
if (key === "method") return /^[A-Z]+$/.test(value);
|
|
329
|
-
if (key === "statusCode") return /^[1-5]\d\d$/.test(value);
|
|
330
|
-
if (key === "statusClass") return /^[1-5]xx$/.test(value);
|
|
331
|
-
if (key === "result") return value === "success" || value === "error";
|
|
332
|
-
return true;
|
|
333
|
-
}
|
|
334
|
-
function sanitizeMetricAttributes(attributes) {
|
|
335
|
-
if (!attributes) return {
|
|
336
|
-
attributes: void 0,
|
|
337
|
-
rejectedKeys: []
|
|
338
|
-
};
|
|
339
|
-
const valid = {};
|
|
340
|
-
const rejectedKeys = [];
|
|
341
|
-
for (const [rawKey, value] of Object.entries(attributes)) {
|
|
342
|
-
const key = rawKey;
|
|
343
|
-
if (!ALLOWED_METRIC_ATTRIBUTES.has(key) || isSensitiveKey(rawKey) || !validValue(key, value)) {
|
|
344
|
-
rejectedKeys.push(rawKey);
|
|
345
|
-
continue;
|
|
346
|
-
}
|
|
347
|
-
valid[key] = value;
|
|
348
|
-
}
|
|
349
|
-
return {
|
|
350
|
-
attributes: valid,
|
|
351
|
-
rejectedKeys
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// src/modules/telemetry/core/telemetry.service.ts
|
|
356
|
-
let TelemetryService = class TelemetryService extends Telemetry {
|
|
357
|
-
logger;
|
|
358
|
-
context;
|
|
359
|
-
operationalState;
|
|
360
|
-
options;
|
|
361
|
-
adapters;
|
|
362
|
-
constructor(logger, context, operationalState, options = {}, adapters) {
|
|
363
|
-
super();
|
|
364
|
-
this.logger = logger;
|
|
365
|
-
this.context = context;
|
|
366
|
-
this.operationalState = operationalState;
|
|
367
|
-
this.options = options;
|
|
368
|
-
this.adapters = adapters;
|
|
369
|
-
}
|
|
370
|
-
debug(event, attributes) {
|
|
371
|
-
this.write("debug", event, attributes);
|
|
372
|
-
}
|
|
373
|
-
info(event, attributes) {
|
|
374
|
-
this.write("info", event, attributes);
|
|
375
|
-
}
|
|
376
|
-
warn(event, attributes) {
|
|
377
|
-
this.write("warn", event, attributes);
|
|
378
|
-
}
|
|
379
|
-
error(event, error, attributes) {
|
|
380
|
-
this.writeError(event, error, attributes);
|
|
381
|
-
}
|
|
382
|
-
event(event, attributes) {
|
|
383
|
-
try {
|
|
384
|
-
const context = this.getContext();
|
|
385
|
-
const safeAttributes = logAttributes(context, attributes);
|
|
386
|
-
this.logger.info({
|
|
387
|
-
event,
|
|
388
|
-
event_kind: "product",
|
|
389
|
-
...safeAttributes
|
|
390
|
-
});
|
|
391
|
-
this.adapters?.captureEvent?.({
|
|
392
|
-
event,
|
|
393
|
-
attributes: safeAttributes,
|
|
394
|
-
context: adapterContext(context)
|
|
395
|
-
});
|
|
396
|
-
} catch {
|
|
397
|
-
this.operationalState.recordFailure("events");
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
captureException(error, attributes, options) {
|
|
401
|
-
this.error("exception.captured", error, attributes);
|
|
402
|
-
if (this.options.errors === false) return;
|
|
403
|
-
const reportError = sanitizeError(error, process.env.TELEMETRY_ERROR_STACK_ENABLED !== "false");
|
|
404
|
-
const reportContext = {
|
|
405
|
-
request: sanitizeAttributes({ ...this.getContext() }),
|
|
406
|
-
attributes: sanitizeAttributes(attributes)
|
|
407
|
-
};
|
|
408
|
-
this.adapters?.captureException?.({
|
|
409
|
-
error: reportError,
|
|
410
|
-
context: reportContext,
|
|
411
|
-
...options?.fingerprint ? { fingerprint: options.fingerprint } : {}
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
async span(name, fn, attributes = {}) {
|
|
415
|
-
if (this.options.tracing === false || process.env.TELEMETRY_TRACING_ENABLED === "false") return fn({
|
|
416
|
-
setAttributes() {},
|
|
417
|
-
addEvent() {}
|
|
418
|
-
});
|
|
419
|
-
try {
|
|
420
|
-
return trace.getTracer(this.getContext().service).startActiveSpan(name, { attributes: sanitizeAttributes(attributes) }, async (span) => {
|
|
421
|
-
const startedAt = performance.now();
|
|
422
|
-
const events = [];
|
|
423
|
-
let spanError;
|
|
424
|
-
let spanAttributes = sanitizeAttributes(attributes);
|
|
425
|
-
const facade = {
|
|
426
|
-
setAttributes: (values) => {
|
|
427
|
-
const safe = sanitizeAttributes(values);
|
|
428
|
-
spanAttributes = {
|
|
429
|
-
...spanAttributes,
|
|
430
|
-
...safe
|
|
431
|
-
};
|
|
432
|
-
span.setAttributes(safe);
|
|
433
|
-
},
|
|
434
|
-
addEvent: (event, values) => {
|
|
435
|
-
const safe = sanitizeAttributes(values);
|
|
436
|
-
events.push({
|
|
437
|
-
name: event,
|
|
438
|
-
attributes: safe
|
|
439
|
-
});
|
|
440
|
-
span.addEvent(event, safe);
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
try {
|
|
444
|
-
return await fn(facade);
|
|
445
|
-
} catch (error) {
|
|
446
|
-
spanError = sanitizeError(error);
|
|
447
|
-
try {
|
|
448
|
-
span.recordException(sanitizeError(error));
|
|
449
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
450
|
-
} catch {
|
|
451
|
-
this.operationalState.recordFailure("tracing");
|
|
452
|
-
}
|
|
453
|
-
throw error;
|
|
454
|
-
} finally {
|
|
455
|
-
this.adapters?.captureSpan?.({
|
|
456
|
-
name,
|
|
457
|
-
durationMs: performance.now() - startedAt,
|
|
458
|
-
attributes: spanAttributes,
|
|
459
|
-
events,
|
|
460
|
-
context: adapterContext(this.getContext()),
|
|
461
|
-
...spanError ? { error: spanError } : {}
|
|
462
|
-
});
|
|
463
|
-
try {
|
|
464
|
-
span.end();
|
|
465
|
-
} catch {
|
|
466
|
-
this.operationalState.recordFailure("tracing");
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
});
|
|
470
|
-
} catch {
|
|
471
|
-
this.operationalState.recordFailure("tracing");
|
|
472
|
-
return fn({
|
|
473
|
-
setAttributes() {},
|
|
474
|
-
addEvent() {}
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
increment(name, value = 1, attributes) {
|
|
479
|
-
if (process.env.TELEMETRY_METRICS_ENABLED === "false") return;
|
|
480
|
-
const sanitized = sanitizeMetricAttributes(attributes);
|
|
481
|
-
this.warnRejectedMetricAttributes(name, sanitized.rejectedKeys);
|
|
482
|
-
try {
|
|
483
|
-
const instrument = counters.get(name) ?? meter.createCounter(name);
|
|
484
|
-
counters.set(name, instrument);
|
|
485
|
-
instrument.add(value, sanitized.attributes);
|
|
486
|
-
this.adapters?.captureMetric?.({
|
|
487
|
-
type: "counter",
|
|
488
|
-
name,
|
|
489
|
-
value,
|
|
490
|
-
attributes: sanitized.attributes ?? {},
|
|
491
|
-
context: adapterContext(this.getContext())
|
|
492
|
-
});
|
|
493
|
-
} catch {
|
|
494
|
-
this.operationalState.recordFailure("metrics");
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
histogram(name, value, attributes) {
|
|
498
|
-
if (process.env.TELEMETRY_METRICS_ENABLED === "false") return;
|
|
499
|
-
const sanitized = sanitizeMetricAttributes(attributes);
|
|
500
|
-
this.warnRejectedMetricAttributes(name, sanitized.rejectedKeys);
|
|
501
|
-
try {
|
|
502
|
-
const instrument = histograms.get(name) ?? meter.createHistogram(name, { unit: "ms" });
|
|
503
|
-
histograms.set(name, instrument);
|
|
504
|
-
instrument.record(value, sanitized.attributes);
|
|
505
|
-
this.adapters?.captureMetric?.({
|
|
506
|
-
type: "histogram",
|
|
507
|
-
name,
|
|
508
|
-
value,
|
|
509
|
-
attributes: sanitized.attributes ?? {},
|
|
510
|
-
context: adapterContext(this.getContext())
|
|
511
|
-
});
|
|
512
|
-
} catch {
|
|
513
|
-
this.operationalState.recordFailure("metrics");
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
async trackDependency(options, fn) {
|
|
517
|
-
const startedAt = performance.now();
|
|
518
|
-
try {
|
|
519
|
-
const result = await this.span(`dependency.${options.name}.${options.operation}`, async () => fn(), {
|
|
520
|
-
"dependency.name": options.name,
|
|
521
|
-
"operation.name": options.operation
|
|
522
|
-
});
|
|
523
|
-
this.increment("rock_dependency_requests_total", 1, {
|
|
524
|
-
dependency: options.name,
|
|
525
|
-
operation: options.operation,
|
|
526
|
-
result: "success"
|
|
527
|
-
});
|
|
528
|
-
return result;
|
|
529
|
-
} catch (error) {
|
|
530
|
-
this.increment("rock_dependency_requests_total", 1, {
|
|
531
|
-
dependency: options.name,
|
|
532
|
-
operation: options.operation,
|
|
533
|
-
result: "error"
|
|
534
|
-
});
|
|
535
|
-
this.captureException(error, {
|
|
536
|
-
dependency: options.name,
|
|
537
|
-
operation: options.operation
|
|
538
|
-
});
|
|
539
|
-
throw error;
|
|
540
|
-
} finally {
|
|
541
|
-
this.histogram("rock_dependency_request_duration_ms", performance.now() - startedAt, {
|
|
542
|
-
dependency: options.name,
|
|
543
|
-
operation: options.operation
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
runJob(options, fn) {
|
|
548
|
-
const run = () => this.context.run({
|
|
549
|
-
...options.jobId ? { jobId: options.jobId } : {},
|
|
550
|
-
...options.correlationId ? { correlationId: options.correlationId } : {}
|
|
551
|
-
}, () => this.trackDependency({
|
|
552
|
-
name: `queue.${options.queue}`,
|
|
553
|
-
operation: options.job
|
|
554
|
-
}, fn));
|
|
555
|
-
if (!options.traceparent) return run();
|
|
556
|
-
const parent = propagation.extract(context.active(), { traceparent: options.traceparent });
|
|
557
|
-
return context.with(parent, run);
|
|
558
|
-
}
|
|
559
|
-
async fetch(input, init, options) {
|
|
560
|
-
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
561
|
-
let host = "unknown";
|
|
562
|
-
let path = url;
|
|
563
|
-
try {
|
|
564
|
-
const parsed = new URL(url);
|
|
565
|
-
host = parsed.host;
|
|
566
|
-
path = parsed.pathname;
|
|
567
|
-
} catch {}
|
|
568
|
-
const method = (init?.method ?? (input instanceof Request ? input.method : void 0) ?? "GET").toUpperCase();
|
|
569
|
-
const dependency = options?.dependency ?? host;
|
|
570
|
-
const operation = options?.operation ?? `${method} ${path}`;
|
|
571
|
-
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : {}));
|
|
572
|
-
propagation.inject(context.active(), headers, { set: (carrier, key, value) => carrier.set(key, String(value)) });
|
|
573
|
-
return this.trackDependency({
|
|
574
|
-
name: dependency,
|
|
575
|
-
operation
|
|
576
|
-
}, () => this.span(`http.client.${dependency}`, async (span) => {
|
|
577
|
-
const response = await fetch(input, {
|
|
578
|
-
...init,
|
|
579
|
-
headers
|
|
580
|
-
});
|
|
581
|
-
span.setAttributes({ "http.response.status_code": response.status });
|
|
582
|
-
return response;
|
|
583
|
-
}, {
|
|
584
|
-
"http.request.method": method,
|
|
585
|
-
"server.address": host,
|
|
586
|
-
"url.path": path,
|
|
587
|
-
...options?.attributes
|
|
588
|
-
}));
|
|
589
|
-
}
|
|
590
|
-
traceparent() {
|
|
591
|
-
const carrier = {};
|
|
592
|
-
try {
|
|
593
|
-
propagation.inject(context.active(), carrier);
|
|
594
|
-
} catch {
|
|
595
|
-
this.operationalState.recordFailure("tracing");
|
|
596
|
-
return;
|
|
597
|
-
}
|
|
598
|
-
return carrier.traceparent;
|
|
599
|
-
}
|
|
600
|
-
getContext() {
|
|
601
|
-
return this.context.get();
|
|
602
|
-
}
|
|
603
|
-
async shutdown() {
|
|
604
|
-
await Promise.allSettled([this.adapters?.shutdown() ?? Promise.resolve(), shutdownTelemetry().catch(() => {
|
|
605
|
-
this.operationalState.recordFailure("logs");
|
|
606
|
-
this.operationalState.recordFailure("metrics");
|
|
607
|
-
this.operationalState.recordFailure("tracing");
|
|
608
|
-
})]);
|
|
609
|
-
}
|
|
610
|
-
write(level, event, attributes) {
|
|
611
|
-
try {
|
|
612
|
-
const context = this.getContext();
|
|
613
|
-
const safeAttributes = logAttributes(context, attributes);
|
|
614
|
-
this.logger[level]({
|
|
615
|
-
event,
|
|
616
|
-
...safeAttributes
|
|
617
|
-
});
|
|
618
|
-
this.adapters?.captureLog?.({
|
|
619
|
-
level,
|
|
620
|
-
event,
|
|
621
|
-
attributes: safeAttributes,
|
|
622
|
-
context: adapterContext(context)
|
|
623
|
-
});
|
|
624
|
-
} catch {
|
|
625
|
-
this.operationalState.recordFailure("logs");
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
writeError(event, error, attributes) {
|
|
629
|
-
try {
|
|
630
|
-
const context = this.getContext();
|
|
631
|
-
const safeAttributes = logAttributes(context, attributes);
|
|
632
|
-
this.logger.error({
|
|
633
|
-
event,
|
|
634
|
-
err: sanitizeError(error),
|
|
635
|
-
...safeAttributes
|
|
636
|
-
});
|
|
637
|
-
this.adapters?.captureLog?.({
|
|
638
|
-
level: "error",
|
|
639
|
-
event,
|
|
640
|
-
attributes: safeAttributes,
|
|
641
|
-
context: adapterContext(context)
|
|
642
|
-
});
|
|
643
|
-
} catch {
|
|
644
|
-
this.operationalState.recordFailure("logs");
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
warnRejectedMetricAttributes(metricName, rejectedKeys) {
|
|
648
|
-
if (rejectedKeys.length === 0) return;
|
|
649
|
-
this.write("warn", "telemetry.metric_attributes_rejected", {
|
|
650
|
-
metricName,
|
|
651
|
-
rejectedAttributeKeys: rejectedKeys
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
};
|
|
655
|
-
TelemetryService = __decorate([
|
|
656
|
-
Injectable(),
|
|
657
|
-
__decorateParam(0, Inject(PinoLogger)),
|
|
658
|
-
__decorateParam(1, Inject(TelemetryContext)),
|
|
659
|
-
__decorateParam(2, Inject(TelemetryOperationalState)),
|
|
660
|
-
__decorateParam(3, Inject(TELEMETRY_OPTIONS)),
|
|
661
|
-
__decorateParam(4, Inject(TelemetryAdapterDispatcher)),
|
|
662
|
-
__decorateMetadata("design:paramtypes", [
|
|
663
|
-
Object,
|
|
664
|
-
typeof TelemetryContext === "undefined" ? Object : TelemetryContext,
|
|
665
|
-
typeof TelemetryOperationalState === "undefined" ? Object : TelemetryOperationalState,
|
|
666
|
-
Object,
|
|
667
|
-
typeof TelemetryAdapterDispatcher === "undefined" ? Object : TelemetryAdapterDispatcher
|
|
668
|
-
])
|
|
669
|
-
], TelemetryService);
|
|
670
|
-
|
|
671
|
-
// src/modules/telemetry/core/create-telemetry.ts
|
|
672
|
-
function createTelemetry(options = {}) {
|
|
673
|
-
const context = new TelemetryContext();
|
|
674
|
-
const operationalState = new TelemetryOperationalState();
|
|
675
|
-
const logger = pino({
|
|
676
|
-
hooks: createTelemetryPinoHooks(),
|
|
677
|
-
level: process.env.LOG_LEVEL ?? "info",
|
|
678
|
-
redact: {
|
|
679
|
-
paths: DEFAULT_REDACT_PATHS,
|
|
680
|
-
censor: "[REDACTED]"
|
|
681
|
-
}
|
|
682
|
-
});
|
|
683
|
-
const adapters = new TelemetryAdapterDispatcher(options.adapters ?? [], operationalState);
|
|
684
|
-
return new CheckedTelemetry(new TelemetryService(logger, context, operationalState, options, adapters), adapters, options);
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
// src/modules/telemetry/shared/tracing/span.ts
|
|
688
|
-
function recordError(span, error) {
|
|
689
|
-
try {
|
|
690
|
-
span.recordException(sanitizeError(error));
|
|
691
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
692
|
-
} catch {}
|
|
693
|
-
}
|
|
694
|
-
function endSpan(span) {
|
|
695
|
-
try {
|
|
696
|
-
span.end();
|
|
697
|
-
} catch {}
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
// src/modules/telemetry/shared/utils/promise.ts
|
|
701
|
-
function isPromiseLike(value) {
|
|
702
|
-
return typeof value === "object" && value !== null && typeof value.then === "function";
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
// src/modules/telemetry/core/trace.decorator.ts
|
|
706
|
-
function Trace(name, attributes = {}) {
|
|
707
|
-
return (_target, _propertyKey, descriptor) => {
|
|
708
|
-
const typedDescriptor = descriptor;
|
|
709
|
-
const original = typedDescriptor.value;
|
|
710
|
-
if (!original) return;
|
|
711
|
-
typedDescriptor.value = function traced(...args) {
|
|
712
|
-
const invoke = () => original.apply(this, args);
|
|
713
|
-
if (process.env.TELEMETRY_TRACING_ENABLED === "false") return invoke();
|
|
714
|
-
try {
|
|
715
|
-
return trace.getTracer(readEnv("OTEL_SERVICE_NAME") ?? "unknown-service").startActiveSpan(name, { attributes: sanitizeAttributes(attributes) }, (span) => {
|
|
716
|
-
try {
|
|
717
|
-
const result = invoke();
|
|
718
|
-
if (!isPromiseLike(result)) {
|
|
719
|
-
endSpan(span);
|
|
720
|
-
return result;
|
|
721
|
-
}
|
|
722
|
-
return result.then((value) => {
|
|
723
|
-
endSpan(span);
|
|
724
|
-
return value;
|
|
725
|
-
}, (error) => {
|
|
726
|
-
recordError(span, error);
|
|
727
|
-
endSpan(span);
|
|
728
|
-
throw error;
|
|
729
|
-
});
|
|
730
|
-
} catch (error) {
|
|
731
|
-
recordError(span, error);
|
|
732
|
-
endSpan(span);
|
|
733
|
-
throw error;
|
|
734
|
-
}
|
|
735
|
-
});
|
|
736
|
-
} catch {
|
|
737
|
-
return invoke();
|
|
738
|
-
}
|
|
739
|
-
};
|
|
740
|
-
};
|
|
741
|
-
}
|
|
742
|
-
|
|
743
18
|
// src/modules/telemetry/nest/health/indicator.ts
|
|
744
19
|
let TelemetryHealthIndicator = class TelemetryHealthIndicator {
|
|
745
20
|
operationalState;
|
|
@@ -768,6 +43,45 @@ __decorate([Inject(TelemetryOperationalState), __decorateMetadata("design:type",
|
|
|
768
43
|
__decorate([Inject(TELEMETRY_OPTIONS), __decorateMetadata("design:type", Object)], TelemetryHealthIndicator.prototype, "options", void 0);
|
|
769
44
|
TelemetryHealthIndicator = __decorate([Injectable()], TelemetryHealthIndicator);
|
|
770
45
|
|
|
46
|
+
// src/modules/telemetry/nest/loggers/nest.ts
|
|
47
|
+
let TelemetryNestLogger = class TelemetryNestLogger {
|
|
48
|
+
logger;
|
|
49
|
+
constructor(logger) {
|
|
50
|
+
this.logger = logger;
|
|
51
|
+
}
|
|
52
|
+
log(message, ...optionalParams) {
|
|
53
|
+
this.write("info", message, optionalParams);
|
|
54
|
+
}
|
|
55
|
+
error(message, ...optionalParams) {
|
|
56
|
+
this.write("error", message, optionalParams);
|
|
57
|
+
}
|
|
58
|
+
warn(message, ...optionalParams) {
|
|
59
|
+
this.write("warn", message, optionalParams);
|
|
60
|
+
}
|
|
61
|
+
debug(message, ...optionalParams) {
|
|
62
|
+
this.write("debug", message, optionalParams);
|
|
63
|
+
}
|
|
64
|
+
verbose(message, ...optionalParams) {
|
|
65
|
+
this.write("trace", message, optionalParams);
|
|
66
|
+
}
|
|
67
|
+
fatal(message, ...optionalParams) {
|
|
68
|
+
this.write("fatal", message, optionalParams);
|
|
69
|
+
}
|
|
70
|
+
write(level, message, optionalParams) {
|
|
71
|
+
this.logger[level].call(this.logger, this.sanitizeLogValue(message), ...optionalParams.map((value) => this.sanitizeLogValue(value)));
|
|
72
|
+
}
|
|
73
|
+
sanitizeLogValue(value) {
|
|
74
|
+
if (value instanceof Error) return sanitizeError(value);
|
|
75
|
+
if (typeof value === "string") return sanitizeText(value);
|
|
76
|
+
return sanitize(value);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
TelemetryNestLogger = __decorate([
|
|
80
|
+
Injectable(),
|
|
81
|
+
__decorateParam(0, Inject(PinoLogger)),
|
|
82
|
+
__decorateMetadata("design:paramtypes", [Object])
|
|
83
|
+
], TelemetryNestLogger);
|
|
84
|
+
|
|
771
85
|
// src/modules/telemetry/shared/http/log.ts
|
|
772
86
|
function resolveHttpSuccessLogsEnabled(logging) {
|
|
773
87
|
if (logging?.httpSuccessLogs !== void 0) return logging.httpSuccessLogs;
|
|
@@ -894,7 +208,7 @@ var TelemetryFastifyLogController = class extends LogController {
|
|
|
894
208
|
}
|
|
895
209
|
};
|
|
896
210
|
|
|
897
|
-
// src/modules/telemetry/
|
|
211
|
+
// src/modules/telemetry/nest/http/error-response.ts
|
|
898
212
|
function defaultCode(statusCode) {
|
|
899
213
|
return {
|
|
900
214
|
400: "BAD_REQUEST",
|
|
@@ -1026,45 +340,6 @@ TelemetryHttpInterceptor = __decorate([Injectable(), __decorateMetadata("design:
|
|
|
1026
340
|
Object
|
|
1027
341
|
])], TelemetryHttpInterceptor);
|
|
1028
342
|
|
|
1029
|
-
// src/modules/telemetry/nest/loggers/nest.ts
|
|
1030
|
-
let TelemetryNestLogger = class TelemetryNestLogger {
|
|
1031
|
-
logger;
|
|
1032
|
-
constructor(logger) {
|
|
1033
|
-
this.logger = logger;
|
|
1034
|
-
}
|
|
1035
|
-
log(message, ...optionalParams) {
|
|
1036
|
-
this.write("info", message, optionalParams);
|
|
1037
|
-
}
|
|
1038
|
-
error(message, ...optionalParams) {
|
|
1039
|
-
this.write("error", message, optionalParams);
|
|
1040
|
-
}
|
|
1041
|
-
warn(message, ...optionalParams) {
|
|
1042
|
-
this.write("warn", message, optionalParams);
|
|
1043
|
-
}
|
|
1044
|
-
debug(message, ...optionalParams) {
|
|
1045
|
-
this.write("debug", message, optionalParams);
|
|
1046
|
-
}
|
|
1047
|
-
verbose(message, ...optionalParams) {
|
|
1048
|
-
this.write("trace", message, optionalParams);
|
|
1049
|
-
}
|
|
1050
|
-
fatal(message, ...optionalParams) {
|
|
1051
|
-
this.write("fatal", message, optionalParams);
|
|
1052
|
-
}
|
|
1053
|
-
write(level, message, optionalParams) {
|
|
1054
|
-
this.logger[level].call(this.logger, this.sanitizeLogValue(message), ...optionalParams.map((value) => this.sanitizeLogValue(value)));
|
|
1055
|
-
}
|
|
1056
|
-
sanitizeLogValue(value) {
|
|
1057
|
-
if (value instanceof Error) return sanitizeError(value);
|
|
1058
|
-
if (typeof value === "string") return sanitizeText(value);
|
|
1059
|
-
return sanitize(value);
|
|
1060
|
-
}
|
|
1061
|
-
};
|
|
1062
|
-
TelemetryNestLogger = __decorate([
|
|
1063
|
-
Injectable(),
|
|
1064
|
-
__decorateParam(0, Inject(PinoLogger)),
|
|
1065
|
-
__decorateMetadata("design:paramtypes", [Object])
|
|
1066
|
-
], TelemetryNestLogger);
|
|
1067
|
-
|
|
1068
343
|
// src/modules/telemetry/nest/middlewares/context.ts
|
|
1069
344
|
let TelemetryContextMiddleware = class TelemetryContextMiddleware {
|
|
1070
345
|
context;
|
|
@@ -1158,15 +433,34 @@ let TelemetryModule = _TelemetryModule = class TelemetryModule {
|
|
|
1158
433
|
provide: TELEMETRY_OPTIONS,
|
|
1159
434
|
useValue: options
|
|
1160
435
|
},
|
|
1161
|
-
|
|
436
|
+
{
|
|
437
|
+
provide: TelemetryContext,
|
|
438
|
+
useFactory: (logger) => new TelemetryContext(logger),
|
|
439
|
+
inject: [{
|
|
440
|
+
token: PinoLogger,
|
|
441
|
+
optional: true
|
|
442
|
+
}]
|
|
443
|
+
},
|
|
1162
444
|
TelemetryContextMiddleware,
|
|
1163
|
-
|
|
445
|
+
{
|
|
446
|
+
provide: TelemetryOperationalState,
|
|
447
|
+
useFactory: () => new TelemetryOperationalState()
|
|
448
|
+
},
|
|
1164
449
|
{
|
|
1165
450
|
provide: TelemetryAdapterDispatcher,
|
|
1166
451
|
useFactory: (state) => new TelemetryAdapterDispatcher(options.adapters ?? [], state),
|
|
1167
452
|
inject: [TelemetryOperationalState]
|
|
1168
453
|
},
|
|
1169
|
-
|
|
454
|
+
{
|
|
455
|
+
provide: TelemetryService,
|
|
456
|
+
useFactory: (logger, context, state, dispatcher) => new TelemetryService(logger, context, state, options, dispatcher),
|
|
457
|
+
inject: [
|
|
458
|
+
PinoLogger,
|
|
459
|
+
TelemetryContext,
|
|
460
|
+
TelemetryOperationalState,
|
|
461
|
+
TelemetryAdapterDispatcher
|
|
462
|
+
]
|
|
463
|
+
},
|
|
1170
464
|
TelemetryExceptionFilter,
|
|
1171
465
|
TelemetryHealthIndicator,
|
|
1172
466
|
TelemetryShutdownService,
|