logixia 1.13.3 → 2.0.4
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 +117 -44
- package/dist/async-context-B05ArHgM.mjs +134 -0
- package/dist/async-context-B05ArHgM.mjs.map +1 -0
- package/dist/async-context-DTQgi8f7.js +150 -0
- package/dist/async-context-DTQgi8f7.js.map +1 -0
- package/dist/{azure-monitor.transport-CHnjVRF-.mjs → azure-monitor.transport-BPbgjATu.mjs} +27 -15
- package/dist/azure-monitor.transport-BPbgjATu.mjs.map +1 -0
- package/dist/{azure-monitor.transport-BDFO4F-i.d.ts → azure-monitor.transport-C7kYyZUW.d.mts} +3 -6
- package/dist/azure-monitor.transport-C7kYyZUW.d.mts.map +1 -0
- package/dist/{azure-monitor.transport-CrvfHd9C.js → azure-monitor.transport-CwbOLZHB.js} +32 -20
- package/dist/azure-monitor.transport-CwbOLZHB.js.map +1 -0
- package/dist/{azure-monitor.transport-D5wQEH04.d.mts → azure-monitor.transport-DV03Z5P4.d.ts} +3 -6
- package/dist/azure-monitor.transport-DV03Z5P4.d.ts.map +1 -0
- package/dist/azure.d.mts +1 -2
- package/dist/azure.d.ts +1 -2
- package/dist/azure.js +3 -6
- package/dist/azure.mjs +1 -6
- package/dist/{batch-buffer-PGvSgbmd.mjs → batch-buffer-0fgLmIPn.mjs} +21 -7
- package/dist/batch-buffer-0fgLmIPn.mjs.map +1 -0
- package/dist/{batch-buffer-BY-mRWIK.js → batch-buffer-DT4gdXmf.js} +53 -40
- package/dist/batch-buffer-DT4gdXmf.js.map +1 -0
- package/dist/browser.d.mts +52 -23
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +52 -23
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +460 -62
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +461 -65
- package/dist/browser.mjs.map +1 -1
- package/dist/{nestjs-extras-ImbuDhs1.mjs → builder-D70z6kjj.mjs} +279 -965
- package/dist/builder-D70z6kjj.mjs.map +1 -0
- package/dist/{nestjs-extras-DnJ6vrIC.js → builder-M7NoaugM.js} +421 -1177
- package/dist/builder-M7NoaugM.js.map +1 -0
- package/dist/cli/index.js +86 -67
- package/dist/cloudwatch.d.mts +1 -2
- package/dist/cloudwatch.d.ts +1 -2
- package/dist/cloudwatch.js +3 -7
- package/dist/cloudwatch.mjs +1 -7
- package/dist/{cloudwatch.transport-BO1ahxw-.js → cloudwatch.transport-B2wKQFF7.js} +61 -36
- package/dist/cloudwatch.transport-B2wKQFF7.js.map +1 -0
- package/dist/{cloudwatch.transport-DZ6ies7g.mjs → cloudwatch.transport-BTvYfLs9.mjs} +54 -28
- package/dist/cloudwatch.transport-BTvYfLs9.mjs.map +1 -0
- package/dist/{cloudwatch.transport-B00st6Xv.d.ts → cloudwatch.transport-Bf7L4I59.d.ts} +2 -6
- package/dist/cloudwatch.transport-Bf7L4I59.d.ts.map +1 -0
- package/dist/{cloudwatch.transport-Blc7Gtxt.d.mts → cloudwatch.transport-Rj4yTpRn.d.mts} +2 -6
- package/dist/cloudwatch.transport-Rj4yTpRn.d.mts.map +1 -0
- package/dist/{coerce.utils-Cu6IUTgX.mjs → coerce.utils-B_rEudCn.mjs} +3 -4
- package/dist/{coerce.utils-Cu6IUTgX.mjs.map → coerce.utils-B_rEudCn.mjs.map} +1 -1
- package/dist/{coerce.utils-B-LilukN.js → coerce.utils-C1C5sIX0.js} +8 -10
- package/dist/{coerce.utils-B-LilukN.js.map → coerce.utils-C1C5sIX0.js.map} +1 -1
- package/dist/correlation.d.mts +13 -16
- package/dist/correlation.d.mts.map +1 -1
- package/dist/correlation.d.ts +13 -16
- package/dist/correlation.d.ts.map +1 -1
- package/dist/correlation.js +58 -9
- package/dist/correlation.js.map +1 -1
- package/dist/correlation.mjs +56 -6
- package/dist/correlation.mjs.map +1 -1
- package/dist/{entry-fields-BJkuPnIg.mjs → entry-fields-CGuvT2R0.mjs} +5 -6
- package/dist/entry-fields-CGuvT2R0.mjs.map +1 -0
- package/dist/{entry-fields-BvOLFlJ4.js → entry-fields-RLd1jCoR.js} +10 -12
- package/dist/entry-fields-RLd1jCoR.js.map +1 -0
- package/dist/gcp.d.mts +1 -2
- package/dist/gcp.d.ts +1 -2
- package/dist/gcp.js +3 -7
- package/dist/gcp.mjs +1 -7
- package/dist/{gcp.transport-m4fVw0b1.d.ts → gcp.transport-C5D72b1g.d.mts} +3 -6
- package/dist/gcp.transport-C5D72b1g.d.mts.map +1 -0
- package/dist/{gcp.transport-zzNyIoih.d.mts → gcp.transport-CFQfdAOK.d.ts} +3 -6
- package/dist/gcp.transport-CFQfdAOK.d.ts.map +1 -0
- package/dist/{gcp.transport-DBX5TPIy.mjs → gcp.transport-CGKopAhQ.mjs} +55 -16
- package/dist/gcp.transport-CGKopAhQ.mjs.map +1 -0
- package/dist/{gcp.transport-CHV8MGgz.js → gcp.transport-KZe9hCAR.js} +60 -22
- package/dist/gcp.transport-KZe9hCAR.js.map +1 -0
- package/dist/{index-nZEeCr3X.d.ts → index-DwozbmB4.d.ts} +3 -8
- package/dist/index-DwozbmB4.d.ts.map +1 -0
- package/dist/{index-BPwEisy4.d.mts → index-xqaJtAZn.d.mts} +3 -8
- package/dist/index-xqaJtAZn.d.mts.map +1 -0
- package/dist/index.d.mts +141 -203
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +140 -202
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +196 -381
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -294
- package/dist/index.mjs.map +1 -1
- package/dist/internal-log-b0Vp4qrB.js +183 -0
- package/dist/internal-log-b0Vp4qrB.js.map +1 -0
- package/dist/internal-log-uCSd1PMc.mjs +142 -0
- package/dist/internal-log-uCSd1PMc.mjs.map +1 -0
- package/dist/logitron-logger-D2B75Oc7.d.ts +365 -0
- package/dist/logitron-logger-D2B75Oc7.d.ts.map +1 -0
- package/dist/logitron-logger-oEd6wNhf.d.mts +365 -0
- package/dist/logitron-logger-oEd6wNhf.d.mts.map +1 -0
- package/dist/middleware.d.mts +10 -12
- package/dist/middleware.d.mts.map +1 -1
- package/dist/middleware.d.ts +10 -12
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +16 -47
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +13 -45
- package/dist/middleware.mjs.map +1 -1
- package/dist/nest.d.mts +467 -10
- package/dist/nest.d.mts.map +1 -1
- package/dist/nest.d.ts +467 -10
- package/dist/nest.d.ts.map +1 -1
- package/dist/nest.js +889 -43
- package/dist/nest.js.map +1 -0
- package/dist/nest.mjs +850 -9
- package/dist/nest.mjs.map +1 -0
- package/dist/{trace.utils-CvXgaiQT.mjs → request-trace-C_fvIDv4.mjs} +44 -9
- package/dist/request-trace-C_fvIDv4.mjs.map +1 -0
- package/dist/{trace.utils-DpBOLDtq.js → request-trace-wTJdKp6-.js} +121 -77
- package/dist/request-trace-wTJdKp6-.js.map +1 -0
- package/dist/rolldown-runtime-D3PmRqjj.mjs +4 -0
- package/dist/{safe-stringify-DJ66tW5I.mjs → safe-stringify-BMRl3EX3.mjs} +3 -4
- package/dist/safe-stringify-BMRl3EX3.mjs.map +1 -0
- package/dist/{safe-stringify-DWo3aZp_.js → safe-stringify-DLz1Kz3o.js} +23 -25
- package/dist/safe-stringify-DLz1Kz3o.js.map +1 -0
- package/dist/{search-CHUZPl0h.d.ts → search-BH33XhuU.d.mts} +2 -22
- package/dist/search-BH33XhuU.d.mts.map +1 -0
- package/dist/{search-DjXSn6v5.mjs → search-CWMVYC-R.mjs} +34 -41
- package/dist/search-CWMVYC-R.mjs.map +1 -0
- package/dist/{search-BfBzDIT9.d.mts → search-CazwyX5Z.d.ts} +2 -22
- package/dist/search-CazwyX5Z.d.ts.map +1 -0
- package/dist/{search-B0MH1SJJ.js → search-DUfWuzFP.js} +64 -71
- package/dist/search-DUfWuzFP.js.map +1 -0
- package/dist/search.d.mts +2 -4
- package/dist/search.d.ts +2 -4
- package/dist/search.js +3 -4
- package/dist/search.mjs +1 -4
- package/dist/secret-config-BegMLkYl.mjs +209 -0
- package/dist/secret-config-BegMLkYl.mjs.map +1 -0
- package/dist/secret-config-CBZBs0p1.js +271 -0
- package/dist/secret-config-CBZBs0p1.js.map +1 -0
- package/dist/slack.transport-Ce96JBDk.mjs +824 -0
- package/dist/slack.transport-Ce96JBDk.mjs.map +1 -0
- package/dist/slack.transport-Dlx3xvb7.js +847 -0
- package/dist/slack.transport-Dlx3xvb7.js.map +1 -0
- package/dist/slack.transport-DrirgDNy.d.ts +159 -0
- package/dist/slack.transport-DrirgDNy.d.ts.map +1 -0
- package/dist/slack.transport-DxHOXlLu.d.mts +159 -0
- package/dist/slack.transport-DxHOXlLu.d.mts.map +1 -0
- package/dist/testing.d.mts +3 -8
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.d.ts +3 -8
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -4
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +2 -3
- package/dist/testing.mjs.map +1 -1
- package/dist/{transport.manager-Crau3Rle.js → transport.manager-DkcEOlqV.js} +331 -234
- package/dist/transport.manager-DkcEOlqV.js.map +1 -0
- package/dist/{transport.manager-CpdVHEGP.mjs → transport.manager-eZ_EeC00.mjs} +274 -178
- package/dist/transport.manager-eZ_EeC00.mjs.map +1 -0
- package/dist/{transport.types-CtNr3D7S.d.mts → transport.types-BJVL1QQl.d.mts} +5 -4
- package/dist/transport.types-BJVL1QQl.d.mts.map +1 -0
- package/dist/{transport.types-DqVLZTyf.d.ts → transport.types-BJVL1QQl.d.ts} +5 -4
- package/dist/transport.types-BJVL1QQl.d.ts.map +1 -0
- package/dist/transports.d.mts +32 -41
- package/dist/transports.d.mts.map +1 -1
- package/dist/transports.d.ts +32 -41
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +12 -12
- package/dist/transports.mjs +7 -12
- package/dist/worker-entry.js +337 -87
- package/dist/worker.d.mts +1 -2
- package/dist/worker.d.ts +1 -2
- package/dist/worker.js +3 -4
- package/dist/worker.mjs +1 -4
- package/dist/{worker.transport-Bj-i0P9V.d.ts → worker.transport-BuPwBi3d.d.ts} +2 -6
- package/dist/worker.transport-BuPwBi3d.d.ts.map +1 -0
- package/dist/{worker.transport-JP8YHBuU.js → worker.transport-C6GNl_r2.js} +44 -14
- package/dist/worker.transport-C6GNl_r2.js.map +1 -0
- package/dist/{worker.transport-otwhJ_Et.mjs → worker.transport-DLVA4y2e.mjs} +39 -9
- package/dist/worker.transport-DLVA4y2e.mjs.map +1 -0
- package/dist/{worker.transport-Bgv9heDI.d.mts → worker.transport-hJay1wxA.d.mts} +2 -6
- package/dist/worker.transport-hJay1wxA.d.mts.map +1 -0
- package/package.json +36 -19
- package/dist/async-context-BzJrbfQs.mjs +0 -72
- package/dist/async-context-BzJrbfQs.mjs.map +0 -1
- package/dist/async-context-DyQQYq3I.js +0 -92
- package/dist/async-context-DyQQYq3I.js.map +0 -1
- package/dist/azure-monitor.transport-BDFO4F-i.d.ts.map +0 -1
- package/dist/azure-monitor.transport-CHnjVRF-.mjs.map +0 -1
- package/dist/azure-monitor.transport-CrvfHd9C.js.map +0 -1
- package/dist/azure-monitor.transport-D5wQEH04.d.mts.map +0 -1
- package/dist/batch-buffer-BY-mRWIK.js.map +0 -1
- package/dist/batch-buffer-PGvSgbmd.mjs.map +0 -1
- package/dist/chunk-DLSkYcPk.mjs +0 -7
- package/dist/chunk-nOFOJqeH.js +0 -30
- package/dist/cloudwatch.transport-B00st6Xv.d.ts.map +0 -1
- package/dist/cloudwatch.transport-BO1ahxw-.js.map +0 -1
- package/dist/cloudwatch.transport-Blc7Gtxt.d.mts.map +0 -1
- package/dist/cloudwatch.transport-DZ6ies7g.mjs.map +0 -1
- package/dist/entry-fields-BJkuPnIg.mjs.map +0 -1
- package/dist/entry-fields-BvOLFlJ4.js.map +0 -1
- package/dist/gcp.transport-CHV8MGgz.js.map +0 -1
- package/dist/gcp.transport-DBX5TPIy.mjs.map +0 -1
- package/dist/gcp.transport-m4fVw0b1.d.ts.map +0 -1
- package/dist/gcp.transport-zzNyIoih.d.mts.map +0 -1
- package/dist/index-BPwEisy4.d.mts.map +0 -1
- package/dist/index-nZEeCr3X.d.ts.map +0 -1
- package/dist/internal-log-BUJYMZbE.js +0 -70
- package/dist/internal-log-BUJYMZbE.js.map +0 -1
- package/dist/internal-log-Cm8SOWSV.mjs +0 -52
- package/dist/internal-log-Cm8SOWSV.mjs.map +0 -1
- package/dist/nestjs-extras-DnJ6vrIC.js.map +0 -1
- package/dist/nestjs-extras-ImbuDhs1.mjs.map +0 -1
- package/dist/nestjs-extras-OkC796py.d.mts +0 -725
- package/dist/nestjs-extras-OkC796py.d.mts.map +0 -1
- package/dist/nestjs-extras-mKrHE9S6.d.ts +0 -725
- package/dist/nestjs-extras-mKrHE9S6.d.ts.map +0 -1
- package/dist/safe-stringify-DJ66tW5I.mjs.map +0 -1
- package/dist/safe-stringify-DWo3aZp_.js.map +0 -1
- package/dist/search-B0MH1SJJ.js.map +0 -1
- package/dist/search-BfBzDIT9.d.mts.map +0 -1
- package/dist/search-CHUZPl0h.d.ts.map +0 -1
- package/dist/search-DjXSn6v5.mjs.map +0 -1
- package/dist/trace.utils-CvXgaiQT.mjs.map +0 -1
- package/dist/trace.utils-DpBOLDtq.js.map +0 -1
- package/dist/transport.manager-CpdVHEGP.mjs.map +0 -1
- package/dist/transport.manager-Crau3Rle.js.map +0 -1
- package/dist/transport.types-CtNr3D7S.d.mts.map +0 -1
- package/dist/transport.types-DqVLZTyf.d.ts.map +0 -1
- package/dist/worker.transport-Bgv9heDI.d.mts.map +0 -1
- package/dist/worker.transport-Bj-i0P9V.d.ts.map +0 -1
- package/dist/worker.transport-JP8YHBuU.js.map +0 -1
- package/dist/worker.transport-otwhJ_Et.mjs.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { t as __require } from "./
|
|
2
|
-
import { n as internalLog, r as internalWarn, t as internalError } from "./internal-log-
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
1
|
+
import { t as __require } from "./rolldown-runtime-D3PmRqjj.mjs";
|
|
2
|
+
import { n as internalLog, r as internalWarn, t as internalError } from "./internal-log-uCSd1PMc.mjs";
|
|
3
|
+
import { n as protectSecrets, o as urlSecrets, r as scrubError, t as collectSecrets } from "./secret-config-BegMLkYl.mjs";
|
|
4
|
+
import { t as safeToString } from "./coerce.utils-B_rEudCn.mjs";
|
|
5
|
+
import { i as stringifyForLog } from "./safe-stringify-BMRl3EX3.mjs";
|
|
6
|
+
import { t as mergeCoreFields } from "./entry-fields-CGuvT2R0.mjs";
|
|
7
|
+
import { EventEmitter } from "node:events";
|
|
8
|
+
import { promisify } from "node:util";
|
|
9
|
+
import { createGzip, gzip } from "node:zlib";
|
|
6
10
|
import * as fs from "node:fs";
|
|
7
11
|
import * as path$1 from "node:path";
|
|
8
|
-
import { EventEmitter } from "node:events";
|
|
9
12
|
import { pipeline } from "node:stream/promises";
|
|
10
|
-
|
|
11
|
-
import { createGzip } from "node:zlib";
|
|
12
|
-
|
|
13
|
-
//#region src/utils/sanitize.utils.ts
|
|
13
|
+
// src/utils/sanitize.utils.ts
|
|
14
14
|
/**
|
|
15
15
|
* Control-character stripping for text-mode log output.
|
|
16
16
|
*
|
|
@@ -26,9 +26,7 @@ const VISIBLE_ESCAPES = {
|
|
|
26
26
|
function stripControlChars(value) {
|
|
27
27
|
return value.replace(CONTROL_CHARS_RE, (ch) => VISIBLE_ESCAPES[ch] ?? "");
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/transports/console.transport.ts
|
|
29
|
+
// src/transports/console.transport.ts
|
|
32
30
|
/**
|
|
33
31
|
* Writes log entries to stdout (info/debug/verbose) and stderr (error/warn).
|
|
34
32
|
*
|
|
@@ -38,26 +36,6 @@ function stripControlChars(value) {
|
|
|
38
36
|
* transports: { console: { format: 'json' } }
|
|
39
37
|
*/
|
|
40
38
|
var ConsoleTransport = class ConsoleTransport {
|
|
41
|
-
static #_ = this.COLORS = new Map([
|
|
42
|
-
["black", "\x1B[30m"],
|
|
43
|
-
["red", "\x1B[31m"],
|
|
44
|
-
["green", "\x1B[32m"],
|
|
45
|
-
["yellow", "\x1B[33m"],
|
|
46
|
-
["blue", "\x1B[34m"],
|
|
47
|
-
["magenta", "\x1B[35m"],
|
|
48
|
-
["cyan", "\x1B[36m"],
|
|
49
|
-
["white", "\x1B[37m"],
|
|
50
|
-
["gray", "\x1B[90m"],
|
|
51
|
-
["grey", "\x1B[90m"],
|
|
52
|
-
["brightred", "\x1B[91m"],
|
|
53
|
-
["brightgreen", "\x1B[92m"],
|
|
54
|
-
["brightyellow", "\x1B[93m"],
|
|
55
|
-
["brightblue", "\x1B[94m"],
|
|
56
|
-
["brightmagenta", "\x1B[95m"],
|
|
57
|
-
["brightcyan", "\x1B[96m"],
|
|
58
|
-
["brightwhite", "\x1B[97m"],
|
|
59
|
-
["reset", "\x1B[0m"]
|
|
60
|
-
]);
|
|
61
39
|
static sanitize(value) {
|
|
62
40
|
return stripControlChars(safeToString(value));
|
|
63
41
|
}
|
|
@@ -126,10 +104,28 @@ var ConsoleTransport = class ConsoleTransport {
|
|
|
126
104
|
close() {
|
|
127
105
|
return Promise.resolve();
|
|
128
106
|
}
|
|
107
|
+
static #_ = () => this.COLORS = /* @__PURE__ */ new Map([
|
|
108
|
+
["black", "\x1B[30m"],
|
|
109
|
+
["red", "\x1B[31m"],
|
|
110
|
+
["green", "\x1B[32m"],
|
|
111
|
+
["yellow", "\x1B[33m"],
|
|
112
|
+
["blue", "\x1B[34m"],
|
|
113
|
+
["magenta", "\x1B[35m"],
|
|
114
|
+
["cyan", "\x1B[36m"],
|
|
115
|
+
["white", "\x1B[37m"],
|
|
116
|
+
["gray", "\x1B[90m"],
|
|
117
|
+
["grey", "\x1B[90m"],
|
|
118
|
+
["brightred", "\x1B[91m"],
|
|
119
|
+
["brightgreen", "\x1B[92m"],
|
|
120
|
+
["brightyellow", "\x1B[93m"],
|
|
121
|
+
["brightblue", "\x1B[94m"],
|
|
122
|
+
["brightmagenta", "\x1B[95m"],
|
|
123
|
+
["brightcyan", "\x1B[96m"],
|
|
124
|
+
["brightwhite", "\x1B[97m"],
|
|
125
|
+
["reset", "\x1B[0m"]
|
|
126
|
+
]);
|
|
129
127
|
};
|
|
130
|
-
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/transports/buffer-cap.ts
|
|
128
|
+
// src/transports/buffer-cap.ts
|
|
133
129
|
const DEFAULT_BUFFER_CAP = 1e4;
|
|
134
130
|
const DROP_WARN_INTERVAL_MS$1 = 5e3;
|
|
135
131
|
/**
|
|
@@ -145,8 +141,10 @@ var BufferCap = class {
|
|
|
145
141
|
this.dropped = 0;
|
|
146
142
|
this.lastWarning = 0;
|
|
147
143
|
let max = fallback;
|
|
148
|
-
if (requested !== void 0)
|
|
149
|
-
|
|
144
|
+
if (requested !== void 0) {
|
|
145
|
+
if (Number.isInteger(requested) && requested >= 1) max = requested;
|
|
146
|
+
else internalWarn(`${name}: maxBufferSize ${String(requested)} is not a positive integer; using ${fallback}`);
|
|
147
|
+
}
|
|
150
148
|
this.max = Math.max(max, batchSize);
|
|
151
149
|
}
|
|
152
150
|
/** Drops the oldest items beyond the cap, in place. */
|
|
@@ -168,9 +166,7 @@ var BufferCap = class {
|
|
|
168
166
|
this.lastWarning = now;
|
|
169
167
|
}
|
|
170
168
|
};
|
|
171
|
-
|
|
172
|
-
//#endregion
|
|
173
|
-
//#region src/transports/database.transport.ts
|
|
169
|
+
// src/transports/database.transport.ts
|
|
174
170
|
/**
|
|
175
171
|
* Validates that a SQL identifier (table/index name) contains only safe characters.
|
|
176
172
|
* Prevents SQL injection via user-supplied table names.
|
|
@@ -193,7 +189,7 @@ const PG_DATA_CLASSES = [
|
|
|
193
189
|
"23",
|
|
194
190
|
"54"
|
|
195
191
|
];
|
|
196
|
-
const MYSQL_DATA_CODES = new Set([
|
|
192
|
+
const MYSQL_DATA_CODES = /* @__PURE__ */ new Set([
|
|
197
193
|
"ER_DATA_TOO_LONG",
|
|
198
194
|
"ER_TRUNCATED_WRONG_VALUE",
|
|
199
195
|
"ER_TRUNCATED_WRONG_VALUE_FOR_FIELD",
|
|
@@ -203,7 +199,7 @@ const MYSQL_DATA_CODES = new Set([
|
|
|
203
199
|
"ER_INVALID_JSON_TEXT",
|
|
204
200
|
"ER_INVALID_CHARACTER_STRING"
|
|
205
201
|
]);
|
|
206
|
-
const MYSQL_DATA_ERRNOS = new Set([
|
|
202
|
+
const MYSQL_DATA_ERRNOS = /* @__PURE__ */ new Set([
|
|
207
203
|
1048,
|
|
208
204
|
1062,
|
|
209
205
|
1264,
|
|
@@ -212,12 +208,12 @@ const MYSQL_DATA_ERRNOS = new Set([
|
|
|
212
208
|
1406,
|
|
213
209
|
3140
|
|
214
210
|
]);
|
|
215
|
-
const SQLITE_DATA_CODES = new Set([
|
|
211
|
+
const SQLITE_DATA_CODES = /* @__PURE__ */ new Set([
|
|
216
212
|
"SQLITE_CONSTRAINT",
|
|
217
213
|
"SQLITE_TOOBIG",
|
|
218
214
|
"SQLITE_MISMATCH"
|
|
219
215
|
]);
|
|
220
|
-
const MONGO_DATA_CODES = new Set([
|
|
216
|
+
const MONGO_DATA_CODES = /* @__PURE__ */ new Set([
|
|
221
217
|
2,
|
|
222
218
|
121,
|
|
223
219
|
10334,
|
|
@@ -279,6 +275,7 @@ var DatabaseTransport = class {
|
|
|
279
275
|
this.name = "database";
|
|
280
276
|
this.batch = [];
|
|
281
277
|
this.isConnected = false;
|
|
278
|
+
protectSecrets(this, ["config", "connection"]);
|
|
282
279
|
this.batchSize = config.batchSize || 100;
|
|
283
280
|
this.flushInterval = config.flushInterval || 5e3;
|
|
284
281
|
this.cap = new BufferCap("DatabaseTransport", config.maxBufferSize, this.batchSize);
|
|
@@ -286,6 +283,14 @@ var DatabaseTransport = class {
|
|
|
286
283
|
if (config.table) validateSqlIdentifier(config.table, "table");
|
|
287
284
|
this.setupFlushTimer();
|
|
288
285
|
}
|
|
286
|
+
secretValues() {
|
|
287
|
+
const { connectionString, password } = this.config;
|
|
288
|
+
return [
|
|
289
|
+
connectionString,
|
|
290
|
+
password,
|
|
291
|
+
...connectionString ? urlSecrets(connectionString) : []
|
|
292
|
+
];
|
|
293
|
+
}
|
|
289
294
|
async write(entry) {
|
|
290
295
|
if (!this.isConnected) await this.connect();
|
|
291
296
|
this.addToBatch(entry);
|
|
@@ -346,6 +351,13 @@ var DatabaseTransport = class {
|
|
|
346
351
|
this.cap.enforce(this.batch);
|
|
347
352
|
}
|
|
348
353
|
async writeEntries(entries) {
|
|
354
|
+
try {
|
|
355
|
+
await this.writeEntriesUnscrubbed(entries);
|
|
356
|
+
} catch (error) {
|
|
357
|
+
throw scrubError(error, this.secretValues());
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
async writeEntriesUnscrubbed(entries) {
|
|
349
361
|
switch (this.config.type) {
|
|
350
362
|
case "mongodb":
|
|
351
363
|
await this.flushToMongoDB(entries);
|
|
@@ -424,13 +436,12 @@ var DatabaseTransport = class {
|
|
|
424
436
|
case "mysql":
|
|
425
437
|
await this.connectMySQL();
|
|
426
438
|
break;
|
|
427
|
-
case "sqlite":
|
|
428
|
-
await this.connectSQLite();
|
|
429
|
-
break;
|
|
439
|
+
case "sqlite": await this.connectSQLite();
|
|
430
440
|
}
|
|
431
441
|
this.isConnected = true;
|
|
432
442
|
} catch (error) {
|
|
433
443
|
this.isConnected = false;
|
|
444
|
+
scrubError(error, this.secretValues());
|
|
434
445
|
throw new Error(`Database connection failed: ${error}`, { cause: error });
|
|
435
446
|
}
|
|
436
447
|
}
|
|
@@ -439,7 +450,8 @@ var DatabaseTransport = class {
|
|
|
439
450
|
const { MongoClient } = await import("mongodb").catch(() => {
|
|
440
451
|
throw new Error("MongoDB driver not installed. Run: npm install mongodb");
|
|
441
452
|
});
|
|
442
|
-
|
|
453
|
+
const connectionString = this.config.connectionString || `mongodb://${this.config.host}:${this.config.port}/${this.config.database}`;
|
|
454
|
+
this.connection = new MongoClient(connectionString);
|
|
443
455
|
await this.connection.connect();
|
|
444
456
|
await this.connection.db(this.config.database).admin().ping();
|
|
445
457
|
} catch (error) {
|
|
@@ -551,12 +563,13 @@ var DatabaseTransport = class {
|
|
|
551
563
|
entry.environment
|
|
552
564
|
].map((value, column) => stripNul(column === 3 ? stripJsonNulEscape(value) : value))), POSTGRES_ROWS_PER_INSERT);
|
|
553
565
|
const insertChunk = async (rows) => {
|
|
566
|
+
const placeholders = rows.map((_, i) => {
|
|
567
|
+
return `(${Array.from({ length: POSTGRES_COLUMNS }, (_unused, c) => `$${i * POSTGRES_COLUMNS + c + 1}`).join(", ")})`;
|
|
568
|
+
}).join(", ");
|
|
554
569
|
const query = `
|
|
555
570
|
INSERT INTO ${tableName}
|
|
556
571
|
(timestamp, level, message, payload, context, trace_id, app_name, environment)
|
|
557
|
-
VALUES ${
|
|
558
|
-
return `(${Array.from({ length: POSTGRES_COLUMNS }, (_unused, c) => `$${i * POSTGRES_COLUMNS + c + 1}`).join(", ")})`;
|
|
559
|
-
}).join(", ")}
|
|
572
|
+
VALUES ${placeholders}
|
|
560
573
|
`;
|
|
561
574
|
await this.connection.query(query, rows.flat());
|
|
562
575
|
};
|
|
@@ -720,9 +733,7 @@ var DatabaseTransport = class {
|
|
|
720
733
|
case "mysql":
|
|
721
734
|
await this.connection.end();
|
|
722
735
|
break;
|
|
723
|
-
case "sqlite":
|
|
724
|
-
await this.connection.close();
|
|
725
|
-
break;
|
|
736
|
+
case "sqlite": await this.connection.close();
|
|
726
737
|
}
|
|
727
738
|
this.isConnected = false;
|
|
728
739
|
}
|
|
@@ -763,9 +774,18 @@ var DatabaseTransport = class {
|
|
|
763
774
|
}
|
|
764
775
|
}
|
|
765
776
|
};
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
777
|
+
// src/transports/analytics.transport.ts
|
|
778
|
+
/**
|
|
779
|
+
* Thrown by sendBatch() when part of a batch was already delivered. drain()
|
|
780
|
+
* requeues only `unsent`, so delivered entries are not sent twice.
|
|
781
|
+
*/
|
|
782
|
+
var PartialBatchError = class extends Error {
|
|
783
|
+
constructor(message, unsent, options) {
|
|
784
|
+
super(message, options);
|
|
785
|
+
this.unsent = unsent;
|
|
786
|
+
this.name = "PartialBatchError";
|
|
787
|
+
}
|
|
788
|
+
};
|
|
769
789
|
var AnalyticsTransport = class {
|
|
770
790
|
constructor(name, config) {
|
|
771
791
|
this.batch = [];
|
|
@@ -778,16 +798,25 @@ var AnalyticsTransport = class {
|
|
|
778
798
|
enableEventTracking: true,
|
|
779
799
|
...config
|
|
780
800
|
};
|
|
801
|
+
protectSecrets(this, ["config"]);
|
|
781
802
|
this.level = config.level;
|
|
782
803
|
this.batchSize = this.config.batchSize || 50;
|
|
783
804
|
this.flushInterval = this.config.flushInterval || 1e4;
|
|
784
805
|
this.cap = new BufferCap(name, config.maxBufferSize, this.batchSize);
|
|
785
806
|
}
|
|
807
|
+
/** Secret strings to scrub from errors: everything secret-looking in the config. Override to add more. */
|
|
808
|
+
secretValues() {
|
|
809
|
+
return collectSecrets(this.config);
|
|
810
|
+
}
|
|
786
811
|
async write(entry) {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
812
|
+
try {
|
|
813
|
+
if (!this.isReady) await this.ensureReady();
|
|
814
|
+
if (this.shouldSkipEntry(entry)) return;
|
|
815
|
+
if (this.config.batchSize && this.config.batchSize > 1) this.addToBatch(entry);
|
|
816
|
+
else await this.sendEntry(entry);
|
|
817
|
+
} catch (error) {
|
|
818
|
+
throw scrubError(error, this.secretValues());
|
|
819
|
+
}
|
|
791
820
|
}
|
|
792
821
|
addToBatch(entry) {
|
|
793
822
|
this.batch.push(entry);
|
|
@@ -825,8 +854,9 @@ var AnalyticsTransport = class {
|
|
|
825
854
|
try {
|
|
826
855
|
await this.sendBatch(entriesToSend);
|
|
827
856
|
} catch (error) {
|
|
857
|
+
scrubError(error, this.secretValues());
|
|
828
858
|
internalError(`Analytics transport ${this.name} flush failed`, error);
|
|
829
|
-
this.batch.unshift(...entriesToSend);
|
|
859
|
+
this.batch.unshift(...error instanceof PartialBatchError ? error.unsent : entriesToSend);
|
|
830
860
|
this.cap.enforce(this.batch);
|
|
831
861
|
return;
|
|
832
862
|
}
|
|
@@ -886,11 +916,72 @@ var AnalyticsTransport = class {
|
|
|
886
916
|
await this.ensureReady();
|
|
887
917
|
}
|
|
888
918
|
};
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
919
|
+
// src/transports/datadog.transport.ts
|
|
920
|
+
const gzipAsync = promisify(gzip);
|
|
921
|
+
const MAX_LOGS_PER_REQUEST = 1e3;
|
|
922
|
+
const MAX_LOGS_PAYLOAD_BYTES = 5e6;
|
|
923
|
+
const MAX_LOG_BYTES = 1e6;
|
|
924
|
+
const MAX_TRUNCATED_MESSAGE_CHARS = 15e4;
|
|
925
|
+
const TRUNCATED_LOG_KEYS = [
|
|
926
|
+
"ddsource",
|
|
927
|
+
"ddtags",
|
|
928
|
+
"hostname",
|
|
929
|
+
"service",
|
|
930
|
+
"status",
|
|
931
|
+
"timestamp",
|
|
932
|
+
"level",
|
|
933
|
+
"context",
|
|
934
|
+
"traceId",
|
|
935
|
+
"appName",
|
|
936
|
+
"environment",
|
|
937
|
+
"env",
|
|
938
|
+
"version",
|
|
939
|
+
"logger",
|
|
940
|
+
"dd.trace_id",
|
|
941
|
+
"dd.span_id"
|
|
942
|
+
];
|
|
943
|
+
const STATUS_MAP = {
|
|
944
|
+
fatal: "critical",
|
|
945
|
+
critical: "critical",
|
|
946
|
+
error: "error",
|
|
947
|
+
warn: "warn",
|
|
948
|
+
warning: "warn",
|
|
949
|
+
info: "info",
|
|
950
|
+
debug: "debug",
|
|
951
|
+
trace: "debug",
|
|
952
|
+
verbose: "debug"
|
|
953
|
+
};
|
|
954
|
+
const MAX_UINT64 = (1n << 64n) - 1n;
|
|
955
|
+
const DASHED_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
956
|
+
const HEX = /^[0-9a-f]+$/i;
|
|
957
|
+
const DIGITS = /^\d+$/;
|
|
958
|
+
/**
|
|
959
|
+
* Datadog correlates on a decimal 64-bit id. Accepts:
|
|
960
|
+
* - a dashed UUID (logixia's default trace id): dashes stripped, then 32-hex;
|
|
961
|
+
* - 32 hex chars (W3C trace id) or 16 hex chars containing a-f: low 64 bits as decimal;
|
|
962
|
+
* - an all-digit string: already decimal (dd-trace's native format), passed through.
|
|
963
|
+
* An all-digit string is ambiguous when it is 16 or 32 long: 32 is read as hex (a
|
|
964
|
+
* decimal id has at most 20 digits), 16 is read as decimal.
|
|
965
|
+
* Anything else yields the raw string for trace ids (`passthrough`) and nothing for span ids.
|
|
966
|
+
*/
|
|
967
|
+
function toDatadogId(id, passthrough) {
|
|
968
|
+
if (typeof id !== "string" || id === "") return void 0;
|
|
969
|
+
const fallback = passthrough ? id : void 0;
|
|
970
|
+
const compact = DASHED_UUID.test(id) ? id.replaceAll("-", "") : id;
|
|
971
|
+
const isHexId = HEX.test(compact) && (compact.length === 32 || compact.length === 16);
|
|
972
|
+
if (DIGITS.test(compact) && compact.length !== 32) {
|
|
973
|
+
const value = BigInt(compact);
|
|
974
|
+
return value <= MAX_UINT64 ? value.toString() : fallback;
|
|
975
|
+
}
|
|
976
|
+
if (isHexId) return BigInt(`0x${compact.slice(-16)}`).toString();
|
|
977
|
+
return fallback;
|
|
978
|
+
}
|
|
979
|
+
/** Datadog tags: no commas or whitespace, lowercase, at most 200 chars. */
|
|
980
|
+
function tag(key, value) {
|
|
981
|
+
return `${key}:${value}`.replaceAll(/[\s,]+/g, "_").toLowerCase().slice(0, 200);
|
|
982
|
+
}
|
|
892
983
|
/**
|
|
893
|
-
* Sends log entries and metrics to Datadog via the Logs and Metrics HTTP APIs.
|
|
984
|
+
* Sends log entries and metrics to Datadog via the Logs (v2) and Metrics HTTP APIs.
|
|
894
985
|
*
|
|
895
986
|
* The API key is transmitted via the `DD-API-KEY` request header — never in the URL.
|
|
896
987
|
*
|
|
@@ -905,6 +996,7 @@ var DataDogTransport = class extends AnalyticsTransport {
|
|
|
905
996
|
this.baseUrl = `https://api.${site}`;
|
|
906
997
|
this.logsUrl = `https://http-intake.logs.${site}`;
|
|
907
998
|
this.metricsUrl = `https://api.${site}`;
|
|
999
|
+
protectSecrets(this, ["datadogConfig"]);
|
|
908
1000
|
}
|
|
909
1001
|
async initialize() {
|
|
910
1002
|
try {
|
|
@@ -916,29 +1008,68 @@ var DataDogTransport = class extends AnalyticsTransport {
|
|
|
916
1008
|
}
|
|
917
1009
|
}
|
|
918
1010
|
async sendEntry(entry) {
|
|
919
|
-
|
|
920
|
-
if (this.datadogConfig.enableLogs !== false) promises.push(this.sendLog(entry));
|
|
921
|
-
if (this.datadogConfig.enableMetrics) promises.push(this.sendMetric(entry));
|
|
922
|
-
if (this.datadogConfig.enableTraces && entry.traceId) promises.push(this.sendTrace(entry));
|
|
923
|
-
await Promise.all(promises);
|
|
1011
|
+
await this.sendBatch([entry]);
|
|
924
1012
|
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Logs go first, chunk by chunk; metrics follow once every log chunk is out.
|
|
1015
|
+
* A failure part-way throws PartialBatchError naming only the entries that were
|
|
1016
|
+
* not delivered, so a retry never re-posts a chunk Datadog already accepted.
|
|
1017
|
+
*/
|
|
925
1018
|
async sendBatch(entries) {
|
|
926
|
-
|
|
927
|
-
if (this.datadogConfig.
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
1019
|
+
if (this.datadogConfig.enableLogs !== false) await this.sendLogBatch(entries);
|
|
1020
|
+
if (this.datadogConfig.enableMetrics) try {
|
|
1021
|
+
await this.sendMetricBatch(entries);
|
|
1022
|
+
} catch (error) {
|
|
1023
|
+
if (this.datadogConfig.enableLogs === false) throw error;
|
|
1024
|
+
throw new PartialBatchError(error.message, [], { cause: error });
|
|
932
1025
|
}
|
|
933
|
-
await Promise.all(promises);
|
|
934
1026
|
}
|
|
935
1027
|
async cleanup() {}
|
|
936
|
-
async sendLog(entry) {
|
|
937
|
-
await this.sendLogBatch([entry]);
|
|
938
|
-
}
|
|
939
1028
|
async sendLogBatch(entries) {
|
|
940
|
-
const
|
|
941
|
-
|
|
1029
|
+
const items = entries.map((entry) => ({
|
|
1030
|
+
entry,
|
|
1031
|
+
json: this.serializeLog(entry)
|
|
1032
|
+
}));
|
|
1033
|
+
const chunks = this.chunkLogs(items);
|
|
1034
|
+
for (let i = 0; i < chunks.length; i += 1) {
|
|
1035
|
+
const chunk = chunks[i];
|
|
1036
|
+
try {
|
|
1037
|
+
await this.makeLogsRequest("/api/v2/logs", `[${chunk.map((item) => item.json).join(",")}]`);
|
|
1038
|
+
} catch (error) {
|
|
1039
|
+
if (i === 0) throw error;
|
|
1040
|
+
const unsent = chunks.slice(i).flatMap((c) => c.map((item) => item.entry));
|
|
1041
|
+
throw new PartialBatchError(error.message, unsent, { cause: error });
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
/** Splits into requests of at most 1000 entries and about 5MB of JSON. */
|
|
1046
|
+
chunkLogs(items) {
|
|
1047
|
+
const chunks = [];
|
|
1048
|
+
let current = [];
|
|
1049
|
+
let currentBytes = 2;
|
|
1050
|
+
for (const item of items) {
|
|
1051
|
+
const bytes = Buffer.byteLength(item.json) + 1;
|
|
1052
|
+
if (current.length > 0 && (current.length >= MAX_LOGS_PER_REQUEST || currentBytes + bytes > MAX_LOGS_PAYLOAD_BYTES)) {
|
|
1053
|
+
chunks.push(current);
|
|
1054
|
+
current = [];
|
|
1055
|
+
currentBytes = 2;
|
|
1056
|
+
}
|
|
1057
|
+
current.push(item);
|
|
1058
|
+
currentBytes += bytes;
|
|
1059
|
+
}
|
|
1060
|
+
if (current.length > 0) chunks.push(current);
|
|
1061
|
+
return chunks;
|
|
1062
|
+
}
|
|
1063
|
+
/** Serializes once. A log over 1MB keeps its identity and correlation fields but loses its attributes and most of its message. */
|
|
1064
|
+
serializeLog(entry) {
|
|
1065
|
+
const log = this.transformToDataDogLog(entry);
|
|
1066
|
+
const json = stringifyForLog(log);
|
|
1067
|
+
if (Buffer.byteLength(json) <= MAX_LOG_BYTES) return json;
|
|
1068
|
+
const kept = {};
|
|
1069
|
+
for (const key of TRUNCATED_LOG_KEYS) if (log[key] !== void 0) kept[key] = log[key];
|
|
1070
|
+
kept["message"] = String(log["message"]).slice(0, MAX_TRUNCATED_MESSAGE_CHARS);
|
|
1071
|
+
kept["truncated"] = true;
|
|
1072
|
+
return stringifyForLog(kept);
|
|
942
1073
|
}
|
|
943
1074
|
async sendMetric(entry) {
|
|
944
1075
|
await this.sendMetricBatch([entry]);
|
|
@@ -947,29 +1078,35 @@ var DataDogTransport = class extends AnalyticsTransport {
|
|
|
947
1078
|
const payload = { series: entries.map((entry) => this.transformToDataDogMetric(entry)) };
|
|
948
1079
|
await this.makeMetricsRequest("/api/v1/series", payload);
|
|
949
1080
|
}
|
|
950
|
-
async sendTrace(entry) {
|
|
951
|
-
await this.sendLog(entry);
|
|
952
|
-
}
|
|
953
|
-
async sendTraceBatch(entries) {
|
|
954
|
-
await this.sendLogBatch(entries);
|
|
955
|
-
}
|
|
956
1081
|
transformToDataDogLog(entry) {
|
|
1082
|
+
var _entry$data, _entry$data2;
|
|
1083
|
+
const transformed = this.transformEntry(entry);
|
|
1084
|
+
const service = this.datadogConfig.service || "logixia";
|
|
1085
|
+
const env = this.datadogConfig.env || "production";
|
|
1086
|
+
const version = this.datadogConfig.version;
|
|
1087
|
+
const tags = [
|
|
1088
|
+
tag("env", env),
|
|
1089
|
+
tag("service", service),
|
|
1090
|
+
...version ? [tag("version", version)] : []
|
|
1091
|
+
];
|
|
1092
|
+
const spanId = toDatadogId(((_entry$data = entry.data) === null || _entry$data === void 0 ? void 0 : _entry$data["spanId"]) ?? ((_entry$data2 = entry.data) === null || _entry$data2 === void 0 ? void 0 : _entry$data2["span_id"]), false);
|
|
1093
|
+
const traceId = toDatadogId(entry.traceId, true);
|
|
957
1094
|
return {
|
|
958
|
-
...
|
|
959
|
-
"
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
level: this.mapLogLevel(entry.level),
|
|
1095
|
+
...transformed,
|
|
1096
|
+
ddsource: "nodejs",
|
|
1097
|
+
ddtags: tags.join(","),
|
|
1098
|
+
hostname: this.getHostname(),
|
|
1099
|
+
service,
|
|
1100
|
+
status: this.mapLogLevel(entry.level),
|
|
965
1101
|
message: entry.message,
|
|
966
|
-
|
|
967
|
-
version
|
|
968
|
-
env: this.datadogConfig.env || "production",
|
|
1102
|
+
env,
|
|
1103
|
+
version,
|
|
969
1104
|
logger: {
|
|
970
1105
|
name: "logixia",
|
|
971
1106
|
thread_name: "main"
|
|
972
|
-
}
|
|
1107
|
+
},
|
|
1108
|
+
...traceId && { "dd.trace_id": traceId },
|
|
1109
|
+
...traceId && spanId && { "dd.span_id": spanId }
|
|
973
1110
|
};
|
|
974
1111
|
}
|
|
975
1112
|
reservedKeys() {
|
|
@@ -995,58 +1132,29 @@ var DataDogTransport = class extends AnalyticsTransport {
|
|
|
995
1132
|
type: "count",
|
|
996
1133
|
host: this.getHostname(),
|
|
997
1134
|
tags: [
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
...entry.context ? [
|
|
1002
|
-
...entry.appName ? [
|
|
1135
|
+
tag("level", entry.level),
|
|
1136
|
+
tag("service", this.datadogConfig.service || "logixia"),
|
|
1137
|
+
tag("env", this.datadogConfig.env || "production"),
|
|
1138
|
+
...entry.context ? [tag("context", entry.context)] : [],
|
|
1139
|
+
...entry.appName ? [tag("app", entry.appName)] : []
|
|
1003
1140
|
]
|
|
1004
1141
|
};
|
|
1005
1142
|
}
|
|
1006
|
-
transformToDataDogTrace(entry) {
|
|
1007
|
-
return {
|
|
1008
|
-
trace_id: entry.traceId,
|
|
1009
|
-
span_id: this.generateSpanId(),
|
|
1010
|
-
parent_id: null,
|
|
1011
|
-
name: "log.entry",
|
|
1012
|
-
service: this.datadogConfig.service || "logixia",
|
|
1013
|
-
resource: entry.message,
|
|
1014
|
-
type: "log",
|
|
1015
|
-
start: entry.timestamp.getTime() * 1e6,
|
|
1016
|
-
duration: 1e6,
|
|
1017
|
-
meta: {
|
|
1018
|
-
"log.level": entry.level,
|
|
1019
|
-
"log.message": entry.message,
|
|
1020
|
-
...entry.context && { "log.context": entry.context },
|
|
1021
|
-
...entry.data && Object.keys(entry.data).reduce((acc, key) => {
|
|
1022
|
-
acc[`log.${key}`] = String(entry.data[key]);
|
|
1023
|
-
return acc;
|
|
1024
|
-
}, {})
|
|
1025
|
-
},
|
|
1026
|
-
metrics: { _sampling_priority_v1: 1 }
|
|
1027
|
-
};
|
|
1028
|
-
}
|
|
1029
1143
|
mapLogLevel(level) {
|
|
1030
|
-
return
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
warning: "warn",
|
|
1034
|
-
info: "info",
|
|
1035
|
-
debug: "debug",
|
|
1036
|
-
trace: "trace",
|
|
1037
|
-
verbose: "debug"
|
|
1038
|
-
}[level.toLowerCase()] || "info";
|
|
1039
|
-
}
|
|
1040
|
-
async makeLogsRequest(endpoint, data) {
|
|
1144
|
+
return STATUS_MAP[level.toLowerCase()] || "info";
|
|
1145
|
+
}
|
|
1146
|
+
async makeLogsRequest(endpoint, json) {
|
|
1041
1147
|
const url = `${this.logsUrl}${endpoint}`;
|
|
1042
1148
|
try {
|
|
1149
|
+
const compress = this.datadogConfig.compress === true;
|
|
1043
1150
|
const response = await fetch(url, {
|
|
1044
1151
|
method: "POST",
|
|
1045
1152
|
headers: {
|
|
1046
1153
|
"Content-Type": "application/json",
|
|
1047
|
-
"DD-API-KEY": this.datadogConfig.apiKey
|
|
1154
|
+
"DD-API-KEY": this.datadogConfig.apiKey,
|
|
1155
|
+
...compress && { "Content-Encoding": "gzip" }
|
|
1048
1156
|
},
|
|
1049
|
-
body:
|
|
1157
|
+
body: compress ? await gzipAsync(json) : json
|
|
1050
1158
|
});
|
|
1051
1159
|
if (!response.ok) throw new Error(`DataDog Logs API error: ${response.status} ${response.statusText}`);
|
|
1052
1160
|
} catch (error) {
|
|
@@ -1069,9 +1177,6 @@ var DataDogTransport = class extends AnalyticsTransport {
|
|
|
1069
1177
|
throw new Error(`Failed to send metrics to DataDog: ${error.message}`, { cause: error });
|
|
1070
1178
|
}
|
|
1071
1179
|
}
|
|
1072
|
-
generateSpanId() {
|
|
1073
|
-
return Math.floor(Math.random() * 0xffffffffffff).toString(16);
|
|
1074
|
-
}
|
|
1075
1180
|
getHostname() {
|
|
1076
1181
|
try {
|
|
1077
1182
|
return __require("node:os").hostname();
|
|
@@ -1118,9 +1223,7 @@ var DataDogTransport = class extends AnalyticsTransport {
|
|
|
1118
1223
|
}
|
|
1119
1224
|
}
|
|
1120
1225
|
};
|
|
1121
|
-
|
|
1122
|
-
//#endregion
|
|
1123
|
-
//#region src/transports/file.transport.ts
|
|
1226
|
+
// src/transports/file.transport.ts
|
|
1124
1227
|
const appendFile = promisify(fs.appendFile);
|
|
1125
1228
|
const rename = promisify(fs.rename);
|
|
1126
1229
|
const unlink = promisify(fs.unlink);
|
|
@@ -1383,7 +1486,6 @@ var FileTransport = class {
|
|
|
1383
1486
|
csvField(entry.traceId),
|
|
1384
1487
|
csvField(stringifyForLog(entry.data || {}))
|
|
1385
1488
|
].join(",");
|
|
1386
|
-
case "text":
|
|
1387
1489
|
default: return `${entry.timestamp.toISOString()} [${stripControlChars(safeToString(entry.level)).toUpperCase()}] ${stripControlChars(safeToString(entry.message))}${entry.data ? " " + stringifyForLog(entry.data) : ""}`;
|
|
1388
1490
|
}
|
|
1389
1491
|
}
|
|
@@ -1409,22 +1511,22 @@ var FileTransport = class {
|
|
|
1409
1511
|
await this.append(content);
|
|
1410
1512
|
return;
|
|
1411
1513
|
}
|
|
1412
|
-
let chunk
|
|
1514
|
+
let chunk = "";
|
|
1413
1515
|
let chunkBytes = 0;
|
|
1414
1516
|
for (const entry of entries) {
|
|
1415
1517
|
const line = this.formatEntry(entry) + "\n";
|
|
1416
1518
|
const lineBytes = Buffer.byteLength(line);
|
|
1417
1519
|
const used = this.bytesWritten + chunkBytes;
|
|
1418
1520
|
if (used > 0 && used + lineBytes > this.maxBytes) {
|
|
1419
|
-
if (chunk
|
|
1420
|
-
chunk
|
|
1521
|
+
if (chunk) await this.append(chunk, chunkBytes);
|
|
1522
|
+
chunk = "";
|
|
1421
1523
|
chunkBytes = 0;
|
|
1422
1524
|
await this.rotateFile();
|
|
1423
1525
|
}
|
|
1424
|
-
chunk
|
|
1526
|
+
chunk += line;
|
|
1425
1527
|
chunkBytes += lineBytes;
|
|
1426
1528
|
}
|
|
1427
|
-
if (chunk
|
|
1529
|
+
if (chunk) await this.append(chunk, chunkBytes);
|
|
1428
1530
|
}
|
|
1429
1531
|
async append(content, bytes = Buffer.byteLength(content)) {
|
|
1430
1532
|
await appendFile(this.currentFilePath, content, { mode: this.fileMode });
|
|
@@ -1453,7 +1555,7 @@ var FileTransport = class {
|
|
|
1453
1555
|
}
|
|
1454
1556
|
parseInterval(interval) {
|
|
1455
1557
|
const match = /^(\d{1,6})([hdwmy])$/i.exec(interval.trim());
|
|
1456
|
-
if (!match) return
|
|
1558
|
+
if (!match) return 864e5;
|
|
1457
1559
|
const value = Number.parseInt(match[1] || "1", 10);
|
|
1458
1560
|
switch ((match[2] || "h").toLowerCase()) {
|
|
1459
1561
|
case "h": return value * 60 * 60 * 1e3;
|
|
@@ -1568,9 +1670,7 @@ var FileTransport = class {
|
|
|
1568
1670
|
this.reportDropped(0);
|
|
1569
1671
|
}
|
|
1570
1672
|
};
|
|
1571
|
-
|
|
1572
|
-
//#endregion
|
|
1573
|
-
//#region src/transports/google-analytics.transport.ts
|
|
1673
|
+
// src/transports/google-analytics.transport.ts
|
|
1574
1674
|
/**
|
|
1575
1675
|
* Sends log entries as Google Analytics 4 Measurement Protocol events.
|
|
1576
1676
|
*
|
|
@@ -1585,6 +1685,7 @@ var GoogleAnalyticsTransport = class extends AnalyticsTransport {
|
|
|
1585
1685
|
this.baseUrl = "https://www.google-analytics.com/mp/collect";
|
|
1586
1686
|
this.debugUrl = "https://www.google-analytics.com/debug/mp/collect";
|
|
1587
1687
|
this.gaConfig = config;
|
|
1688
|
+
protectSecrets(this, ["gaConfig"]);
|
|
1588
1689
|
}
|
|
1589
1690
|
async initialize() {
|
|
1590
1691
|
try {
|
|
@@ -1672,10 +1773,10 @@ var GoogleAnalyticsTransport = class extends AnalyticsTransport {
|
|
|
1672
1773
|
}
|
|
1673
1774
|
async sendEvents(events) {
|
|
1674
1775
|
const chunks = this.chunkArray(events, 25);
|
|
1675
|
-
for (const chunk
|
|
1776
|
+
for (const chunk of chunks) {
|
|
1676
1777
|
const payload = {
|
|
1677
1778
|
client_id: this.gaConfig.clientId || this.generateClientId(),
|
|
1678
|
-
events: chunk
|
|
1779
|
+
events: chunk
|
|
1679
1780
|
};
|
|
1680
1781
|
await this.makeRequest(payload);
|
|
1681
1782
|
}
|
|
@@ -1796,9 +1897,7 @@ var GoogleAnalyticsTransport = class extends AnalyticsTransport {
|
|
|
1796
1897
|
await this.sendEvent(event);
|
|
1797
1898
|
}
|
|
1798
1899
|
};
|
|
1799
|
-
|
|
1800
|
-
//#endregion
|
|
1801
|
-
//#region src/transports/mixpanel.transport.ts
|
|
1900
|
+
// src/transports/mixpanel.transport.ts
|
|
1802
1901
|
/**
|
|
1803
1902
|
* Sends log entries as Mixpanel events via the Track and Engage HTTP APIs.
|
|
1804
1903
|
*
|
|
@@ -1810,6 +1909,7 @@ var MixpanelTransport = class extends AnalyticsTransport {
|
|
|
1810
1909
|
super("mixpanel", config);
|
|
1811
1910
|
this.baseUrl = "https://api.mixpanel.com";
|
|
1812
1911
|
this.mixpanelConfig = config;
|
|
1912
|
+
protectSecrets(this, ["mixpanelConfig"]);
|
|
1813
1913
|
}
|
|
1814
1914
|
async initialize() {
|
|
1815
1915
|
try {
|
|
@@ -1935,9 +2035,7 @@ var MixpanelTransport = class extends AnalyticsTransport {
|
|
|
1935
2035
|
await this.makeRequest("/track", [payload]);
|
|
1936
2036
|
}
|
|
1937
2037
|
};
|
|
1938
|
-
|
|
1939
|
-
//#endregion
|
|
1940
|
-
//#region src/version.ts
|
|
2038
|
+
// src/version.ts
|
|
1941
2039
|
/**
|
|
1942
2040
|
* The published version of this package.
|
|
1943
2041
|
*
|
|
@@ -1946,9 +2044,7 @@ var MixpanelTransport = class extends AnalyticsTransport {
|
|
|
1946
2044
|
* free of a JSON import that bundlers and consumers would have to resolve.
|
|
1947
2045
|
*/
|
|
1948
2046
|
const LOGIXIA_VERSION = "1.12.0";
|
|
1949
|
-
|
|
1950
|
-
//#endregion
|
|
1951
|
-
//#region src/transports/segment.transport.ts
|
|
2047
|
+
// src/transports/segment.transport.ts
|
|
1952
2048
|
/**
|
|
1953
2049
|
* Sends log entries as Segment track/identify events via the HTTP Tracking API.
|
|
1954
2050
|
*
|
|
@@ -1966,6 +2062,10 @@ var SegmentTransport = class extends AnalyticsTransport {
|
|
|
1966
2062
|
...config
|
|
1967
2063
|
};
|
|
1968
2064
|
this.baseUrl = config.dataPlaneUrl || "https://api.segment.io";
|
|
2065
|
+
protectSecrets(this, ["segmentConfig", "baseUrl"]);
|
|
2066
|
+
}
|
|
2067
|
+
secretValues() {
|
|
2068
|
+
return [...super.secretValues(), Buffer.from(`${this.segmentConfig.writeKey}:`).toString("base64")];
|
|
1969
2069
|
}
|
|
1970
2070
|
async initialize() {
|
|
1971
2071
|
try {
|
|
@@ -2033,8 +2133,8 @@ var SegmentTransport = class extends AnalyticsTransport {
|
|
|
2033
2133
|
}
|
|
2034
2134
|
async batchTrack(events) {
|
|
2035
2135
|
const chunks = this.chunkArray(events, this.segmentConfig.maxBatchSize || 100);
|
|
2036
|
-
for (const chunk
|
|
2037
|
-
const payload = { batch: chunk
|
|
2136
|
+
for (const chunk of chunks) {
|
|
2137
|
+
const payload = { batch: chunk };
|
|
2038
2138
|
await this.makeRequest("/v1/batch", payload);
|
|
2039
2139
|
}
|
|
2040
2140
|
}
|
|
@@ -2211,9 +2311,7 @@ var SegmentTransport = class extends AnalyticsTransport {
|
|
|
2211
2311
|
await this.makeRequest("/v1/track", payload);
|
|
2212
2312
|
}
|
|
2213
2313
|
};
|
|
2214
|
-
|
|
2215
|
-
//#endregion
|
|
2216
|
-
//#region src/transports/transport.manager.ts
|
|
2314
|
+
// src/transports/transport.manager.ts
|
|
2217
2315
|
function _sleep(ms) {
|
|
2218
2316
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2219
2317
|
}
|
|
@@ -2408,7 +2506,6 @@ var TransportManager = class extends EventEmitter {
|
|
|
2408
2506
|
case "linear":
|
|
2409
2507
|
wait = baseDelay * (attempt + 1);
|
|
2410
2508
|
break;
|
|
2411
|
-
case "exponential":
|
|
2412
2509
|
default: wait = Math.min(baseDelay * Math.pow(2, attempt), maxDelay);
|
|
2413
2510
|
}
|
|
2414
2511
|
this.emit("transport:retry", transport.name, attempt + 1, maxRetries, wait);
|
|
@@ -2562,7 +2659,6 @@ var TransportManager = class extends EventEmitter {
|
|
|
2562
2659
|
internalLog("Transport level preferences cleared");
|
|
2563
2660
|
}
|
|
2564
2661
|
};
|
|
2662
|
+
export { FileTransport as a, DatabaseTransport as c, stripControlChars as d, GoogleAnalyticsTransport as i, BufferCap as l, SegmentTransport as n, DataDogTransport as o, MixpanelTransport as r, AnalyticsTransport as s, TransportManager as t, ConsoleTransport as u };
|
|
2565
2663
|
|
|
2566
|
-
//#
|
|
2567
|
-
export { FileTransport as a, DatabaseTransport as c, GoogleAnalyticsTransport as i, ConsoleTransport as l, SegmentTransport as n, DataDogTransport as o, MixpanelTransport as r, AnalyticsTransport as s, TransportManager as t, stripControlChars as u };
|
|
2568
|
-
//# sourceMappingURL=transport.manager-CpdVHEGP.mjs.map
|
|
2664
|
+
//# sourceMappingURL=transport.manager-eZ_EeC00.mjs.map
|