@zintrust/trace 0.7.0 → 0.7.2
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/dist/build-manifest.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/trace",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"buildDate": "2026-04-
|
|
3
|
+
"version": "0.7.2",
|
|
4
|
+
"buildDate": "2026-04-18T19:23:29.310Z",
|
|
5
5
|
"buildEnvironment": {
|
|
6
6
|
"node": "v22.22.1",
|
|
7
7
|
"platform": "darwin",
|
|
8
8
|
"arch": "arm64"
|
|
9
9
|
},
|
|
10
10
|
"git": {
|
|
11
|
-
"commit": "
|
|
11
|
+
"commit": "126e1196",
|
|
12
12
|
"branch": "release"
|
|
13
13
|
},
|
|
14
14
|
"package": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"files": {
|
|
24
24
|
"build-manifest.json": {
|
|
25
|
-
"size":
|
|
26
|
-
"sha256": "
|
|
25
|
+
"size": 14744,
|
|
26
|
+
"sha256": "6cd46c9c15b2d55e83b4563969b4180be3c278cda5438003d8ba98b543133a49"
|
|
27
27
|
},
|
|
28
28
|
"cli-register.d.ts": {
|
|
29
29
|
"size": 255,
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
},
|
|
80
80
|
"index.js": {
|
|
81
81
|
"size": 3324,
|
|
82
|
-
"sha256": "
|
|
82
|
+
"sha256": "fea850dbd404cad2e9cf9e29c718dd0596216a4ec766bb8701b399a10c7adeb9"
|
|
83
83
|
},
|
|
84
84
|
"migrations/20260331000001_create_zin_trace_entries_table.d.ts": {
|
|
85
85
|
"size": 304,
|
|
@@ -182,8 +182,8 @@
|
|
|
182
182
|
"sha256": "5f49df97a830ad895653fa4a18b3a1b31ca4a5066d6f8150ee02dca013e16397"
|
|
183
183
|
},
|
|
184
184
|
"storage/TraceWriteDiagnostics.js": {
|
|
185
|
-
"size":
|
|
186
|
-
"sha256": "
|
|
185
|
+
"size": 7041,
|
|
186
|
+
"sha256": "6fc34e6e52a9b463db0967dba4aec4c8c706b6978c496f568637ffc15327279a"
|
|
187
187
|
},
|
|
188
188
|
"storage/index.d.ts": {
|
|
189
189
|
"size": 100,
|
|
@@ -350,8 +350,8 @@
|
|
|
350
350
|
"sha256": "f3ddc5f8b58c6c86ac6b464dd48e5a55e79ab2bf2e735feacffc7480e4ccc0c4"
|
|
351
351
|
},
|
|
352
352
|
"watchers/LogWatcher.js": {
|
|
353
|
-
"size":
|
|
354
|
-
"sha256": "
|
|
353
|
+
"size": 3290,
|
|
354
|
+
"sha256": "0297479465b25f93ab0b11bfd6c2083afe9023fdddaa1b7841d12d68b294fa3e"
|
|
355
355
|
},
|
|
356
356
|
"watchers/MailWatcher.d.ts": {
|
|
357
357
|
"size": 244,
|
|
@@ -69,6 +69,14 @@ const withOptionalDetail = (context, errorDetails) => {
|
|
|
69
69
|
return context;
|
|
70
70
|
return { ...context, errorDetails };
|
|
71
71
|
};
|
|
72
|
+
const TRACE_SKIP_LOG_CONTEXT_KEY = '__zintrustSkipTraceLog';
|
|
73
|
+
const withTraceSkipContext = (logger, context) => {
|
|
74
|
+
const loggerWithTraceSkip = logger;
|
|
75
|
+
return (loggerWithTraceSkip.withTraceSkipContext?.(context) ?? {
|
|
76
|
+
...context,
|
|
77
|
+
[TRACE_SKIP_LOG_CONTEXT_KEY]: true,
|
|
78
|
+
});
|
|
79
|
+
};
|
|
72
80
|
const getErrorMessage = (error) => {
|
|
73
81
|
let baseMessage = '';
|
|
74
82
|
if (error instanceof Error && error.message.trim() !== '') {
|
|
@@ -123,14 +131,14 @@ const reportFailure = (logger, context) => {
|
|
|
123
131
|
if (typeof lastLoggedAt === 'number' && now - lastLoggedAt < LOG_WINDOW_MS)
|
|
124
132
|
return;
|
|
125
133
|
diagnosticsState.lastLoggedAtByFingerprint.set(fingerprint, now);
|
|
126
|
-
logger.warn('[trace] Trace storage write degraded', withOptionalDetail({
|
|
134
|
+
logger.warn('[trace] Trace storage write degraded', withTraceSkipContext(logger, withOptionalDetail({
|
|
127
135
|
connectionName: context.connectionName,
|
|
128
136
|
error: errorMessage,
|
|
129
137
|
lastFailureAt: now,
|
|
130
138
|
operation: context.operation,
|
|
131
139
|
totalFailures: diagnosticsState.totalFailures,
|
|
132
140
|
watcherType: context.watcherType ?? null,
|
|
133
|
-
}, errorDetails));
|
|
141
|
+
}, errorDetails)));
|
|
134
142
|
};
|
|
135
143
|
const wrapStorageMethod = (method, describeFailure, connectionName, logger) => {
|
|
136
144
|
return async (...args) => {
|
|
@@ -46,6 +46,10 @@ const isTraceStorageQueryLog = (message, context) => {
|
|
|
46
46
|
return typeof sql === 'string' && isTraceStorageQuery(sql);
|
|
47
47
|
};
|
|
48
48
|
const shouldSkipTraceInfrastructureLog = (message, context) => {
|
|
49
|
+
const loggerWithTraceSkip = Logger;
|
|
50
|
+
if (loggerWithTraceSkip.shouldSkipTraceLogContext?.(context) === true) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
49
53
|
return (TRACE_INFRASTRUCTURE_LOG_MESSAGES.has(message.trim()) ||
|
|
50
54
|
isTraceStorageQueryLog(message, context));
|
|
51
55
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/trace",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Trace assistant for ZinTrust: logs requests, queries, exceptions, jobs, and more.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"node": ">=20.0.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@zintrust/core": "^0.7.
|
|
43
|
+
"@zintrust/core": "^0.7.2"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
@@ -101,6 +101,24 @@ const withOptionalDetail = (
|
|
|
101
101
|
return { ...context, errorDetails };
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
+
const TRACE_SKIP_LOG_CONTEXT_KEY = '__zintrustSkipTraceLog';
|
|
105
|
+
|
|
106
|
+
const withTraceSkipContext = (
|
|
107
|
+
logger: TraceLogger | undefined,
|
|
108
|
+
context: Record<string, unknown>
|
|
109
|
+
): Record<string, unknown> => {
|
|
110
|
+
const loggerWithTraceSkip = logger as TraceLogger & {
|
|
111
|
+
withTraceSkipContext?: (ctx?: Record<string, unknown>) => Record<string, unknown>;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
loggerWithTraceSkip.withTraceSkipContext?.(context) ?? {
|
|
116
|
+
...context,
|
|
117
|
+
[TRACE_SKIP_LOG_CONTEXT_KEY]: true,
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
|
|
104
122
|
const getErrorMessage = (error: unknown): string => {
|
|
105
123
|
let baseMessage = '';
|
|
106
124
|
if (error instanceof Error && error.message.trim() !== '') {
|
|
@@ -163,16 +181,19 @@ const reportFailure = (
|
|
|
163
181
|
diagnosticsState.lastLoggedAtByFingerprint.set(fingerprint, now);
|
|
164
182
|
logger.warn(
|
|
165
183
|
'[trace] Trace storage write degraded',
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
184
|
+
withTraceSkipContext(
|
|
185
|
+
logger,
|
|
186
|
+
withOptionalDetail(
|
|
187
|
+
{
|
|
188
|
+
connectionName: context.connectionName,
|
|
189
|
+
error: errorMessage,
|
|
190
|
+
lastFailureAt: now,
|
|
191
|
+
operation: context.operation,
|
|
192
|
+
totalFailures: diagnosticsState.totalFailures,
|
|
193
|
+
watcherType: context.watcherType ?? null,
|
|
194
|
+
},
|
|
195
|
+
errorDetails
|
|
196
|
+
)
|
|
176
197
|
)
|
|
177
198
|
);
|
|
178
199
|
};
|
|
@@ -61,6 +61,14 @@ const shouldSkipTraceInfrastructureLog = (
|
|
|
61
61
|
message: string,
|
|
62
62
|
context?: Record<string, unknown>
|
|
63
63
|
): boolean => {
|
|
64
|
+
const loggerWithTraceSkip = Logger as typeof Logger & {
|
|
65
|
+
shouldSkipTraceLogContext?: (ctx?: Record<string, unknown>) => boolean;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
if (loggerWithTraceSkip.shouldSkipTraceLogContext?.(context) === true) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
64
72
|
return (
|
|
65
73
|
TRACE_INFRASTRUCTURE_LOG_MESSAGES.has(message.trim()) ||
|
|
66
74
|
isTraceStorageQueryLog(message, context)
|