@zintrust/trace 0.7.0 → 0.7.7

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.
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@zintrust/trace",
3
- "version": "0.7.0",
4
- "buildDate": "2026-04-17T14:20:06.644Z",
3
+ "version": "0.7.7",
4
+ "buildDate": "2026-04-19T14:53:01.931Z",
5
5
  "buildEnvironment": {
6
6
  "node": "v22.22.1",
7
7
  "platform": "darwin",
8
8
  "arch": "arm64"
9
9
  },
10
10
  "git": {
11
- "commit": "5b1c8641",
11
+ "commit": "a24f7050",
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": 14743,
26
- "sha256": "28f88d02b98b9c6fcfb60b9344de6eebd8307e3186da15e82d1e4332691ac87d"
25
+ "size": 14744,
26
+ "sha256": "f5f50503c1274eef8ca9ed655ce83aa193d86cbb88aedb8c474f8734ee7b8975"
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": "0ff435971e5fb1664cc95787db83a609997ecfee3b389275467e6a8944cf8c0c"
82
+ "sha256": "2a1654480aaa24ce2b671b4c509300b525e8fd83d11c5f0a8c57bb667579a4fc"
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": 6714,
186
- "sha256": "398b2cb74e2e7278c6a3b5d29537e7a95581e0a1cb9fb5831f7ff13ac70805e4"
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": 3146,
354
- "sha256": "aa8a8e7d324a217911640d4616fc9c41f07cb1c3f4ad130a8a05b6c213516fba"
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.0",
3
+ "version": "0.7.7",
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.0"
43
+ "@zintrust/core": "^0.7.7"
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
- withOptionalDetail(
167
- {
168
- connectionName: context.connectionName,
169
- error: errorMessage,
170
- lastFailureAt: now,
171
- operation: context.operation,
172
- totalFailures: diagnosticsState.totalFailures,
173
- watcherType: context.watcherType ?? null,
174
- },
175
- errorDetails
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)