@zintrust/trace 0.5.4 → 0.5.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.
- package/dist/config.js +2 -0
- package/dist/dashboard/ui.js +4 -4
- package/dist/storage/TraceContentBudget.js +47 -85
- package/dist/types.d.ts +1 -0
- package/dist/utils/requestFilter.d.ts +7 -2
- package/dist/utils/requestFilter.js +30 -4
- package/dist/watchers/AuthWatcher.js +4 -1
- package/dist/watchers/BatchWatcher.js +4 -1
- package/dist/watchers/CacheWatcher.js +4 -1
- package/dist/watchers/CommandWatcher.js +4 -1
- package/dist/watchers/DumpWatcher.js +4 -1
- package/dist/watchers/EventWatcher.js +4 -1
- package/dist/watchers/ExceptionWatcher.js +5 -2
- package/dist/watchers/GateWatcher.js +4 -1
- package/dist/watchers/HttpClientWatcher.js +4 -1
- package/dist/watchers/HttpWatcher.js +1 -1
- package/dist/watchers/JobWatcher.js +4 -1
- package/dist/watchers/LogWatcher.js +1 -1
- package/dist/watchers/MailWatcher.js +4 -1
- package/dist/watchers/MiddlewareWatcher.js +4 -1
- package/dist/watchers/ModelWatcher.js +4 -1
- package/dist/watchers/NotificationWatcher.js +4 -1
- package/dist/watchers/QueryWatcher.js +1 -1
- package/dist/watchers/RedisWatcher.js +4 -1
- package/dist/watchers/ScheduleWatcher.js +4 -1
- package/dist/watchers/ViewWatcher.js +4 -1
- package/package.json +2 -2
- package/src/config.ts +2 -0
- package/src/dashboard/ui.ts +4 -4
- package/src/storage/TraceContentBudget.ts +57 -118
- package/src/types.ts +1 -0
- package/src/utils/requestFilter.ts +57 -11
- package/src/watchers/AuthWatcher.ts +4 -1
- package/src/watchers/BatchWatcher.ts +4 -1
- package/src/watchers/CacheWatcher.ts +4 -1
- package/src/watchers/CommandWatcher.ts +4 -1
- package/src/watchers/DumpWatcher.ts +4 -1
- package/src/watchers/EventWatcher.ts +4 -1
- package/src/watchers/ExceptionWatcher.ts +5 -2
- package/src/watchers/GateWatcher.ts +4 -1
- package/src/watchers/HttpClientWatcher.ts +4 -1
- package/src/watchers/HttpWatcher.ts +1 -1
- package/src/watchers/JobWatcher.ts +4 -1
- package/src/watchers/LogWatcher.ts +2 -1
- package/src/watchers/MailWatcher.ts +4 -1
- package/src/watchers/MiddlewareWatcher.ts +4 -1
- package/src/watchers/ModelWatcher.ts +4 -1
- package/src/watchers/NotificationWatcher.ts +4 -1
- package/src/watchers/QueryWatcher.ts +1 -1
- package/src/watchers/RedisWatcher.ts +4 -1
- package/src/watchers/ScheduleWatcher.ts +4 -1
- package/src/watchers/ViewWatcher.ts +4 -1
|
@@ -9,10 +9,11 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
9
9
|
|
|
10
10
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
11
11
|
let _ignoreRoutes: string[] = [];
|
|
12
|
+
let _ignorePath: string[] = [];
|
|
12
13
|
|
|
13
14
|
const emit = (event: AuthContent['event'], userId?: string): void => {
|
|
14
15
|
if (!_storage) return;
|
|
15
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
16
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
16
17
|
const content: AuthContent = {
|
|
17
18
|
event,
|
|
18
19
|
userId,
|
|
@@ -42,9 +43,11 @@ export const AuthWatcher: ITraceWatcher & { emit: typeof emit } = Object.freeze(
|
|
|
42
43
|
if (config.watchers.auth === false) return () => undefined;
|
|
43
44
|
_storage = storage;
|
|
44
45
|
_ignoreRoutes = config.ignoreRoutes;
|
|
46
|
+
_ignorePath = config.ignorePath;
|
|
45
47
|
return () => {
|
|
46
48
|
_storage = null;
|
|
47
49
|
_ignoreRoutes = [];
|
|
50
|
+
_ignorePath = [];
|
|
48
51
|
};
|
|
49
52
|
},
|
|
50
53
|
});
|
|
@@ -5,6 +5,7 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
5
5
|
|
|
6
6
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
7
7
|
let _ignoreRoutes: string[] = [];
|
|
8
|
+
let _ignorePath: string[] = [];
|
|
8
9
|
|
|
9
10
|
const emit = (
|
|
10
11
|
name: string,
|
|
@@ -14,7 +15,7 @@ const emit = (
|
|
|
14
15
|
status: BatchContent['status']
|
|
15
16
|
): void => {
|
|
16
17
|
if (!_storage) return;
|
|
17
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
18
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
18
19
|
const tags = [name];
|
|
19
20
|
if (failed > 0) tags.push('failed');
|
|
20
21
|
const content: BatchContent = {
|
|
@@ -44,9 +45,11 @@ export const BatchWatcher: ITraceWatcher & { emit: typeof emit } = Object.freeze
|
|
|
44
45
|
if (config.watchers.batch === false) return () => undefined;
|
|
45
46
|
_storage = storage;
|
|
46
47
|
_ignoreRoutes = config.ignoreRoutes;
|
|
48
|
+
_ignorePath = config.ignorePath;
|
|
47
49
|
return () => {
|
|
48
50
|
_storage = null;
|
|
49
51
|
_ignoreRoutes = [];
|
|
52
|
+
_ignorePath = [];
|
|
50
53
|
};
|
|
51
54
|
},
|
|
52
55
|
});
|
|
@@ -13,6 +13,7 @@ let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
|
13
13
|
let _config: ITraceWatcherConfig['config'] | null = null;
|
|
14
14
|
let _redactionFields: string[] = [];
|
|
15
15
|
let _ignoreRoutes: string[] = [];
|
|
16
|
+
let _ignorePath: string[] = [];
|
|
16
17
|
|
|
17
18
|
const emit = (
|
|
18
19
|
operation: CacheContent['operation'],
|
|
@@ -24,7 +25,7 @@ const emit = (
|
|
|
24
25
|
ttl?: number
|
|
25
26
|
): void => {
|
|
26
27
|
if (!_storage) return;
|
|
27
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
28
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
28
29
|
const safeKey = redactString(key, _redactionFields);
|
|
29
30
|
const shouldLogPayload = _config?.captureCachePayloads === true;
|
|
30
31
|
const content: CacheContent = {
|
|
@@ -60,10 +61,12 @@ export const CacheWatcher: ITraceWatcher & { emit: typeof emit } = Object.freeze
|
|
|
60
61
|
_config = config;
|
|
61
62
|
_redactionFields = config.redaction.query;
|
|
62
63
|
_ignoreRoutes = config.ignoreRoutes;
|
|
64
|
+
_ignorePath = config.ignorePath;
|
|
63
65
|
return () => {
|
|
64
66
|
_storage = null;
|
|
65
67
|
_config = null;
|
|
66
68
|
_ignoreRoutes = [];
|
|
69
|
+
_ignorePath = [];
|
|
67
70
|
};
|
|
68
71
|
},
|
|
69
72
|
});
|
|
@@ -7,6 +7,7 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
7
7
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
8
8
|
let _redactKeys: string[] = [];
|
|
9
9
|
let _ignoreRoutes: string[] = [];
|
|
10
|
+
let _ignorePath: string[] = [];
|
|
10
11
|
|
|
11
12
|
const emit = (
|
|
12
13
|
name: string,
|
|
@@ -16,7 +17,7 @@ const emit = (
|
|
|
16
17
|
output?: string
|
|
17
18
|
): void => {
|
|
18
19
|
if (!_storage) return;
|
|
19
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
20
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
20
21
|
const tags = [name];
|
|
21
22
|
if (exitCode !== 0) tags.push('failed');
|
|
22
23
|
const content: CommandContent = {
|
|
@@ -47,9 +48,11 @@ export const CommandWatcher: ITraceWatcher & { emit: typeof emit } = Object.free
|
|
|
47
48
|
_storage = storage;
|
|
48
49
|
_redactKeys = [...(config.redaction?.keys ?? []), ...(config.redaction?.body ?? [])];
|
|
49
50
|
_ignoreRoutes = config.ignoreRoutes;
|
|
51
|
+
_ignorePath = config.ignorePath;
|
|
50
52
|
return () => {
|
|
51
53
|
_storage = null;
|
|
52
54
|
_ignoreRoutes = [];
|
|
55
|
+
_ignorePath = [];
|
|
53
56
|
};
|
|
54
57
|
},
|
|
55
58
|
});
|
|
@@ -6,11 +6,12 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
6
6
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
7
7
|
let _enabled = false;
|
|
8
8
|
let _ignoreRoutes: string[] = [];
|
|
9
|
+
let _ignorePath: string[] = [];
|
|
9
10
|
|
|
10
11
|
/** Explicitly opt-in (enabled only when config.watchers.dump === true, not just non-false). */
|
|
11
12
|
const emit = (value: unknown, file?: string, line?: number): void => {
|
|
12
13
|
if (!_storage || !_enabled) return;
|
|
13
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
14
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
14
15
|
const content: DumpContent = { value, file, line, hostname: TraceContext.getHostname() };
|
|
15
16
|
_storage
|
|
16
17
|
.writeEntry({
|
|
@@ -33,10 +34,12 @@ export const DumpWatcher: ITraceWatcher & { emit: typeof emit } = Object.freeze(
|
|
|
33
34
|
_storage = storage;
|
|
34
35
|
_enabled = true;
|
|
35
36
|
_ignoreRoutes = config.ignoreRoutes;
|
|
37
|
+
_ignorePath = config.ignorePath;
|
|
36
38
|
return () => {
|
|
37
39
|
_storage = null;
|
|
38
40
|
_enabled = false;
|
|
39
41
|
_ignoreRoutes = [];
|
|
42
|
+
_ignorePath = [];
|
|
40
43
|
};
|
|
41
44
|
},
|
|
42
45
|
});
|
|
@@ -6,10 +6,11 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
6
6
|
|
|
7
7
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
8
8
|
let _ignoreRoutes: string[] = [];
|
|
9
|
+
let _ignorePath: string[] = [];
|
|
9
10
|
|
|
10
11
|
const emit = (name: string, listenerCount: number, payload?: unknown): void => {
|
|
11
12
|
if (!_storage) return;
|
|
12
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
13
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
13
14
|
const content: EventContent = {
|
|
14
15
|
name,
|
|
15
16
|
payload,
|
|
@@ -35,9 +36,11 @@ export const EventWatcher: ITraceWatcher & { emit: typeof emit } = Object.freeze
|
|
|
35
36
|
if (config.watchers.event === false) return () => undefined;
|
|
36
37
|
_storage = storage;
|
|
37
38
|
_ignoreRoutes = config.ignoreRoutes;
|
|
39
|
+
_ignorePath = config.ignorePath;
|
|
38
40
|
return () => {
|
|
39
41
|
_storage = null;
|
|
40
42
|
_ignoreRoutes = [];
|
|
43
|
+
_ignorePath = [];
|
|
41
44
|
};
|
|
42
45
|
},
|
|
43
46
|
});
|
|
@@ -50,6 +50,7 @@ const buildContent = (err: Error, context?: ExceptionCaptureContext): ExceptionC
|
|
|
50
50
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
51
51
|
let _listenerRefCount = 0;
|
|
52
52
|
let _ignoreRoutes: string[] = [];
|
|
53
|
+
let _ignorePath: string[] = [];
|
|
53
54
|
|
|
54
55
|
const handleUncaughtException = (error: unknown): void => {
|
|
55
56
|
captureException(error);
|
|
@@ -76,8 +77,8 @@ const captureException = (err: unknown, context?: ExceptionCaptureContext): void
|
|
|
76
77
|
if (!storage) return;
|
|
77
78
|
if (!(err instanceof Error)) return;
|
|
78
79
|
if (context?.path !== undefined) {
|
|
79
|
-
if (RequestFilter.matchesIgnoredPath(context.path, _ignoreRoutes)) return;
|
|
80
|
-
} else if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) {
|
|
80
|
+
if (RequestFilter.matchesIgnoredPath(context.path, _ignoreRoutes, _ignorePath)) return;
|
|
81
|
+
} else if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) {
|
|
81
82
|
return;
|
|
82
83
|
}
|
|
83
84
|
|
|
@@ -109,6 +110,7 @@ export const ExceptionWatcher: ITraceWatcher & {
|
|
|
109
110
|
if (config.watchers.exception === false) return () => undefined;
|
|
110
111
|
_storage = storage;
|
|
111
112
|
_ignoreRoutes = config.ignoreRoutes;
|
|
113
|
+
_ignorePath = config.ignorePath;
|
|
112
114
|
|
|
113
115
|
if (_listenerRefCount === 0) {
|
|
114
116
|
registerProcessListeners();
|
|
@@ -122,6 +124,7 @@ export const ExceptionWatcher: ITraceWatcher & {
|
|
|
122
124
|
}
|
|
123
125
|
_storage = null;
|
|
124
126
|
_ignoreRoutes = [];
|
|
127
|
+
_ignorePath = [];
|
|
125
128
|
};
|
|
126
129
|
},
|
|
127
130
|
});
|
|
@@ -5,6 +5,7 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
5
5
|
|
|
6
6
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
7
7
|
let _ignoreRoutes: string[] = [];
|
|
8
|
+
let _ignorePath: string[] = [];
|
|
8
9
|
|
|
9
10
|
const emit = (
|
|
10
11
|
ability: string,
|
|
@@ -13,7 +14,7 @@ const emit = (
|
|
|
13
14
|
subject?: string
|
|
14
15
|
): void => {
|
|
15
16
|
if (!_storage) return;
|
|
16
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
17
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
17
18
|
const tags: string[] = [ability, result];
|
|
18
19
|
if (userId) tags.push(`Auth:${userId}`);
|
|
19
20
|
const content: GateContent = {
|
|
@@ -42,9 +43,11 @@ export const GateWatcher: ITraceWatcher & { emit: typeof emit } = Object.freeze(
|
|
|
42
43
|
if (config.watchers.gate === false) return () => undefined;
|
|
43
44
|
_storage = storage;
|
|
44
45
|
_ignoreRoutes = config.ignoreRoutes;
|
|
46
|
+
_ignorePath = config.ignorePath;
|
|
45
47
|
return () => {
|
|
46
48
|
_storage = null;
|
|
47
49
|
_ignoreRoutes = [];
|
|
50
|
+
_ignorePath = [];
|
|
48
51
|
};
|
|
49
52
|
},
|
|
50
53
|
});
|
|
@@ -16,6 +16,7 @@ let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
|
16
16
|
let _redactHeaderNames: string[] = [];
|
|
17
17
|
let _redactBodyFields: string[] = [];
|
|
18
18
|
let _ignoreRoutes: string[] = [];
|
|
19
|
+
let _ignorePath: string[] = [];
|
|
19
20
|
let _clientRequestWatcher: TraceClientRequestWatcherConfig | undefined;
|
|
20
21
|
|
|
21
22
|
const isObjectValue = (value: unknown): value is Record<string, unknown> => {
|
|
@@ -158,7 +159,7 @@ const emit = ({
|
|
|
158
159
|
error,
|
|
159
160
|
}: ClientRequestTraceInput): void => {
|
|
160
161
|
if (!_storage) return;
|
|
161
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
162
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
162
163
|
const normalizedSource = resolveSource(source);
|
|
163
164
|
const sourceRule = resolveSourceRule(normalizedSource);
|
|
164
165
|
if (sourceRule?.enabled === false) return;
|
|
@@ -206,11 +207,13 @@ export const HttpClientWatcher: ITraceWatcher & { emit: typeof emit } = Object.f
|
|
|
206
207
|
_redactHeaderNames = [...(config.redaction?.keys ?? []), ...(config.redaction?.headers ?? [])];
|
|
207
208
|
_redactBodyFields = [...(config.redaction?.keys ?? []), ...(config.redaction?.body ?? [])];
|
|
208
209
|
_ignoreRoutes = config.ignoreRoutes;
|
|
210
|
+
_ignorePath = config.ignorePath;
|
|
209
211
|
return () => {
|
|
210
212
|
_storage = null;
|
|
211
213
|
_clientRequestWatcher = undefined;
|
|
212
214
|
_redactBodyFields = [];
|
|
213
215
|
_ignoreRoutes = [];
|
|
216
|
+
_ignorePath = [];
|
|
214
217
|
};
|
|
215
218
|
},
|
|
216
219
|
});
|
|
@@ -164,7 +164,7 @@ const buildEntry = (
|
|
|
164
164
|
};
|
|
165
165
|
|
|
166
166
|
const shouldIgnore = (req: IRequest, config: ITraceConfig): boolean => {
|
|
167
|
-
return RequestFilter.matchesIgnoredPath(req.getPath(), config
|
|
167
|
+
return RequestFilter.matchesIgnoredPath(req.getPath(), config);
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
const isWatcherEnabled = (config: ITraceConfig): boolean => config.watchers.request !== false;
|
|
@@ -12,6 +12,7 @@ import { parseStackFrameLine } from '../utils/stackFrame';
|
|
|
12
12
|
// Module-level storage ref so emit helpers can be called from outside.
|
|
13
13
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
14
14
|
let _ignoreRoutes: string[] = [];
|
|
15
|
+
let _ignorePath: string[] = [];
|
|
15
16
|
const MAX_TRACKED_JOBS = 1000;
|
|
16
17
|
|
|
17
18
|
type PendingJob = { uuid: string; content: JobContent };
|
|
@@ -43,7 +44,7 @@ const takePendingJob = (name: string): PendingJob | null => {
|
|
|
43
44
|
|
|
44
45
|
const emitDispatch = (name: string, queue: string, connection: string, data?: unknown): void => {
|
|
45
46
|
if (!_storage) return;
|
|
46
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
47
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
47
48
|
const uuid = crypto.randomUUID();
|
|
48
49
|
const content: JobContent = {
|
|
49
50
|
status: 'pending',
|
|
@@ -112,9 +113,11 @@ export const JobWatcher: ITraceWatcher & {
|
|
|
112
113
|
if (config.watchers.job === false) return () => undefined;
|
|
113
114
|
_storage = storage;
|
|
114
115
|
_ignoreRoutes = config.ignoreRoutes;
|
|
116
|
+
_ignorePath = config.ignorePath;
|
|
115
117
|
return () => {
|
|
116
118
|
_storage = null;
|
|
117
119
|
_ignoreRoutes = [];
|
|
120
|
+
_ignorePath = [];
|
|
118
121
|
pendingJobs.clear();
|
|
119
122
|
};
|
|
120
123
|
},
|
|
@@ -82,7 +82,8 @@ export const LogWatcher: ITraceWatcher = Object.freeze({
|
|
|
82
82
|
const unsubscribe = loggerWithSink.addSink(
|
|
83
83
|
(level: string, message: string, context?: Record<string, unknown>) => {
|
|
84
84
|
if ((LEVEL_PRIORITY[level] ?? 0) < minPriority) return;
|
|
85
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(config.ignoreRoutes))
|
|
85
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(config.ignoreRoutes, config.ignorePath))
|
|
86
|
+
return;
|
|
86
87
|
if (shouldSkipTraceInfrastructureLog(message, context)) return;
|
|
87
88
|
|
|
88
89
|
const content: LogContent = {
|
|
@@ -10,6 +10,7 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
10
10
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
11
11
|
let _redactionFields: string[] = [];
|
|
12
12
|
let _ignoreRoutes: string[] = [];
|
|
13
|
+
let _ignorePath: string[] = [];
|
|
13
14
|
|
|
14
15
|
const emit = (
|
|
15
16
|
to: string,
|
|
@@ -19,7 +20,7 @@ const emit = (
|
|
|
19
20
|
html?: string
|
|
20
21
|
): void => {
|
|
21
22
|
if (!_storage) return;
|
|
22
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
23
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
23
24
|
const content: MailContent = {
|
|
24
25
|
to,
|
|
25
26
|
subject,
|
|
@@ -53,10 +54,12 @@ export const MailWatcher: ITraceWatcher & { emit: typeof emit } = Object.freeze(
|
|
|
53
54
|
_storage = storage;
|
|
54
55
|
_redactionFields = [...config.redaction.keys, ...config.redaction.body];
|
|
55
56
|
_ignoreRoutes = config.ignoreRoutes;
|
|
57
|
+
_ignorePath = config.ignorePath;
|
|
56
58
|
return () => {
|
|
57
59
|
_storage = null;
|
|
58
60
|
_redactionFields = [];
|
|
59
61
|
_ignoreRoutes = [];
|
|
62
|
+
_ignorePath = [];
|
|
60
63
|
};
|
|
61
64
|
},
|
|
62
65
|
});
|
|
@@ -5,6 +5,7 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
5
5
|
|
|
6
6
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
7
7
|
let _ignoreRoutes: string[] = [];
|
|
8
|
+
let _ignorePath: string[] = [];
|
|
8
9
|
|
|
9
10
|
type GlobalMiddlewareTraceState = {
|
|
10
11
|
__zintrust_trace_middleware_emit__?: typeof emit;
|
|
@@ -12,7 +13,7 @@ type GlobalMiddlewareTraceState = {
|
|
|
12
13
|
|
|
13
14
|
const emit = (name: string, event: MiddlewareContent['event'], duration?: number): void => {
|
|
14
15
|
if (!_storage) return;
|
|
15
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
16
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
16
17
|
const content: MiddlewareContent = {
|
|
17
18
|
name,
|
|
18
19
|
event,
|
|
@@ -38,6 +39,7 @@ export const MiddlewareWatcher: ITraceWatcher & { emit: typeof emit } = Object.f
|
|
|
38
39
|
if (config.watchers.middleware === false) return () => undefined;
|
|
39
40
|
_storage = storage;
|
|
40
41
|
_ignoreRoutes = config.ignoreRoutes;
|
|
42
|
+
_ignorePath = config.ignorePath;
|
|
41
43
|
(globalThis as unknown as GlobalMiddlewareTraceState).__zintrust_trace_middleware_emit__ = emit;
|
|
42
44
|
return () => {
|
|
43
45
|
const globalState = globalThis as unknown as GlobalMiddlewareTraceState;
|
|
@@ -46,6 +48,7 @@ export const MiddlewareWatcher: ITraceWatcher & { emit: typeof emit } = Object.f
|
|
|
46
48
|
}
|
|
47
49
|
_storage = null;
|
|
48
50
|
_ignoreRoutes = [];
|
|
51
|
+
_ignorePath = [];
|
|
49
52
|
};
|
|
50
53
|
},
|
|
51
54
|
});
|
|
@@ -5,6 +5,7 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
5
5
|
|
|
6
6
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
7
7
|
let _ignoreRoutes: string[] = [];
|
|
8
|
+
let _ignorePath: string[] = [];
|
|
8
9
|
|
|
9
10
|
type GlobalModelTraceState = {
|
|
10
11
|
__zintrust_trace_model_emit__?: typeof emit;
|
|
@@ -17,7 +18,7 @@ const emit = (
|
|
|
17
18
|
changes?: Record<string, unknown>
|
|
18
19
|
): void => {
|
|
19
20
|
if (!_storage) return;
|
|
20
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
21
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
21
22
|
const content: ModelContent = {
|
|
22
23
|
action,
|
|
23
24
|
model,
|
|
@@ -44,6 +45,7 @@ export const ModelWatcher: ITraceWatcher & { emit: typeof emit } = Object.freeze
|
|
|
44
45
|
if (config.watchers.model === false) return () => undefined;
|
|
45
46
|
_storage = storage;
|
|
46
47
|
_ignoreRoutes = config.ignoreRoutes;
|
|
48
|
+
_ignorePath = config.ignorePath;
|
|
47
49
|
(globalThis as unknown as GlobalModelTraceState).__zintrust_trace_model_emit__ = emit;
|
|
48
50
|
return () => {
|
|
49
51
|
const globalState = globalThis as unknown as GlobalModelTraceState;
|
|
@@ -52,6 +54,7 @@ export const ModelWatcher: ITraceWatcher & { emit: typeof emit } = Object.freeze
|
|
|
52
54
|
}
|
|
53
55
|
_storage = null;
|
|
54
56
|
_ignoreRoutes = [];
|
|
57
|
+
_ignorePath = [];
|
|
55
58
|
};
|
|
56
59
|
},
|
|
57
60
|
});
|
|
@@ -8,6 +8,7 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
8
8
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
9
9
|
let _redactionFields: string[] = [];
|
|
10
10
|
let _ignoreRoutes: string[] = [];
|
|
11
|
+
let _ignorePath: string[] = [];
|
|
11
12
|
|
|
12
13
|
const emit = (
|
|
13
14
|
notification: string,
|
|
@@ -17,7 +18,7 @@ const emit = (
|
|
|
17
18
|
payload?: unknown
|
|
18
19
|
): void => {
|
|
19
20
|
if (!_storage) return;
|
|
20
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
21
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
21
22
|
const content: NotificationContent = {
|
|
22
23
|
notification,
|
|
23
24
|
channels,
|
|
@@ -48,10 +49,12 @@ export const NotificationWatcher: ITraceWatcher & { emit: typeof emit } = Object
|
|
|
48
49
|
_storage = storage;
|
|
49
50
|
_redactionFields = [...config.redaction.keys, ...config.redaction.body];
|
|
50
51
|
_ignoreRoutes = config.ignoreRoutes;
|
|
52
|
+
_ignorePath = config.ignorePath;
|
|
51
53
|
return () => {
|
|
52
54
|
_storage = null;
|
|
53
55
|
_redactionFields = [];
|
|
54
56
|
_ignoreRoutes = [];
|
|
57
|
+
_ignorePath = [];
|
|
55
58
|
};
|
|
56
59
|
},
|
|
57
60
|
});
|
|
@@ -33,7 +33,7 @@ const isTraceStorageQuery = (sql: string): boolean => {
|
|
|
33
33
|
|
|
34
34
|
const emit = (query: string, params: unknown[], duration: number, connection = 'default'): void => {
|
|
35
35
|
if (_storage === null || _config === null) return;
|
|
36
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_config.ignoreRoutes)) return;
|
|
36
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_config.ignoreRoutes, _config.ignorePath)) return;
|
|
37
37
|
if (isTraceStorageQuery(query)) return;
|
|
38
38
|
|
|
39
39
|
const batchId = TraceContext.getBatchId();
|
|
@@ -6,11 +6,12 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
6
6
|
|
|
7
7
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
8
8
|
let _ignoreRoutes: string[] = [];
|
|
9
|
+
let _ignorePath: string[] = [];
|
|
9
10
|
|
|
10
11
|
/** Emit a redis command trace. Key/value payload is intentionally omitted for security. */
|
|
11
12
|
const emit = (command: string, duration: number): void => {
|
|
12
13
|
if (!_storage) return;
|
|
13
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
14
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
14
15
|
const content: RedisContent = { command, duration, hostname: TraceContext.getHostname() };
|
|
15
16
|
_storage
|
|
16
17
|
.writeEntry({
|
|
@@ -31,9 +32,11 @@ export const RedisWatcher: ITraceWatcher & { emit: typeof emit } = Object.freeze
|
|
|
31
32
|
if (config.watchers.redis === false) return () => undefined;
|
|
32
33
|
_storage = storage;
|
|
33
34
|
_ignoreRoutes = config.ignoreRoutes;
|
|
35
|
+
_ignorePath = config.ignorePath;
|
|
34
36
|
return () => {
|
|
35
37
|
_storage = null;
|
|
36
38
|
_ignoreRoutes = [];
|
|
39
|
+
_ignorePath = [];
|
|
37
40
|
};
|
|
38
41
|
},
|
|
39
42
|
});
|
|
@@ -8,6 +8,7 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
8
8
|
|
|
9
9
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
10
10
|
let _ignoreRoutes: string[] = [];
|
|
11
|
+
let _ignorePath: string[] = [];
|
|
11
12
|
|
|
12
13
|
const emit = (
|
|
13
14
|
name: string,
|
|
@@ -17,7 +18,7 @@ const emit = (
|
|
|
17
18
|
output?: string
|
|
18
19
|
): void => {
|
|
19
20
|
if (!_storage) return;
|
|
20
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
21
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
21
22
|
const content: ScheduleContent = {
|
|
22
23
|
name,
|
|
23
24
|
expression,
|
|
@@ -46,9 +47,11 @@ export const ScheduleWatcher: ITraceWatcher & { emit: typeof emit } = Object.fre
|
|
|
46
47
|
if (config.watchers.schedule === false) return () => undefined;
|
|
47
48
|
_storage = storage;
|
|
48
49
|
_ignoreRoutes = config.ignoreRoutes;
|
|
50
|
+
_ignorePath = config.ignorePath;
|
|
49
51
|
return () => {
|
|
50
52
|
_storage = null;
|
|
51
53
|
_ignoreRoutes = [];
|
|
54
|
+
_ignorePath = [];
|
|
52
55
|
};
|
|
53
56
|
},
|
|
54
57
|
});
|
|
@@ -5,10 +5,11 @@ import { RequestFilter } from '../utils/requestFilter';
|
|
|
5
5
|
|
|
6
6
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
7
7
|
let _ignoreRoutes: string[] = [];
|
|
8
|
+
let _ignorePath: string[] = [];
|
|
8
9
|
|
|
9
10
|
const emit = (template: string, duration: number): void => {
|
|
10
11
|
if (!_storage) return;
|
|
11
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
12
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePath)) return;
|
|
12
13
|
const content: ViewContent = { template, duration, hostname: TraceContext.getHostname() };
|
|
13
14
|
_storage
|
|
14
15
|
.writeEntry({
|
|
@@ -29,9 +30,11 @@ export const ViewWatcher: ITraceWatcher & { emit: typeof emit } = Object.freeze(
|
|
|
29
30
|
if (config.watchers.view === false) return () => undefined;
|
|
30
31
|
_storage = storage;
|
|
31
32
|
_ignoreRoutes = config.ignoreRoutes;
|
|
33
|
+
_ignorePath = config.ignorePath;
|
|
32
34
|
return () => {
|
|
33
35
|
_storage = null;
|
|
34
36
|
_ignoreRoutes = [];
|
|
37
|
+
_ignorePath = [];
|
|
35
38
|
};
|
|
36
39
|
},
|
|
37
40
|
});
|