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