@easyweb/logging 1.0.1 → 1.1.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 +32 -0
- package/dist/logger.d.ts +13 -3
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +37 -2
- package/dist/logger.js.map +1 -1
- package/dist/register.d.ts +2 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +9 -0
- package/dist/register.js.map +1 -0
- package/dist/telemetry.d.ts +8 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +54 -0
- package/dist/telemetry.js.map +1 -0
- package/package.json +21 -3
package/README.md
CHANGED
|
@@ -32,6 +32,13 @@ log.info({ projectId }, "Project created");
|
|
|
32
32
|
pino merges the mixin UNDER the object the call site passed, so an explicit
|
|
33
33
|
field always wins over an ambient one.
|
|
34
34
|
|
|
35
|
+
**The mixin hands pino a COPY of the scope (1.0.2).** pino's default merge is
|
|
36
|
+
`Object.assign(mixinObject, mergeObject)`, and 1.0.1 returned the live store —
|
|
37
|
+
so every call's fields were written into the request's context and appeared on
|
|
38
|
+
every later line of that request, an `err` included. It also skips any key the
|
|
39
|
+
logger already binds, which is why a `getLogger(req)` line or a subscriber's
|
|
40
|
+
`child({ requestId, queue })` line now carries `requestId` once, not twice.
|
|
41
|
+
|
|
35
42
|
## Usage
|
|
36
43
|
|
|
37
44
|
```ts
|
|
@@ -108,3 +115,28 @@ operator-create refusal, and a Google registration — and they are the signup
|
|
|
108
115
|
audit trail: `userId` alone cannot answer "which address did they sign up
|
|
109
116
|
with". The exposure is real and bounded by log retention. See
|
|
110
117
|
`docs/platform/ADR-0001`.
|
|
118
|
+
|
|
119
|
+
## Tracing (OpenTelemetry)
|
|
120
|
+
|
|
121
|
+
`@easyweb/logging/register` starts the OpenTelemetry SDK on import. Make it the
|
|
122
|
+
**first** import of a service's entry file, before anything that loads `http`,
|
|
123
|
+
`express`, `pg`, `ioredis`, `amqplib`, `undici` or `pino`:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import "@easyweb/logging/register";
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The instrumentations patch those modules as they are required, so a module
|
|
130
|
+
loaded earlier is never traced. Pino lines gain `trace_id` and `span_id` next to
|
|
131
|
+
the existing `requestId`.
|
|
132
|
+
|
|
133
|
+
It is inert unless configured: it starts only when `OTEL_EXPORTER_OTLP_ENDPOINT`
|
|
134
|
+
or `OTEL_TRACES_EXPORTER` is set and non-empty, and `OTEL_SDK_DISABLED=true`
|
|
135
|
+
always wins. The service name is `OTEL_SERVICE_NAME`, else `SERVICE_NAME`, else
|
|
136
|
+
`unknown-service`. Exporter, endpoint and sampler come from the standard
|
|
137
|
+
`OTEL_*` variables. `/health`, `/livez` and `/api/heartbeat` are not traced.
|
|
138
|
+
Note that `OTEL_TRACES_EXPORTER=none` registers no tracer provider, so spans are
|
|
139
|
+
non-recording and carry no `trace_id`.
|
|
140
|
+
|
|
141
|
+
`npm run check:telemetry` builds and proves the `trace_id` injection against
|
|
142
|
+
`dist/`; it cannot be a jest test because jest bypasses the require hooks.
|
package/dist/logger.d.ts
CHANGED
|
@@ -25,9 +25,11 @@ export interface ServiceLoggerOptions {
|
|
|
25
25
|
export interface ServiceLogger {
|
|
26
26
|
logger: pino.Logger;
|
|
27
27
|
/**
|
|
28
|
-
* Kept for the ~42 files that import it
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* Kept for the ~42 files that import it, and still a child logger: a line
|
|
29
|
+
* logged from `res.on("close")` or a socket callback runs OUTSIDE the request
|
|
30
|
+
* scope, and the bound `requestId` is the only one it carries. Inside the
|
|
31
|
+
* scope the mixin skips the key the child already binds, so the line carries
|
|
32
|
+
* it once rather than twice.
|
|
31
33
|
*/
|
|
32
34
|
getLogger: (req: Request) => pino.Logger;
|
|
33
35
|
}
|
|
@@ -39,6 +41,14 @@ export interface ServiceLogger {
|
|
|
39
41
|
* explicit field always wins over the ambient one. That is what lets every
|
|
40
42
|
* existing `log.info({ projectId }, "...")` gain a requestId without being
|
|
41
43
|
* touched.
|
|
44
|
+
*
|
|
45
|
+
* **The mixin returns a COPY of the scope, and 1.0.1's did not.** pino's
|
|
46
|
+
* default merge is `Object.assign(mixinObject, mergeObject)`, so returning the
|
|
47
|
+
* live store wrote every call's fields INTO the request's context — and every
|
|
48
|
+
* later line in that request carried them. A production build's "Initial build
|
|
49
|
+
* failed" line carried `path: "middleware.ts"`, `tool: "screenshot"`, a design
|
|
50
|
+
* retrieval's diagnostics and an `err` from a different call entirely. "An
|
|
51
|
+
* explicit field always wins" was true of one line and false of the next.
|
|
42
52
|
*/
|
|
43
53
|
export declare function createServiceLogger(options: ServiceLoggerOptions): ServiceLogger;
|
|
44
54
|
//# sourceMappingURL=logger.d.ts.map
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMvC,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;CAClD;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;IACpB
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMvC,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;CAClD;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC;CAC1C;AAsBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,oBAAoB,GAC5B,aAAa,CA4Df"}
|
package/dist/logger.js
CHANGED
|
@@ -9,6 +9,24 @@ const context_1 = require("./context");
|
|
|
9
9
|
const redact_1 = require("./redact");
|
|
10
10
|
const serialize_1 = require("./serialize");
|
|
11
11
|
const transport_1 = require("./transport");
|
|
12
|
+
/**
|
|
13
|
+
* The keys a logger already writes itself, per logger instance.
|
|
14
|
+
*
|
|
15
|
+
* pino writes a child's bindings as a pre-built string and appends the merged
|
|
16
|
+
* object after it without de-duplicating, so an ambient key a child also binds
|
|
17
|
+
* appeared twice on every line — `getLogger(req)` binding `requestId` inside a
|
|
18
|
+
* scope that carries it too. Cached because `bindings()` re-parses that string
|
|
19
|
+
* on every call, and a logger's bindings do not change after it is made.
|
|
20
|
+
*/
|
|
21
|
+
const boundKeys = new WeakMap();
|
|
22
|
+
function keysBoundBy(logger) {
|
|
23
|
+
let keys = boundKeys.get(logger);
|
|
24
|
+
if (!keys) {
|
|
25
|
+
keys = new Set(Object.keys(logger.bindings()));
|
|
26
|
+
boundKeys.set(logger, keys);
|
|
27
|
+
}
|
|
28
|
+
return keys;
|
|
29
|
+
}
|
|
12
30
|
/**
|
|
13
31
|
* Builds the service's root logger.
|
|
14
32
|
*
|
|
@@ -17,6 +35,14 @@ const transport_1 = require("./transport");
|
|
|
17
35
|
* explicit field always wins over the ambient one. That is what lets every
|
|
18
36
|
* existing `log.info({ projectId }, "...")` gain a requestId without being
|
|
19
37
|
* touched.
|
|
38
|
+
*
|
|
39
|
+
* **The mixin returns a COPY of the scope, and 1.0.1's did not.** pino's
|
|
40
|
+
* default merge is `Object.assign(mixinObject, mergeObject)`, so returning the
|
|
41
|
+
* live store wrote every call's fields INTO the request's context — and every
|
|
42
|
+
* later line in that request carried them. A production build's "Initial build
|
|
43
|
+
* failed" line carried `path: "middleware.ts"`, `tool: "screenshot"`, a design
|
|
44
|
+
* retrieval's diagnostics and an `err` from a different call entirely. "An
|
|
45
|
+
* explicit field always wins" was true of one line and false of the next.
|
|
20
46
|
*/
|
|
21
47
|
function createServiceLogger(options) {
|
|
22
48
|
const env = options.env ?? process.env.NODE_ENV ?? "development";
|
|
@@ -38,9 +64,18 @@ function createServiceLogger(options) {
|
|
|
38
64
|
* calls are overwhelmingly on error paths — the failure would swallow
|
|
39
65
|
* exactly the line somebody needed.
|
|
40
66
|
*/
|
|
41
|
-
mixin() {
|
|
67
|
+
mixin(_mergeObject, _level, instance) {
|
|
42
68
|
try {
|
|
43
|
-
|
|
69
|
+
const context = (0, context_1.getContext)();
|
|
70
|
+
if (!context)
|
|
71
|
+
return {};
|
|
72
|
+
const bound = keysBoundBy(instance);
|
|
73
|
+
const ambient = {};
|
|
74
|
+
for (const [key, value] of Object.entries(context)) {
|
|
75
|
+
if (!bound.has(key))
|
|
76
|
+
ambient[key] = value;
|
|
77
|
+
}
|
|
78
|
+
return ambient;
|
|
44
79
|
}
|
|
45
80
|
catch {
|
|
46
81
|
return {};
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":""}
|
package/dist/register.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const telemetry_1 = require("./telemetry");
|
|
4
|
+
(0, telemetry_1.createTelemetrySdk)(process.env)?.start();
|
|
5
|
+
// Must be the FIRST import of a service entry file. The instrumentations patch
|
|
6
|
+
// http, express, pg, ioredis, amqplib, undici and pino by hooking require, so
|
|
7
|
+
// any of those loaded before this line is never traced. Do not import ./logger
|
|
8
|
+
// or ./index here for the same reason.
|
|
9
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":";;AAAA,2CAAiD;AAEjD,IAAA,8BAAkB,EAAC,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC;AAEzC,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,uCAAuC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
2
|
+
import type { Instrumentation } from "@opentelemetry/instrumentation";
|
|
3
|
+
export declare function shouldStartTelemetry(env: NodeJS.ProcessEnv): boolean;
|
|
4
|
+
export declare function telemetryServiceName(env: NodeJS.ProcessEnv): string;
|
|
5
|
+
export declare function isProbePath(url: string | undefined): boolean;
|
|
6
|
+
export declare function telemetryInstrumentations(): Instrumentation[];
|
|
7
|
+
export declare function createTelemetrySdk(env: NodeJS.ProcessEnv): NodeSDK | null;
|
|
8
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AActE,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAGpE;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAEnE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAI5D;AAED,wBAAgB,yBAAyB,IAAI,eAAe,EAAE,CAU7D;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,GAAG,IAAI,CAQzE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldStartTelemetry = shouldStartTelemetry;
|
|
4
|
+
exports.telemetryServiceName = telemetryServiceName;
|
|
5
|
+
exports.isProbePath = isProbePath;
|
|
6
|
+
exports.telemetryInstrumentations = telemetryInstrumentations;
|
|
7
|
+
exports.createTelemetrySdk = createTelemetrySdk;
|
|
8
|
+
const sdk_node_1 = require("@opentelemetry/sdk-node");
|
|
9
|
+
const instrumentation_http_1 = require("@opentelemetry/instrumentation-http");
|
|
10
|
+
const instrumentation_express_1 = require("@opentelemetry/instrumentation-express");
|
|
11
|
+
const instrumentation_undici_1 = require("@opentelemetry/instrumentation-undici");
|
|
12
|
+
const instrumentation_pg_1 = require("@opentelemetry/instrumentation-pg");
|
|
13
|
+
const instrumentation_ioredis_1 = require("@opentelemetry/instrumentation-ioredis");
|
|
14
|
+
const instrumentation_amqplib_1 = require("@opentelemetry/instrumentation-amqplib");
|
|
15
|
+
const instrumentation_pino_1 = require("@opentelemetry/instrumentation-pino");
|
|
16
|
+
// Deliberately imports nothing from ./logger or ./index: this file must load
|
|
17
|
+
// before pino, http, pg, ... so the SDK can patch them as they are required.
|
|
18
|
+
const PROBE_PATHS = new Set(["/health", "/livez", "/api/heartbeat"]);
|
|
19
|
+
function shouldStartTelemetry(env) {
|
|
20
|
+
if (env["OTEL_SDK_DISABLED"] === "true")
|
|
21
|
+
return false;
|
|
22
|
+
return Boolean(env["OTEL_EXPORTER_OTLP_ENDPOINT"] || env["OTEL_TRACES_EXPORTER"]);
|
|
23
|
+
}
|
|
24
|
+
function telemetryServiceName(env) {
|
|
25
|
+
return env["OTEL_SERVICE_NAME"] || env["SERVICE_NAME"] || "unknown-service";
|
|
26
|
+
}
|
|
27
|
+
function isProbePath(url) {
|
|
28
|
+
if (!url)
|
|
29
|
+
return false;
|
|
30
|
+
const path = url.split("?")[0] ?? "";
|
|
31
|
+
return PROBE_PATHS.has(path);
|
|
32
|
+
}
|
|
33
|
+
function telemetryInstrumentations() {
|
|
34
|
+
return [
|
|
35
|
+
new instrumentation_http_1.HttpInstrumentation({ ignoreIncomingRequestHook: (req) => isProbePath(req.url) }),
|
|
36
|
+
new instrumentation_express_1.ExpressInstrumentation(),
|
|
37
|
+
new instrumentation_undici_1.UndiciInstrumentation(),
|
|
38
|
+
new instrumentation_pg_1.PgInstrumentation(),
|
|
39
|
+
new instrumentation_ioredis_1.IORedisInstrumentation(),
|
|
40
|
+
new instrumentation_amqplib_1.AmqplibInstrumentation(),
|
|
41
|
+
new instrumentation_pino_1.PinoInstrumentation(),
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
function createTelemetrySdk(env) {
|
|
45
|
+
if (!shouldStartTelemetry(env))
|
|
46
|
+
return null;
|
|
47
|
+
// No traceExporter: OTEL_TRACES_EXPORTER, OTEL_EXPORTER_OTLP_* and
|
|
48
|
+
// OTEL_TRACES_SAMPLER* are read from the environment by the SDK.
|
|
49
|
+
return new sdk_node_1.NodeSDK({
|
|
50
|
+
serviceName: telemetryServiceName(env),
|
|
51
|
+
instrumentations: telemetryInstrumentations(),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":";;AAeA,oDAGC;AAED,oDAEC;AAED,kCAIC;AAED,8DAUC;AAED,gDAQC;AAlDD,sDAAkD;AAElD,8EAA0E;AAC1E,oFAAgF;AAChF,kFAA8E;AAC9E,0EAAsE;AACtE,oFAAgF;AAChF,oFAAgF;AAChF,8EAA0E;AAE1E,6EAA6E;AAC7E,6EAA6E;AAE7E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAErE,SAAgB,oBAAoB,CAAC,GAAsB;IACzD,IAAI,GAAG,CAAC,mBAAmB,CAAC,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACtD,OAAO,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,IAAI,GAAG,CAAC,sBAAsB,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,SAAgB,oBAAoB,CAAC,GAAsB;IACzD,OAAO,GAAG,CAAC,mBAAmB,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,IAAI,iBAAiB,CAAC;AAC9E,CAAC;AAED,SAAgB,WAAW,CAAC,GAAuB;IACjD,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACrC,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED,SAAgB,yBAAyB;IACvC,OAAO;QACL,IAAI,0CAAmB,CAAC,EAAE,yBAAyB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACrF,IAAI,gDAAsB,EAAE;QAC5B,IAAI,8CAAqB,EAAE;QAC3B,IAAI,sCAAiB,EAAE;QACvB,IAAI,gDAAsB,EAAE;QAC5B,IAAI,gDAAsB,EAAE;QAC5B,IAAI,0CAAmB,EAAE;KAC1B,CAAC;AACJ,CAAC;AAED,SAAgB,kBAAkB,CAAC,GAAsB;IACvD,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5C,mEAAmE;IACnE,iEAAiE;IACjE,OAAO,IAAI,kBAAO,CAAC;QACjB,WAAW,EAAE,oBAAoB,CAAC,GAAG,CAAC;QACtC,gBAAgB,EAAE,yBAAyB,EAAE;KAC9C,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyweb/logging",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Shared structured logging for Easyweb microservices: one pino configuration, request-scoped context over AsyncLocalStorage, an HTTP access log, and the redaction every service needs before its logs leave the pod",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
"require": "./dist/index.js",
|
|
10
10
|
"import": "./dist/index.js",
|
|
11
11
|
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./register": {
|
|
14
|
+
"require": "./dist/register.js",
|
|
15
|
+
"import": "./dist/register.js",
|
|
16
|
+
"types": "./dist/register.d.ts"
|
|
12
17
|
}
|
|
13
18
|
},
|
|
14
19
|
"files": [
|
|
@@ -22,7 +27,8 @@
|
|
|
22
27
|
"clean": "rimraf dist",
|
|
23
28
|
"test": "jest",
|
|
24
29
|
"typecheck": "tsc --noEmit",
|
|
25
|
-
"typecheck:test": "tsc -p tsconfig.test.json --noEmit"
|
|
30
|
+
"typecheck:test": "tsc -p tsconfig.test.json --noEmit",
|
|
31
|
+
"check:telemetry": "npm run build && node scripts/check-telemetry.js"
|
|
26
32
|
},
|
|
27
33
|
"keywords": [
|
|
28
34
|
"microservices",
|
|
@@ -55,9 +61,21 @@
|
|
|
55
61
|
"typescript": "^6.0.3"
|
|
56
62
|
},
|
|
57
63
|
"engines": {
|
|
58
|
-
"node": ">=
|
|
64
|
+
"node": ">=22.15.0"
|
|
59
65
|
},
|
|
60
66
|
"publishConfig": {
|
|
61
67
|
"access": "public"
|
|
68
|
+
},
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"@opentelemetry/api": "^1.10.0",
|
|
71
|
+
"@opentelemetry/instrumentation": "^0.301.2",
|
|
72
|
+
"@opentelemetry/instrumentation-amqplib": "^0.72.0",
|
|
73
|
+
"@opentelemetry/instrumentation-express": "^0.73.0",
|
|
74
|
+
"@opentelemetry/instrumentation-http": "^0.301.2",
|
|
75
|
+
"@opentelemetry/instrumentation-ioredis": "^0.73.0",
|
|
76
|
+
"@opentelemetry/instrumentation-pg": "^0.78.0",
|
|
77
|
+
"@opentelemetry/instrumentation-pino": "^0.71.0",
|
|
78
|
+
"@opentelemetry/instrumentation-undici": "^0.35.1",
|
|
79
|
+
"@opentelemetry/sdk-node": "^0.301.2"
|
|
62
80
|
}
|
|
63
81
|
}
|