@eventuras/logger 0.7.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 +309 -0
- package/dist/Logger.d.ts +105 -0
- package/dist/Logger.d.ts.map +1 -0
- package/dist/__vite-browser-external-pQ4XsTOI.js +7 -0
- package/dist/chunk-NnHqS4_Y.js +20 -0
- package/dist/esm-B1-Y8LUx.js +1580 -0
- package/dist/esm-wJpbN37y.js +528 -0
- package/dist/httpLogger.d.ts +18 -0
- package/dist/httpLogger.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +607 -0
- package/dist/node.d.ts +12 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +2 -0
- package/dist/opentelemetry.d.ts +136 -0
- package/dist/opentelemetry.d.ts.map +1 -0
- package/dist/opentelemetry.js +44 -0
- package/dist/pretty-BTJ0fKhV.js +114 -0
- package/dist/src-V4zpQbfq.js +406 -0
- package/dist/transports/console.d.ts +11 -0
- package/dist/transports/console.d.ts.map +1 -0
- package/dist/transports/pino.d.ts +24 -0
- package/dist/transports/pino.d.ts.map +1 -0
- package/dist/transports/pretty.d.ts +20 -0
- package/dist/transports/pretty.d.ts.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenTelemetry integration for @eventuras/logger
|
|
3
|
+
*
|
|
4
|
+
* This module provides integration between Pino and OpenTelemetry Logs API.
|
|
5
|
+
* It allows sending logs to any OpenTelemetry-compatible backend (Sentry, Grafana, Jaeger, etc.)
|
|
6
|
+
* without vendor lock-in.
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This module requires OpenTelemetry packages to be installed as peer dependencies.
|
|
9
|
+
* If they are not available, the integration will gracefully disable itself.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // In your app's instrumentation.ts or main entry point
|
|
13
|
+
* import { setupOpenTelemetryLogger } from '@eventuras/logger/opentelemetry';
|
|
14
|
+
* import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
|
|
15
|
+
* import { BatchLogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
16
|
+
*
|
|
17
|
+
* setupOpenTelemetryLogger({
|
|
18
|
+
* logRecordProcessor: new BatchLogRecordProcessor(
|
|
19
|
+
* new OTLPLogExporter({
|
|
20
|
+
* url: 'https://[org].ingest.sentry.io/api/[project]/integration/otlp/v1/logs',
|
|
21
|
+
* headers: { 'x-sentry-auth': 'sentry sentry_key=...' }
|
|
22
|
+
* })
|
|
23
|
+
* )
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Then use logger as normal
|
|
28
|
+
* import { Logger } from '@eventuras/logger';
|
|
29
|
+
*
|
|
30
|
+
* const logger = Logger.create({ namespace: 'MyService' });
|
|
31
|
+
* logger.error({ error: err }, 'Something failed'); // Sent to OpenTelemetry backend
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Minimal interface for an OpenTelemetry LogRecordProcessor.
|
|
35
|
+
* Compatible with `@opentelemetry/sdk-logs` `LogRecordProcessor`.
|
|
36
|
+
* Defined locally to avoid requiring OTel types at compile time.
|
|
37
|
+
*/
|
|
38
|
+
export interface LogRecordProcessor {
|
|
39
|
+
shutdown(): Promise<void>;
|
|
40
|
+
forceFlush(): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Minimal interface for an OpenTelemetry LoggerProvider.
|
|
44
|
+
* Compatible with `@opentelemetry/sdk-logs` `LoggerProvider`.
|
|
45
|
+
*/
|
|
46
|
+
export interface OTelLoggerProvider {
|
|
47
|
+
addLogRecordProcessor(processor: LogRecordProcessor): void;
|
|
48
|
+
shutdown(): Promise<void>;
|
|
49
|
+
forceFlush?(): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Options for OpenTelemetry logger integration
|
|
53
|
+
*/
|
|
54
|
+
export type OpenTelemetryLoggerOptions = {
|
|
55
|
+
/**
|
|
56
|
+
* Log record processor (e.g., BatchLogRecordProcessor with an exporter).
|
|
57
|
+
* If not provided, logs will only be instrumented but not exported.
|
|
58
|
+
*/
|
|
59
|
+
logRecordProcessor?: LogRecordProcessor;
|
|
60
|
+
/**
|
|
61
|
+
* Logger provider instance. If not provided, a new one will be created.
|
|
62
|
+
*/
|
|
63
|
+
loggerProvider?: OTelLoggerProvider;
|
|
64
|
+
/**
|
|
65
|
+
* Service name to attach to log records.
|
|
66
|
+
* Defaults to the `OTEL_SERVICE_NAME` environment variable, or `'unknown-service'`.
|
|
67
|
+
*/
|
|
68
|
+
serviceName?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Whether to enable the integration. Default: true
|
|
71
|
+
*/
|
|
72
|
+
enabled?: boolean;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Set up OpenTelemetry integration for Pino logger.
|
|
76
|
+
*
|
|
77
|
+
* This function:
|
|
78
|
+
* 1. Creates or uses provided LoggerProvider
|
|
79
|
+
* 2. Registers the log record processor (for exporting logs)
|
|
80
|
+
* 3. Enables Pino instrumentation to bridge Pino logs to OTel
|
|
81
|
+
*
|
|
82
|
+
* Call this function once at application startup, before creating any loggers.
|
|
83
|
+
*
|
|
84
|
+
* @param options - Configuration options
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Send to Sentry via OTLP
|
|
88
|
+
* import { setupOpenTelemetryLogger } from '@eventuras/logger';
|
|
89
|
+
* import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
|
|
90
|
+
* import { BatchLogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
91
|
+
*
|
|
92
|
+
* setupOpenTelemetryLogger({
|
|
93
|
+
* logRecordProcessor: new BatchLogRecordProcessor(
|
|
94
|
+
* new OTLPLogExporter({
|
|
95
|
+
* url: process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT,
|
|
96
|
+
* headers: {
|
|
97
|
+
* 'x-sentry-auth': `sentry sentry_key=${process.env.SENTRY_KEY}`
|
|
98
|
+
* }
|
|
99
|
+
* })
|
|
100
|
+
* )
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* // Use environment variables (recommended)
|
|
105
|
+
* // Set these in your environment:
|
|
106
|
+
* // OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://[org].ingest.sentry.io/api/[project]/integration/otlp/v1/logs
|
|
107
|
+
* // OTEL_EXPORTER_OTLP_LOGS_HEADERS=x-sentry-auth=sentry sentry_key=...
|
|
108
|
+
*
|
|
109
|
+
* import { setupOpenTelemetryLogger } from '@eventuras/logger';
|
|
110
|
+
* import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
|
|
111
|
+
* import { BatchLogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
112
|
+
*
|
|
113
|
+
* await setupOpenTelemetryLogger({
|
|
114
|
+
* logRecordProcessor: new BatchLogRecordProcessor(
|
|
115
|
+
* new OTLPLogExporter() // Reads from env vars
|
|
116
|
+
* )
|
|
117
|
+
* });
|
|
118
|
+
*/
|
|
119
|
+
export declare function setupOpenTelemetryLogger(options?: OpenTelemetryLoggerOptions): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Shut down the OpenTelemetry logger integration.
|
|
122
|
+
* Call this when your application is shutting down to flush any pending logs.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* process.on('SIGTERM', async () => {
|
|
126
|
+
* await shutdownOpenTelemetryLogger();
|
|
127
|
+
* process.exit(0);
|
|
128
|
+
* });
|
|
129
|
+
*/
|
|
130
|
+
export declare function shutdownOpenTelemetryLogger(): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Get the active LoggerProvider instance, if any.
|
|
133
|
+
* Useful for advanced use cases or debugging.
|
|
134
|
+
*/
|
|
135
|
+
export declare function getLoggerProvider(): OTelLoggerProvider | null;
|
|
136
|
+
//# sourceMappingURL=opentelemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opentelemetry.d.ts","sourceRoot":"","sources":["../src/opentelemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,qBAAqB,CAAC,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC3D,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAwBD;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC;;OAEG;IACH,cAAc,CAAC,EAAE,kBAAkB,CAAC;IAEpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAKF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,IAAI,CAAC,CA+Df;AAED;;;;;;;;;GASG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC,CAiBjE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,kBAAkB,GAAG,IAAI,CAO7D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { a as e } from "./chunk-NnHqS4_Y.js";
|
|
2
|
+
//#region src/opentelemetry.ts
|
|
3
|
+
async function t() {
|
|
4
|
+
try {
|
|
5
|
+
let [t, n] = await Promise.all([import("./src-V4zpQbfq.js").then((t) => /* @__PURE__ */ e(t.default, 1)), import("./esm-wJpbN37y.js")]);
|
|
6
|
+
return {
|
|
7
|
+
PinoInstrumentation: t.PinoInstrumentation,
|
|
8
|
+
LoggerProvider: n.LoggerProvider
|
|
9
|
+
};
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
var n = null, r = null;
|
|
15
|
+
async function i(e = {}) {
|
|
16
|
+
if (typeof window < "u") {
|
|
17
|
+
console.warn("[logger] OpenTelemetry integration is server-side only - skipping in browser");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let { logRecordProcessor: i, loggerProvider: a, serviceName: o, enabled: s = !0 } = e;
|
|
21
|
+
if (!s) {
|
|
22
|
+
console.log("[logger] OpenTelemetry integration disabled");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
let c = await t();
|
|
26
|
+
if (!c) {
|
|
27
|
+
console.warn("[logger] OpenTelemetry packages not available - integration disabled"), console.warn("[logger] Install @opentelemetry/* packages to enable OpenTelemetry integration");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let { PinoInstrumentation: l, LoggerProvider: u } = c;
|
|
31
|
+
n &&= (n.disable(), null), r = a ?? new u(), i && r && r.addLogRecordProcessor(i);
|
|
32
|
+
let d = o ?? (typeof process < "u" ? process.env?.OTEL_SERVICE_NAME : void 0) ?? "unknown-service";
|
|
33
|
+
n = new l({ logHook: (e, t) => {
|
|
34
|
+
t["service.name"] = d;
|
|
35
|
+
} }), n.enable(), console.log("[logger] OpenTelemetry integration enabled"), i && console.log("[logger] Log record processor registered");
|
|
36
|
+
}
|
|
37
|
+
async function a() {
|
|
38
|
+
typeof window < "u" || (n &&= (n.disable(), null), r &&= (await r.shutdown(), null), console.log("[logger] OpenTelemetry integration shut down"));
|
|
39
|
+
}
|
|
40
|
+
function o() {
|
|
41
|
+
return typeof window < "u" ? null : r;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { o as getLoggerProvider, i as setupOpenTelemetryLogger, a as shutdownOpenTelemetryLogger };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { t as e } from "./__vite-browser-external-pQ4XsTOI.js";
|
|
2
|
+
//#region src/transports/pretty.ts
|
|
3
|
+
var t = e(), n = {
|
|
4
|
+
reset: "\x1B[0m",
|
|
5
|
+
dim: "\x1B[2m",
|
|
6
|
+
bold: "\x1B[1m",
|
|
7
|
+
red: "\x1B[31m",
|
|
8
|
+
yellow: "\x1B[33m",
|
|
9
|
+
green: "\x1B[32m",
|
|
10
|
+
cyan: "\x1B[36m",
|
|
11
|
+
magenta: "\x1B[35m",
|
|
12
|
+
gray: "\x1B[90m"
|
|
13
|
+
}, r = {
|
|
14
|
+
10: {
|
|
15
|
+
label: "TRACE",
|
|
16
|
+
color: n.gray
|
|
17
|
+
},
|
|
18
|
+
20: {
|
|
19
|
+
label: "DEBUG",
|
|
20
|
+
color: n.cyan
|
|
21
|
+
},
|
|
22
|
+
30: {
|
|
23
|
+
label: "INFO ",
|
|
24
|
+
color: n.green
|
|
25
|
+
},
|
|
26
|
+
40: {
|
|
27
|
+
label: "WARN ",
|
|
28
|
+
color: n.yellow
|
|
29
|
+
},
|
|
30
|
+
50: {
|
|
31
|
+
label: "ERROR",
|
|
32
|
+
color: n.red
|
|
33
|
+
},
|
|
34
|
+
60: {
|
|
35
|
+
label: "FATAL",
|
|
36
|
+
color: `${n.bold}${n.red}`
|
|
37
|
+
}
|
|
38
|
+
}, i = {
|
|
39
|
+
trace: {
|
|
40
|
+
label: "TRACE",
|
|
41
|
+
color: n.gray
|
|
42
|
+
},
|
|
43
|
+
debug: {
|
|
44
|
+
label: "DEBUG",
|
|
45
|
+
color: n.cyan
|
|
46
|
+
},
|
|
47
|
+
info: {
|
|
48
|
+
label: "INFO ",
|
|
49
|
+
color: n.green
|
|
50
|
+
},
|
|
51
|
+
warn: {
|
|
52
|
+
label: "WARN ",
|
|
53
|
+
color: n.yellow
|
|
54
|
+
},
|
|
55
|
+
error: {
|
|
56
|
+
label: "ERROR",
|
|
57
|
+
color: n.red
|
|
58
|
+
},
|
|
59
|
+
fatal: {
|
|
60
|
+
label: "FATAL",
|
|
61
|
+
color: `${n.bold}${n.red}`
|
|
62
|
+
}
|
|
63
|
+
}, a = new Set([
|
|
64
|
+
"level",
|
|
65
|
+
"time",
|
|
66
|
+
"pid",
|
|
67
|
+
"hostname",
|
|
68
|
+
"msg",
|
|
69
|
+
"name",
|
|
70
|
+
"ns",
|
|
71
|
+
"namespace"
|
|
72
|
+
]);
|
|
73
|
+
function o(e) {
|
|
74
|
+
if (typeof e == "string") {
|
|
75
|
+
let t = new Date(e);
|
|
76
|
+
return Number.isNaN(t.getTime()) ? "" : t.toLocaleTimeString("en-GB", { hour12: !1 });
|
|
77
|
+
}
|
|
78
|
+
return typeof e == "number" ? new Date(e).toLocaleTimeString("en-GB", { hour12: !1 }) : (/* @__PURE__ */ new Date()).toLocaleTimeString("en-GB", { hour12: !1 });
|
|
79
|
+
}
|
|
80
|
+
function s(e) {
|
|
81
|
+
let t = {}, r = !1;
|
|
82
|
+
for (let [n, i] of Object.entries(e)) a.has(n) || (t[n] = i, r = !0);
|
|
83
|
+
return r ? ` ${n.dim}${JSON.stringify(t)}${n.reset}` : "";
|
|
84
|
+
}
|
|
85
|
+
function c(e) {
|
|
86
|
+
let t = e.trim();
|
|
87
|
+
if (!t) return "";
|
|
88
|
+
let a;
|
|
89
|
+
try {
|
|
90
|
+
a = JSON.parse(t);
|
|
91
|
+
} catch {
|
|
92
|
+
return t;
|
|
93
|
+
}
|
|
94
|
+
let c = a.level, l = typeof c == "string" ? i[c] ?? {
|
|
95
|
+
label: c.toUpperCase().padEnd(5),
|
|
96
|
+
color: n.gray
|
|
97
|
+
} : r[c] ?? {
|
|
98
|
+
label: `L${c}`,
|
|
99
|
+
color: n.gray
|
|
100
|
+
}, u = o(a.time), d = a.msg ?? "", f = a.namespace || a.ns || a.name || "", p = f ? ` ${n.magenta}(${f})${n.reset}` : "", m = `${n.dim}→${n.reset}`, h = s(a);
|
|
101
|
+
return `${n.dim}${u}${n.reset} ${l.color}${l.label}${n.reset}${p} ${m} ${d}${h}`;
|
|
102
|
+
}
|
|
103
|
+
function l() {
|
|
104
|
+
return new t.Writable({ write(e, t, n) {
|
|
105
|
+
let r = e.toString().split("\n");
|
|
106
|
+
for (let e of r) {
|
|
107
|
+
let t = c(e);
|
|
108
|
+
t && process.stdout.write(t + "\n");
|
|
109
|
+
}
|
|
110
|
+
n();
|
|
111
|
+
} });
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
export { c as n, l as t };
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./chunk-NnHqS4_Y.js";
|
|
2
|
+
import { t as i } from "./__vite-browser-external-pQ4XsTOI.js";
|
|
3
|
+
import { D as a, E as o, O as s, T as c, b as l, n as u, t as d, w as f, x as p, y as m } from "./esm-B1-Y8LUx.js";
|
|
4
|
+
//#region ../../node_modules/.pnpm/@opentelemetry+instrumentation@0.214.0_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/instrumentation/build/esm/autoLoaderUtils.js
|
|
5
|
+
function h(e, t, n, r) {
|
|
6
|
+
for (let i = 0, a = e.length; i < a; i++) {
|
|
7
|
+
let a = e[i];
|
|
8
|
+
t && a.setTracerProvider(t), n && a.setMeterProvider(n), r && a.setLoggerProvider && a.setLoggerProvider(r), a.getConfig().enabled || a.enable();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function g(e) {
|
|
12
|
+
e.forEach((e) => e.disable());
|
|
13
|
+
}
|
|
14
|
+
var _ = t((() => {}));
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../../node_modules/.pnpm/@opentelemetry+instrumentation@0.214.0_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/instrumentation/build/esm/autoLoader.js
|
|
17
|
+
function v(e) {
|
|
18
|
+
let t = e.tracerProvider || o.getTracerProvider(), n = e.meterProvider || a.getMeterProvider(), r = e.loggerProvider || p.getLoggerProvider(), i = e.instrumentations?.flat() ?? [];
|
|
19
|
+
return h(i, t, n, r), () => {
|
|
20
|
+
g(i);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
var y = t((() => {
|
|
24
|
+
c(), l(), _();
|
|
25
|
+
}));
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region ../../node_modules/.pnpm/@opentelemetry+instrumentation@0.214.0_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/instrumentation/build/esm/shimmer.js
|
|
28
|
+
function b(e, t, n) {
|
|
29
|
+
let r = !!e[t] && Object.prototype.propertyIsEnumerable.call(e, t);
|
|
30
|
+
Object.defineProperty(e, t, {
|
|
31
|
+
configurable: !0,
|
|
32
|
+
enumerable: r,
|
|
33
|
+
writable: !0,
|
|
34
|
+
value: n
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function x(e) {
|
|
38
|
+
e && e.logger && (typeof e.logger == "function" ? S = e.logger : S("new logger isn't a function, not replacing"));
|
|
39
|
+
}
|
|
40
|
+
var S, C, w, T, E, D = t((() => {
|
|
41
|
+
S = console.error.bind(console), C = (e, t, n) => {
|
|
42
|
+
if (!e || !e[t]) {
|
|
43
|
+
S("no original function " + String(t) + " to wrap");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!n) {
|
|
47
|
+
S("no wrapper function"), S((/* @__PURE__ */ Error()).stack);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
let r = e[t];
|
|
51
|
+
if (typeof r != "function" || typeof n != "function") {
|
|
52
|
+
S("original object and wrapper must be functions");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let i = n(r, t);
|
|
56
|
+
return b(i, "__original", r), b(i, "__unwrap", () => {
|
|
57
|
+
e[t] === i && b(e, t, r);
|
|
58
|
+
}), b(i, "__wrapped", !0), b(e, t, i), i;
|
|
59
|
+
}, w = (e, t, n) => {
|
|
60
|
+
if (e) Array.isArray(e) || (e = [e]);
|
|
61
|
+
else {
|
|
62
|
+
S("must provide one or more modules to patch"), S((/* @__PURE__ */ Error()).stack);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (!(t && Array.isArray(t))) {
|
|
66
|
+
S("must provide one or more functions to wrap on modules");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
e.forEach((e) => {
|
|
70
|
+
t.forEach((t) => {
|
|
71
|
+
C(e, t, n);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}, T = (e, t) => {
|
|
75
|
+
if (!e || !e[t]) {
|
|
76
|
+
S("no function to unwrap."), S((/* @__PURE__ */ Error()).stack);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
let n = e[t];
|
|
80
|
+
if (!n.__unwrap) S("no original to unwrap to -- has " + String(t) + " already been unwrapped?");
|
|
81
|
+
else {
|
|
82
|
+
n.__unwrap();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}, E = (e, t) => {
|
|
86
|
+
if (e) Array.isArray(e) || (e = [e]);
|
|
87
|
+
else {
|
|
88
|
+
S("must provide one or more modules to patch"), S((/* @__PURE__ */ Error()).stack);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (!(t && Array.isArray(t))) {
|
|
92
|
+
S("must provide one or more functions to unwrap on modules");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
e.forEach((e) => {
|
|
96
|
+
t.forEach((t) => {
|
|
97
|
+
T(e, t);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}, x.wrap = C, x.massWrap = w, x.unwrap = T, x.massUnwrap = E;
|
|
101
|
+
})), O, k = t((() => {
|
|
102
|
+
c(), l(), D(), O = class {
|
|
103
|
+
_config = {};
|
|
104
|
+
_tracer;
|
|
105
|
+
_meter;
|
|
106
|
+
_logger;
|
|
107
|
+
_diag;
|
|
108
|
+
instrumentationName;
|
|
109
|
+
instrumentationVersion;
|
|
110
|
+
constructor(e, t, n) {
|
|
111
|
+
this.instrumentationName = e, this.instrumentationVersion = t, this.setConfig(n), this._diag = s.createComponentLogger({ namespace: e }), this._tracer = o.getTracer(e, t), this._meter = a.getMeter(e, t), this._logger = p.getLogger(e, t), this._updateMetricInstruments();
|
|
112
|
+
}
|
|
113
|
+
_wrap = C;
|
|
114
|
+
_unwrap = T;
|
|
115
|
+
_massWrap = w;
|
|
116
|
+
_massUnwrap = E;
|
|
117
|
+
get meter() {
|
|
118
|
+
return this._meter;
|
|
119
|
+
}
|
|
120
|
+
setMeterProvider(e) {
|
|
121
|
+
this._meter = e.getMeter(this.instrumentationName, this.instrumentationVersion), this._updateMetricInstruments();
|
|
122
|
+
}
|
|
123
|
+
get logger() {
|
|
124
|
+
return this._logger;
|
|
125
|
+
}
|
|
126
|
+
setLoggerProvider(e) {
|
|
127
|
+
this._logger = e.getLogger(this.instrumentationName, this.instrumentationVersion);
|
|
128
|
+
}
|
|
129
|
+
getModuleDefinitions() {
|
|
130
|
+
let e = this.init() ?? [];
|
|
131
|
+
return Array.isArray(e) ? e : [e];
|
|
132
|
+
}
|
|
133
|
+
_updateMetricInstruments() {}
|
|
134
|
+
getConfig() {
|
|
135
|
+
return this._config;
|
|
136
|
+
}
|
|
137
|
+
setConfig(e) {
|
|
138
|
+
this._config = {
|
|
139
|
+
enabled: !0,
|
|
140
|
+
...e
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
setTracerProvider(e) {
|
|
144
|
+
this._tracer = e.getTracer(this.instrumentationName, this.instrumentationVersion);
|
|
145
|
+
}
|
|
146
|
+
get tracer() {
|
|
147
|
+
return this._tracer;
|
|
148
|
+
}
|
|
149
|
+
_runSpanCustomizationHook(e, t, n, r) {
|
|
150
|
+
if (e) try {
|
|
151
|
+
e(n, r);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
this._diag.error("Error running span customization hook due to exception in handler", { triggerName: t }, e);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
})), A, j = t((() => {
|
|
158
|
+
k(), A = class extends O {
|
|
159
|
+
constructor(e, t, n) {
|
|
160
|
+
super(e, t, n), this._config.enabled && this.enable();
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}));
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region ../../node_modules/.pnpm/@opentelemetry+instrumentation@0.214.0_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/instrumentation/build/esm/platform/browser/noop-normalize.js
|
|
166
|
+
function M(e) {
|
|
167
|
+
return s.warn("Path normalization is not implemented for this platform. To silence this warning, ensure no node-specific instrumentations are loaded, and node-specific types (e.g. InstrumentationNodeModuleFile), are not used in a browser context)"), e;
|
|
168
|
+
}
|
|
169
|
+
var N = t((() => {
|
|
170
|
+
c();
|
|
171
|
+
})), P = t((() => {
|
|
172
|
+
j(), N();
|
|
173
|
+
})), F, I = t((() => {
|
|
174
|
+
F = class {
|
|
175
|
+
files;
|
|
176
|
+
name;
|
|
177
|
+
supportedVersions;
|
|
178
|
+
patch;
|
|
179
|
+
unpatch;
|
|
180
|
+
constructor(e, t, n, r, i) {
|
|
181
|
+
this.files = i || [], this.name = e, this.supportedVersions = t, this.patch = n, this.unpatch = r;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
})), L, R = t((() => {
|
|
185
|
+
P(), L = class {
|
|
186
|
+
name;
|
|
187
|
+
supportedVersions;
|
|
188
|
+
patch;
|
|
189
|
+
unpatch;
|
|
190
|
+
constructor(e, t, n, r) {
|
|
191
|
+
this.name = M(e), this.supportedVersions = t, this.patch = n, this.unpatch = r;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}));
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region ../../node_modules/.pnpm/@opentelemetry+instrumentation@0.214.0_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/instrumentation/build/esm/utils.js
|
|
197
|
+
function z(e, t, n) {
|
|
198
|
+
let r, i;
|
|
199
|
+
try {
|
|
200
|
+
i = e();
|
|
201
|
+
} catch (e) {
|
|
202
|
+
r = e;
|
|
203
|
+
} finally {
|
|
204
|
+
if (t(r, i), r && !n) throw r;
|
|
205
|
+
return i;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
async function B(e, t, n) {
|
|
209
|
+
let r, i;
|
|
210
|
+
try {
|
|
211
|
+
i = await e();
|
|
212
|
+
} catch (e) {
|
|
213
|
+
r = e;
|
|
214
|
+
} finally {
|
|
215
|
+
if (await t(r, i), r && !n) throw r;
|
|
216
|
+
return i;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function V(e) {
|
|
220
|
+
return typeof e == "function" && typeof e.__original == "function" && typeof e.__unwrap == "function" && e.__wrapped === !0;
|
|
221
|
+
}
|
|
222
|
+
var H = t((() => {}));
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region ../../node_modules/.pnpm/@opentelemetry+instrumentation@0.214.0_@opentelemetry+api@1.9.1/node_modules/@opentelemetry/instrumentation/build/esm/semconvStability.js
|
|
225
|
+
function U(e, t) {
|
|
226
|
+
let n = W.OLD, r = t?.split(",").map((e) => e.trim()).filter((e) => e !== "");
|
|
227
|
+
for (let t of r ?? []) if (t.toLowerCase() === e + "/dup") {
|
|
228
|
+
n = W.DUPLICATE;
|
|
229
|
+
break;
|
|
230
|
+
} else t.toLowerCase() === e && (n = W.STABLE);
|
|
231
|
+
return n;
|
|
232
|
+
}
|
|
233
|
+
var W, G = t((() => {
|
|
234
|
+
(function(e) {
|
|
235
|
+
e[e.STABLE = 1] = "STABLE", e[e.OLD = 2] = "OLD", e[e.DUPLICATE = 3] = "DUPLICATE";
|
|
236
|
+
})(W ||= {});
|
|
237
|
+
})), K = /* @__PURE__ */ n({
|
|
238
|
+
InstrumentationBase: () => A,
|
|
239
|
+
InstrumentationNodeModuleDefinition: () => F,
|
|
240
|
+
InstrumentationNodeModuleFile: () => L,
|
|
241
|
+
SemconvStability: () => W,
|
|
242
|
+
isWrapped: () => V,
|
|
243
|
+
registerInstrumentations: () => v,
|
|
244
|
+
safeExecuteInTheMiddle: () => z,
|
|
245
|
+
safeExecuteInTheMiddleAsync: () => B,
|
|
246
|
+
semconvStabilityFromStr: () => U
|
|
247
|
+
}), q = t((() => {
|
|
248
|
+
y(), P(), I(), R(), H(), G();
|
|
249
|
+
})), J = /* @__PURE__ */ r(((e) => {
|
|
250
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.PACKAGE_NAME = e.PACKAGE_VERSION = void 0, e.PACKAGE_VERSION = "0.60.0", e.PACKAGE_NAME = "@opentelemetry/instrumentation-pino";
|
|
251
|
+
})), Y = /* @__PURE__ */ r(((t) => {
|
|
252
|
+
Object.defineProperty(t, "__esModule", { value: !0 }), t.OTelPinoStream = t.getTimeConverter = void 0;
|
|
253
|
+
var n = i(), r = (l(), e(m)), a = J(), o = (u(), e(d)), s = {
|
|
254
|
+
trace: 10,
|
|
255
|
+
debug: 20,
|
|
256
|
+
info: 30,
|
|
257
|
+
warn: 40,
|
|
258
|
+
error: 50,
|
|
259
|
+
fatal: 60
|
|
260
|
+
}, c = {
|
|
261
|
+
[s.trace]: r.SeverityNumber.TRACE,
|
|
262
|
+
[s.debug]: r.SeverityNumber.DEBUG,
|
|
263
|
+
[s.info]: r.SeverityNumber.INFO,
|
|
264
|
+
[s.warn]: r.SeverityNumber.WARN,
|
|
265
|
+
[s.error]: r.SeverityNumber.ERROR,
|
|
266
|
+
[s.fatal]: r.SeverityNumber.FATAL
|
|
267
|
+
}, f = [
|
|
268
|
+
r.SeverityNumber.TRACE2,
|
|
269
|
+
r.SeverityNumber.TRACE3,
|
|
270
|
+
r.SeverityNumber.TRACE4,
|
|
271
|
+
r.SeverityNumber.DEBUG2,
|
|
272
|
+
r.SeverityNumber.DEBUG3,
|
|
273
|
+
r.SeverityNumber.DEBUG4,
|
|
274
|
+
r.SeverityNumber.INFO2,
|
|
275
|
+
r.SeverityNumber.INFO3,
|
|
276
|
+
r.SeverityNumber.INFO4,
|
|
277
|
+
r.SeverityNumber.WARN2,
|
|
278
|
+
r.SeverityNumber.WARN3,
|
|
279
|
+
r.SeverityNumber.WARN4,
|
|
280
|
+
r.SeverityNumber.ERROR2,
|
|
281
|
+
r.SeverityNumber.ERROR3,
|
|
282
|
+
r.SeverityNumber.ERROR4,
|
|
283
|
+
r.SeverityNumber.FATAL2,
|
|
284
|
+
r.SeverityNumber.FATAL3,
|
|
285
|
+
r.SeverityNumber.FATAL4
|
|
286
|
+
];
|
|
287
|
+
function p(e) {
|
|
288
|
+
let t = c[e];
|
|
289
|
+
if (t !== void 0) return t;
|
|
290
|
+
let n = (e - 10) / 60, r = Math.floor(n * f.length);
|
|
291
|
+
return f[Math.min(f.length - 1, Math.max(0, r))];
|
|
292
|
+
}
|
|
293
|
+
function h(e, t) {
|
|
294
|
+
let n = t.stdTimeFunctions, r = e[t.symbols.timeSym];
|
|
295
|
+
return r === n.epochTime ? (e) => e : r === n.unixTime ? (e) => e * 1e3 : r === n.isoTime ? (e) => new Date(e).getTime() : r === n.nullTime ? () => Date.now() : () => NaN;
|
|
296
|
+
}
|
|
297
|
+
t.getTimeConverter = h, t.OTelPinoStream = class extends n.Writable {
|
|
298
|
+
constructor(e) {
|
|
299
|
+
super(), this._messageKey = e.messageKey, this._levels = e.levels, this._otelTimestampFromTime = e.otelTimestampFromTime, this._otelLogger = r.logs.getLogger(a.PACKAGE_NAME, a.PACKAGE_VERSION);
|
|
300
|
+
}
|
|
301
|
+
_write(e, t, n) {
|
|
302
|
+
/* istanbul ignore if */
|
|
303
|
+
if (!e) return;
|
|
304
|
+
let r;
|
|
305
|
+
try {
|
|
306
|
+
r = JSON.parse(e);
|
|
307
|
+
} catch (t) {
|
|
308
|
+
this.emit("unknown", e.toString(), t), n();
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
/* istanbul ignore if */
|
|
312
|
+
if (r === null) {
|
|
313
|
+
this.emit("unknown", e.toString(), "Null value ignored"), n();
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
/* istanbul ignore if */
|
|
317
|
+
typeof r != "object" && (r = { data: r });
|
|
318
|
+
let { time: i, [this._messageKey]: a, level: s, hostname: c, pid: l, trace_id: u, span_id: d, trace_flags: f, ...m } = r, h = this._otelTimestampFromTime(i);
|
|
319
|
+
isNaN(h) && (m.time = i, h = Date.now());
|
|
320
|
+
let g = (0, o.millisToHrTime)(h), _ = this.lastLevel, v = {
|
|
321
|
+
timestamp: g,
|
|
322
|
+
observedTimestamp: g,
|
|
323
|
+
severityNumber: p(_),
|
|
324
|
+
severityText: this._levels.labels[_],
|
|
325
|
+
body: a,
|
|
326
|
+
attributes: m
|
|
327
|
+
};
|
|
328
|
+
this._otelLogger.emit(v), n();
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
})), X = /* @__PURE__ */ r(((t) => {
|
|
332
|
+
Object.defineProperty(t, "__esModule", { value: !0 }), t.PinoInstrumentation = void 0;
|
|
333
|
+
var n = (c(), e(f)), r = (q(), e(K)), i = J(), a = Y(), o = [">=5.14.0 <11"], s = {
|
|
334
|
+
traceId: "trace_id",
|
|
335
|
+
spanId: "span_id",
|
|
336
|
+
traceFlags: "trace_flags"
|
|
337
|
+
};
|
|
338
|
+
t.PinoInstrumentation = class extends r.InstrumentationBase {
|
|
339
|
+
constructor(e = {}) {
|
|
340
|
+
super(i.PACKAGE_NAME, i.PACKAGE_VERSION, e);
|
|
341
|
+
}
|
|
342
|
+
init() {
|
|
343
|
+
return [new r.InstrumentationNodeModuleDefinition("pino", o, (e) => {
|
|
344
|
+
let t = e[Symbol.toStringTag] === "Module", n = t ? e.default : e, r = this, i = Object.assign((...e) => {
|
|
345
|
+
let t = r.getConfig(), i = r.isEnabled(), o = n(...e), s = r._getMixinFunction(), c = n.symbols.mixinSym, l = o[c];
|
|
346
|
+
if (l === void 0 ? o[c] = s : o[c] = (e, t, ...n) => Object.assign(s(e, t), l(e, t, ...n)), i && !t.disableLogSending && typeof n.multistream == "function") {
|
|
347
|
+
let e = (0, a.getTimeConverter)(o, n), t = new a.OTelPinoStream({
|
|
348
|
+
messageKey: o[n.symbols.messageKeySym],
|
|
349
|
+
levels: o.levels,
|
|
350
|
+
otelTimestampFromTime: e
|
|
351
|
+
});
|
|
352
|
+
t[Symbol.for("pino.metadata")] = !0, t.once("unknown", (e, t) => {
|
|
353
|
+
r._diag.warn("could not send pino log line (will only log first occurrence)", {
|
|
354
|
+
line: e,
|
|
355
|
+
err: t
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
let i = o[n.symbols.streamSym];
|
|
359
|
+
o[n.symbols.streamSym] = n.multistream([{
|
|
360
|
+
level: 0,
|
|
361
|
+
stream: i
|
|
362
|
+
}, {
|
|
363
|
+
level: 0,
|
|
364
|
+
stream: t
|
|
365
|
+
}], { levels: o.levels.values });
|
|
366
|
+
}
|
|
367
|
+
return o;
|
|
368
|
+
}, n);
|
|
369
|
+
return typeof i.pino == "function" && (i.pino = i), typeof i.default == "function" && (i.default = i), t && (e.pino &&= i, e.default = i), i;
|
|
370
|
+
})];
|
|
371
|
+
}
|
|
372
|
+
_callHook(e, t, i) {
|
|
373
|
+
let { logHook: a } = this.getConfig();
|
|
374
|
+
a && (0, r.safeExecuteInTheMiddle)(() => a(e, t, i), (e) => {
|
|
375
|
+
e && n.diag.error("pino instrumentation: error calling logHook", e);
|
|
376
|
+
}, !0);
|
|
377
|
+
}
|
|
378
|
+
_getMixinFunction() {
|
|
379
|
+
let e = this;
|
|
380
|
+
return function(t, r) {
|
|
381
|
+
if (!e.isEnabled() || e.getConfig().disableLogCorrelation) return {};
|
|
382
|
+
let i = n.trace.getSpan(n.context.active());
|
|
383
|
+
if (!i) return {};
|
|
384
|
+
let a = i.spanContext();
|
|
385
|
+
if (!(0, n.isSpanContextValid)(a)) return {};
|
|
386
|
+
let o = e.getConfig().logKeys ?? s, c = {
|
|
387
|
+
[o.traceId]: a.traceId,
|
|
388
|
+
[o.spanId]: a.spanId,
|
|
389
|
+
[o.traceFlags]: `0${a.traceFlags.toString(16)}`
|
|
390
|
+
};
|
|
391
|
+
return e._callHook(i, c, r), c;
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
})), Z = /* @__PURE__ */ r(((e) => {
|
|
396
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.PinoInstrumentation = void 0;
|
|
397
|
+
var t = X();
|
|
398
|
+
Object.defineProperty(e, "PinoInstrumentation", {
|
|
399
|
+
enumerable: !0,
|
|
400
|
+
get: function() {
|
|
401
|
+
return t.PinoInstrumentation;
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
}));
|
|
405
|
+
//#endregion
|
|
406
|
+
export default Z();
|