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