@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/dist/config.js
CHANGED
|
@@ -169,7 +169,7 @@ const DEFAULTS = Object.freeze({
|
|
|
169
169
|
observeConnection: undefined,
|
|
170
170
|
pruneAfterHours: 24,
|
|
171
171
|
ignoreRoutes: ['/trace', '/health', '/ping'],
|
|
172
|
-
|
|
172
|
+
ignorePaths: [],
|
|
173
173
|
slowQueryThreshold: 100,
|
|
174
174
|
captureCachePayloads: false,
|
|
175
175
|
captureQueryBindings: true,
|
|
@@ -256,7 +256,7 @@ export const TraceConfig = Object.freeze({
|
|
|
256
256
|
query: mergeStringLists(DEFAULTS.redaction.query, overrides.redaction?.query),
|
|
257
257
|
},
|
|
258
258
|
ignoreRoutes: overrides.ignoreRoutes ?? DEFAULTS.ignoreRoutes,
|
|
259
|
-
|
|
259
|
+
ignorePaths: overrides.ignorePaths ?? DEFAULTS.ignorePaths,
|
|
260
260
|
});
|
|
261
261
|
},
|
|
262
262
|
getRedactionFields,
|
package/dist/types.d.ts
CHANGED
|
@@ -347,7 +347,7 @@ export interface ITraceConfig {
|
|
|
347
347
|
observeConnection?: string;
|
|
348
348
|
pruneAfterHours: number;
|
|
349
349
|
ignoreRoutes: string[];
|
|
350
|
-
|
|
350
|
+
ignorePaths: string[];
|
|
351
351
|
slowQueryThreshold: number;
|
|
352
352
|
captureCachePayloads: boolean;
|
|
353
353
|
captureQueryBindings: boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
type RequestIgnoreRules = {
|
|
2
2
|
ignoreRoutes?: string[];
|
|
3
|
-
|
|
3
|
+
ignorePaths?: string[];
|
|
4
4
|
};
|
|
5
5
|
export declare const RequestFilter: Readonly<{
|
|
6
|
-
matchesIgnoredPath: (path: string, ignoreRoutesOrRules: string[] | RequestIgnoreRules,
|
|
7
|
-
shouldIgnoreCurrentRequest: (ignoreRoutesOrRules: string[] | RequestIgnoreRules,
|
|
6
|
+
matchesIgnoredPath: (path: string, ignoreRoutesOrRules: string[] | RequestIgnoreRules, ignorePaths?: string[]) => boolean;
|
|
7
|
+
shouldIgnoreCurrentRequest: (ignoreRoutesOrRules: string[] | RequestIgnoreRules, ignorePaths?: string[]) => boolean;
|
|
8
8
|
}>;
|
|
9
9
|
export {};
|
|
@@ -11,21 +11,21 @@ const normalizeContainsPattern = (input) => {
|
|
|
11
11
|
const [pathOnly] = trimmed.split('?');
|
|
12
12
|
return pathOnly ?? '';
|
|
13
13
|
};
|
|
14
|
-
const resolveRules = (ignoreRoutesOrRules,
|
|
14
|
+
const resolveRules = (ignoreRoutesOrRules, ignorePaths) => {
|
|
15
15
|
if (Array.isArray(ignoreRoutesOrRules)) {
|
|
16
16
|
return {
|
|
17
17
|
ignoreRoutes: ignoreRoutesOrRules,
|
|
18
|
-
|
|
18
|
+
ignorePaths: ignorePaths ?? [],
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
return {
|
|
22
22
|
ignoreRoutes: ignoreRoutesOrRules.ignoreRoutes ?? [],
|
|
23
|
-
|
|
23
|
+
ignorePaths: ignoreRoutesOrRules.ignorePaths ?? [],
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
const matchesIgnoredPath = (path, ignoreRoutesOrRules,
|
|
26
|
+
const matchesIgnoredPath = (path, ignoreRoutesOrRules, ignorePaths) => {
|
|
27
27
|
const normalizedPath = normalizePath(path);
|
|
28
|
-
const rules = resolveRules(ignoreRoutesOrRules,
|
|
28
|
+
const rules = resolveRules(ignoreRoutesOrRules, ignorePaths);
|
|
29
29
|
if (rules.ignoreRoutes.some((route) => {
|
|
30
30
|
const normalizedRoute = normalizePath(route);
|
|
31
31
|
return (normalizedPath === normalizedRoute ||
|
|
@@ -33,18 +33,18 @@ const matchesIgnoredPath = (path, ignoreRoutesOrRules, ignorePath) => {
|
|
|
33
33
|
})) {
|
|
34
34
|
return true;
|
|
35
35
|
}
|
|
36
|
-
return rules.
|
|
36
|
+
return rules.ignorePaths.some((route) => {
|
|
37
37
|
const containsPattern = normalizeContainsPattern(route);
|
|
38
38
|
if (containsPattern === '')
|
|
39
39
|
return false;
|
|
40
40
|
return normalizedPath.includes(containsPattern);
|
|
41
41
|
});
|
|
42
42
|
};
|
|
43
|
-
const shouldIgnoreCurrentRequest = (ignoreRoutesOrRules,
|
|
43
|
+
const shouldIgnoreCurrentRequest = (ignoreRoutesOrRules, ignorePaths) => {
|
|
44
44
|
const currentPath = TraceContext.getRequestPath();
|
|
45
45
|
if (typeof currentPath !== 'string' || currentPath === '')
|
|
46
46
|
return false;
|
|
47
|
-
return matchesIgnoredPath(currentPath, ignoreRoutesOrRules,
|
|
47
|
+
return matchesIgnoredPath(currentPath, ignoreRoutesOrRules, ignorePaths);
|
|
48
48
|
};
|
|
49
49
|
export const RequestFilter = Object.freeze({
|
|
50
50
|
matchesIgnoredPath,
|
|
@@ -7,11 +7,11 @@ import { EntryType } from '../types.js';
|
|
|
7
7
|
import { RequestFilter } from '../utils/requestFilter.js';
|
|
8
8
|
let _storage = null;
|
|
9
9
|
let _ignoreRoutes = [];
|
|
10
|
-
let
|
|
10
|
+
let _ignorePaths = [];
|
|
11
11
|
const emit = (event, userId) => {
|
|
12
12
|
if (!_storage)
|
|
13
13
|
return;
|
|
14
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
14
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
15
15
|
return;
|
|
16
16
|
const content = {
|
|
17
17
|
event,
|
|
@@ -42,11 +42,11 @@ export const AuthWatcher = Object.freeze({
|
|
|
42
42
|
return () => undefined;
|
|
43
43
|
_storage = storage;
|
|
44
44
|
_ignoreRoutes = config.ignoreRoutes;
|
|
45
|
-
|
|
45
|
+
_ignorePaths = config.ignorePaths;
|
|
46
46
|
return () => {
|
|
47
47
|
_storage = null;
|
|
48
48
|
_ignoreRoutes = [];
|
|
49
|
-
|
|
49
|
+
_ignorePaths = [];
|
|
50
50
|
};
|
|
51
51
|
},
|
|
52
52
|
});
|
|
@@ -3,11 +3,11 @@ import { EntryType } from '../types.js';
|
|
|
3
3
|
import { RequestFilter } from '../utils/requestFilter.js';
|
|
4
4
|
let _storage = null;
|
|
5
5
|
let _ignoreRoutes = [];
|
|
6
|
-
let
|
|
6
|
+
let _ignorePaths = [];
|
|
7
7
|
const emit = (name, total, processed, failed, status) => {
|
|
8
8
|
if (!_storage)
|
|
9
9
|
return;
|
|
10
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
10
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
11
11
|
return;
|
|
12
12
|
const tags = [name];
|
|
13
13
|
if (failed > 0)
|
|
@@ -39,11 +39,11 @@ export const BatchWatcher = Object.freeze({
|
|
|
39
39
|
return () => undefined;
|
|
40
40
|
_storage = storage;
|
|
41
41
|
_ignoreRoutes = config.ignoreRoutes;
|
|
42
|
-
|
|
42
|
+
_ignorePaths = config.ignorePaths;
|
|
43
43
|
return () => {
|
|
44
44
|
_storage = null;
|
|
45
45
|
_ignoreRoutes = [];
|
|
46
|
-
|
|
46
|
+
_ignorePaths = [];
|
|
47
47
|
};
|
|
48
48
|
},
|
|
49
49
|
});
|
|
@@ -11,11 +11,11 @@ let _storage = null;
|
|
|
11
11
|
let _config = null;
|
|
12
12
|
let _redactionFields = [];
|
|
13
13
|
let _ignoreRoutes = [];
|
|
14
|
-
let
|
|
14
|
+
let _ignorePaths = [];
|
|
15
15
|
const emit = (operation, key, duration, hit, payload, store, ttl) => {
|
|
16
16
|
if (!_storage)
|
|
17
17
|
return;
|
|
18
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
18
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
19
19
|
return;
|
|
20
20
|
const safeKey = redactString(key, _redactionFields);
|
|
21
21
|
const shouldLogPayload = _config?.captureCachePayloads === true;
|
|
@@ -51,12 +51,12 @@ export const CacheWatcher = Object.freeze({
|
|
|
51
51
|
_config = config;
|
|
52
52
|
_redactionFields = config.redaction.query;
|
|
53
53
|
_ignoreRoutes = config.ignoreRoutes;
|
|
54
|
-
|
|
54
|
+
_ignorePaths = config.ignorePaths;
|
|
55
55
|
return () => {
|
|
56
56
|
_storage = null;
|
|
57
57
|
_config = null;
|
|
58
58
|
_ignoreRoutes = [];
|
|
59
|
-
|
|
59
|
+
_ignorePaths = [];
|
|
60
60
|
};
|
|
61
61
|
},
|
|
62
62
|
});
|
|
@@ -5,11 +5,11 @@ import { RequestFilter } from '../utils/requestFilter.js';
|
|
|
5
5
|
let _storage = null;
|
|
6
6
|
let _redactKeys = [];
|
|
7
7
|
let _ignoreRoutes = [];
|
|
8
|
-
let
|
|
8
|
+
let _ignorePaths = [];
|
|
9
9
|
const emit = (name, args, exitCode, duration, output) => {
|
|
10
10
|
if (!_storage)
|
|
11
11
|
return;
|
|
12
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
12
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
13
13
|
return;
|
|
14
14
|
const tags = [name];
|
|
15
15
|
if (exitCode !== 0)
|
|
@@ -42,11 +42,11 @@ export const CommandWatcher = Object.freeze({
|
|
|
42
42
|
_storage = storage;
|
|
43
43
|
_redactKeys = [...(config.redaction?.keys ?? []), ...(config.redaction?.body ?? [])];
|
|
44
44
|
_ignoreRoutes = config.ignoreRoutes;
|
|
45
|
-
|
|
45
|
+
_ignorePaths = config.ignorePaths;
|
|
46
46
|
return () => {
|
|
47
47
|
_storage = null;
|
|
48
48
|
_ignoreRoutes = [];
|
|
49
|
-
|
|
49
|
+
_ignorePaths = [];
|
|
50
50
|
};
|
|
51
51
|
},
|
|
52
52
|
});
|
|
@@ -4,12 +4,12 @@ import { RequestFilter } from '../utils/requestFilter.js';
|
|
|
4
4
|
let _storage = null;
|
|
5
5
|
let _enabled = false;
|
|
6
6
|
let _ignoreRoutes = [];
|
|
7
|
-
let
|
|
7
|
+
let _ignorePaths = [];
|
|
8
8
|
/** Explicitly opt-in (enabled only when config.watchers.dump === true, not just non-false). */
|
|
9
9
|
const emit = (value, file, line) => {
|
|
10
10
|
if (!_storage || !_enabled)
|
|
11
11
|
return;
|
|
12
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
12
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
13
13
|
return;
|
|
14
14
|
const content = { value, file, line, hostname: TraceContext.getHostname() };
|
|
15
15
|
_storage
|
|
@@ -33,12 +33,12 @@ export const DumpWatcher = Object.freeze({
|
|
|
33
33
|
_storage = storage;
|
|
34
34
|
_enabled = true;
|
|
35
35
|
_ignoreRoutes = config.ignoreRoutes;
|
|
36
|
-
|
|
36
|
+
_ignorePaths = config.ignorePaths;
|
|
37
37
|
return () => {
|
|
38
38
|
_storage = null;
|
|
39
39
|
_enabled = false;
|
|
40
40
|
_ignoreRoutes = [];
|
|
41
|
-
|
|
41
|
+
_ignorePaths = [];
|
|
42
42
|
};
|
|
43
43
|
},
|
|
44
44
|
});
|
|
@@ -4,11 +4,11 @@ import { AuthTag } from '../utils/authTag.js';
|
|
|
4
4
|
import { RequestFilter } from '../utils/requestFilter.js';
|
|
5
5
|
let _storage = null;
|
|
6
6
|
let _ignoreRoutes = [];
|
|
7
|
-
let
|
|
7
|
+
let _ignorePaths = [];
|
|
8
8
|
const emit = (name, listenerCount, payload) => {
|
|
9
9
|
if (!_storage)
|
|
10
10
|
return;
|
|
11
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
11
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
12
12
|
return;
|
|
13
13
|
const content = {
|
|
14
14
|
name,
|
|
@@ -35,11 +35,11 @@ export const EventWatcher = Object.freeze({
|
|
|
35
35
|
return () => undefined;
|
|
36
36
|
_storage = storage;
|
|
37
37
|
_ignoreRoutes = config.ignoreRoutes;
|
|
38
|
-
|
|
38
|
+
_ignorePaths = config.ignorePaths;
|
|
39
39
|
return () => {
|
|
40
40
|
_storage = null;
|
|
41
41
|
_ignoreRoutes = [];
|
|
42
|
-
|
|
42
|
+
_ignorePaths = [];
|
|
43
43
|
};
|
|
44
44
|
},
|
|
45
45
|
});
|
|
@@ -37,7 +37,7 @@ const buildContent = (err, context) => {
|
|
|
37
37
|
let _storage = null;
|
|
38
38
|
let _listenerRefCount = 0;
|
|
39
39
|
let _ignoreRoutes = [];
|
|
40
|
-
let
|
|
40
|
+
let _ignorePaths = [];
|
|
41
41
|
const handleUncaughtException = (error) => {
|
|
42
42
|
captureException(error);
|
|
43
43
|
};
|
|
@@ -63,10 +63,10 @@ const captureException = (err, context) => {
|
|
|
63
63
|
if (!(err instanceof Error))
|
|
64
64
|
return;
|
|
65
65
|
if (context?.path !== undefined) {
|
|
66
|
-
if (RequestFilter.matchesIgnoredPath(context.path, _ignoreRoutes,
|
|
66
|
+
if (RequestFilter.matchesIgnoredPath(context.path, _ignoreRoutes, _ignorePaths))
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
else if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
69
|
+
else if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths)) {
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
const content = buildContent(err, context);
|
|
@@ -93,7 +93,7 @@ export const ExceptionWatcher = Object.freeze({
|
|
|
93
93
|
return () => undefined;
|
|
94
94
|
_storage = storage;
|
|
95
95
|
_ignoreRoutes = config.ignoreRoutes;
|
|
96
|
-
|
|
96
|
+
_ignorePaths = config.ignorePaths;
|
|
97
97
|
if (_listenerRefCount === 0) {
|
|
98
98
|
registerProcessListeners();
|
|
99
99
|
}
|
|
@@ -105,7 +105,7 @@ export const ExceptionWatcher = Object.freeze({
|
|
|
105
105
|
}
|
|
106
106
|
_storage = null;
|
|
107
107
|
_ignoreRoutes = [];
|
|
108
|
-
|
|
108
|
+
_ignorePaths = [];
|
|
109
109
|
};
|
|
110
110
|
},
|
|
111
111
|
});
|
|
@@ -3,11 +3,11 @@ import { EntryType } from '../types.js';
|
|
|
3
3
|
import { RequestFilter } from '../utils/requestFilter.js';
|
|
4
4
|
let _storage = null;
|
|
5
5
|
let _ignoreRoutes = [];
|
|
6
|
-
let
|
|
6
|
+
let _ignorePaths = [];
|
|
7
7
|
const emit = (ability, result, userId, subject) => {
|
|
8
8
|
if (!_storage)
|
|
9
9
|
return;
|
|
10
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
10
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
11
11
|
return;
|
|
12
12
|
const tags = [ability, result];
|
|
13
13
|
if (userId)
|
|
@@ -38,11 +38,11 @@ export const GateWatcher = Object.freeze({
|
|
|
38
38
|
return () => undefined;
|
|
39
39
|
_storage = storage;
|
|
40
40
|
_ignoreRoutes = config.ignoreRoutes;
|
|
41
|
-
|
|
41
|
+
_ignorePaths = config.ignorePaths;
|
|
42
42
|
return () => {
|
|
43
43
|
_storage = null;
|
|
44
44
|
_ignoreRoutes = [];
|
|
45
|
-
|
|
45
|
+
_ignorePaths = [];
|
|
46
46
|
};
|
|
47
47
|
},
|
|
48
48
|
});
|
|
@@ -7,7 +7,7 @@ let _storage = null;
|
|
|
7
7
|
let _redactHeaderNames = [];
|
|
8
8
|
let _redactBodyFields = [];
|
|
9
9
|
let _ignoreRoutes = [];
|
|
10
|
-
let
|
|
10
|
+
let _ignorePaths = [];
|
|
11
11
|
let _clientRequestWatcher;
|
|
12
12
|
const isObjectValue = (value) => {
|
|
13
13
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -103,7 +103,7 @@ const isWatcherEnabled = (value) => {
|
|
|
103
103
|
const emit = ({ source, method, url, requestHeaders, responseStatus, duration, requestBody, responseHeaders, responseBody, error, }) => {
|
|
104
104
|
if (!_storage)
|
|
105
105
|
return;
|
|
106
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
106
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
107
107
|
return;
|
|
108
108
|
const normalizedSource = resolveSource(source);
|
|
109
109
|
const sourceRule = resolveSourceRule(normalizedSource);
|
|
@@ -151,13 +151,13 @@ export const HttpClientWatcher = Object.freeze({
|
|
|
151
151
|
_redactHeaderNames = [...(config.redaction?.keys ?? []), ...(config.redaction?.headers ?? [])];
|
|
152
152
|
_redactBodyFields = [...(config.redaction?.keys ?? []), ...(config.redaction?.body ?? [])];
|
|
153
153
|
_ignoreRoutes = config.ignoreRoutes;
|
|
154
|
-
|
|
154
|
+
_ignorePaths = config.ignorePaths;
|
|
155
155
|
return () => {
|
|
156
156
|
_storage = null;
|
|
157
157
|
_clientRequestWatcher = undefined;
|
|
158
158
|
_redactBodyFields = [];
|
|
159
159
|
_ignoreRoutes = [];
|
|
160
|
-
|
|
160
|
+
_ignorePaths = [];
|
|
161
161
|
};
|
|
162
162
|
},
|
|
163
163
|
});
|
|
@@ -10,7 +10,7 @@ import { parseStackFrameLine } from '../utils/stackFrame.js';
|
|
|
10
10
|
// Module-level storage ref so emit helpers can be called from outside.
|
|
11
11
|
let _storage = null;
|
|
12
12
|
let _ignoreRoutes = [];
|
|
13
|
-
let
|
|
13
|
+
let _ignorePaths = [];
|
|
14
14
|
const MAX_TRACKED_JOBS = 1000;
|
|
15
15
|
const pendingJobs = new Map();
|
|
16
16
|
const trackPendingJob = (name, job) => {
|
|
@@ -37,7 +37,7 @@ const takePendingJob = (name) => {
|
|
|
37
37
|
const emitDispatch = (name, queue, connection, data) => {
|
|
38
38
|
if (!_storage)
|
|
39
39
|
return;
|
|
40
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
40
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
41
41
|
return;
|
|
42
42
|
const uuid = crypto.randomUUID();
|
|
43
43
|
const content = {
|
|
@@ -100,11 +100,11 @@ export const JobWatcher = Object.freeze({
|
|
|
100
100
|
return () => undefined;
|
|
101
101
|
_storage = storage;
|
|
102
102
|
_ignoreRoutes = config.ignoreRoutes;
|
|
103
|
-
|
|
103
|
+
_ignorePaths = config.ignorePaths;
|
|
104
104
|
return () => {
|
|
105
105
|
_storage = null;
|
|
106
106
|
_ignoreRoutes = [];
|
|
107
|
-
|
|
107
|
+
_ignorePaths = [];
|
|
108
108
|
pendingJobs.clear();
|
|
109
109
|
};
|
|
110
110
|
},
|
|
@@ -61,7 +61,7 @@ export const LogWatcher = Object.freeze({
|
|
|
61
61
|
const unsubscribe = loggerWithSink.addSink((level, message, context) => {
|
|
62
62
|
if ((LEVEL_PRIORITY[level] ?? 0) < minPriority)
|
|
63
63
|
return;
|
|
64
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(config.ignoreRoutes, config.
|
|
64
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(config.ignoreRoutes, config.ignorePaths))
|
|
65
65
|
return;
|
|
66
66
|
if (shouldSkipTraceInfrastructureLog(message, context))
|
|
67
67
|
return;
|
|
@@ -8,11 +8,11 @@ import { RequestFilter } from '../utils/requestFilter.js';
|
|
|
8
8
|
let _storage = null;
|
|
9
9
|
let _redactionFields = [];
|
|
10
10
|
let _ignoreRoutes = [];
|
|
11
|
-
let
|
|
11
|
+
let _ignorePaths = [];
|
|
12
12
|
const emit = (to, subject, template, text, html) => {
|
|
13
13
|
if (!_storage)
|
|
14
14
|
return;
|
|
15
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
15
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
16
16
|
return;
|
|
17
17
|
const content = {
|
|
18
18
|
to,
|
|
@@ -46,12 +46,12 @@ export const MailWatcher = Object.freeze({
|
|
|
46
46
|
_storage = storage;
|
|
47
47
|
_redactionFields = [...config.redaction.keys, ...config.redaction.body];
|
|
48
48
|
_ignoreRoutes = config.ignoreRoutes;
|
|
49
|
-
|
|
49
|
+
_ignorePaths = config.ignorePaths;
|
|
50
50
|
return () => {
|
|
51
51
|
_storage = null;
|
|
52
52
|
_redactionFields = [];
|
|
53
53
|
_ignoreRoutes = [];
|
|
54
|
-
|
|
54
|
+
_ignorePaths = [];
|
|
55
55
|
};
|
|
56
56
|
},
|
|
57
57
|
});
|
|
@@ -3,11 +3,11 @@ import { EntryType } from '../types.js';
|
|
|
3
3
|
import { RequestFilter } from '../utils/requestFilter.js';
|
|
4
4
|
let _storage = null;
|
|
5
5
|
let _ignoreRoutes = [];
|
|
6
|
-
let
|
|
6
|
+
let _ignorePaths = [];
|
|
7
7
|
const emit = (name, event, duration) => {
|
|
8
8
|
if (!_storage)
|
|
9
9
|
return;
|
|
10
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
10
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
11
11
|
return;
|
|
12
12
|
const content = {
|
|
13
13
|
name,
|
|
@@ -34,7 +34,7 @@ export const MiddlewareWatcher = Object.freeze({
|
|
|
34
34
|
return () => undefined;
|
|
35
35
|
_storage = storage;
|
|
36
36
|
_ignoreRoutes = config.ignoreRoutes;
|
|
37
|
-
|
|
37
|
+
_ignorePaths = config.ignorePaths;
|
|
38
38
|
globalThis.__zintrust_trace_middleware_emit__ = emit;
|
|
39
39
|
return () => {
|
|
40
40
|
const globalState = globalThis;
|
|
@@ -43,7 +43,7 @@ export const MiddlewareWatcher = Object.freeze({
|
|
|
43
43
|
}
|
|
44
44
|
_storage = null;
|
|
45
45
|
_ignoreRoutes = [];
|
|
46
|
-
|
|
46
|
+
_ignorePaths = [];
|
|
47
47
|
};
|
|
48
48
|
},
|
|
49
49
|
});
|
|
@@ -3,11 +3,11 @@ import { EntryType } from '../types.js';
|
|
|
3
3
|
import { RequestFilter } from '../utils/requestFilter.js';
|
|
4
4
|
let _storage = null;
|
|
5
5
|
let _ignoreRoutes = [];
|
|
6
|
-
let
|
|
6
|
+
let _ignorePaths = [];
|
|
7
7
|
const emit = (action, model, id, changes) => {
|
|
8
8
|
if (!_storage)
|
|
9
9
|
return;
|
|
10
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
10
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
11
11
|
return;
|
|
12
12
|
const content = {
|
|
13
13
|
action,
|
|
@@ -35,7 +35,7 @@ export const ModelWatcher = Object.freeze({
|
|
|
35
35
|
return () => undefined;
|
|
36
36
|
_storage = storage;
|
|
37
37
|
_ignoreRoutes = config.ignoreRoutes;
|
|
38
|
-
|
|
38
|
+
_ignorePaths = config.ignorePaths;
|
|
39
39
|
globalThis.__zintrust_trace_model_emit__ = emit;
|
|
40
40
|
return () => {
|
|
41
41
|
const globalState = globalThis;
|
|
@@ -44,7 +44,7 @@ export const ModelWatcher = Object.freeze({
|
|
|
44
44
|
}
|
|
45
45
|
_storage = null;
|
|
46
46
|
_ignoreRoutes = [];
|
|
47
|
-
|
|
47
|
+
_ignorePaths = [];
|
|
48
48
|
};
|
|
49
49
|
},
|
|
50
50
|
});
|
|
@@ -6,11 +6,11 @@ import { RequestFilter } from '../utils/requestFilter.js';
|
|
|
6
6
|
let _storage = null;
|
|
7
7
|
let _redactionFields = [];
|
|
8
8
|
let _ignoreRoutes = [];
|
|
9
|
-
let
|
|
9
|
+
let _ignorePaths = [];
|
|
10
10
|
const emit = (notification, channels, notifiable, message, payload) => {
|
|
11
11
|
if (!_storage)
|
|
12
12
|
return;
|
|
13
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
13
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
14
14
|
return;
|
|
15
15
|
const content = {
|
|
16
16
|
notification,
|
|
@@ -42,12 +42,12 @@ export const NotificationWatcher = Object.freeze({
|
|
|
42
42
|
_storage = storage;
|
|
43
43
|
_redactionFields = [...config.redaction.keys, ...config.redaction.body];
|
|
44
44
|
_ignoreRoutes = config.ignoreRoutes;
|
|
45
|
-
|
|
45
|
+
_ignorePaths = config.ignorePaths;
|
|
46
46
|
return () => {
|
|
47
47
|
_storage = null;
|
|
48
48
|
_redactionFields = [];
|
|
49
49
|
_ignoreRoutes = [];
|
|
50
|
-
|
|
50
|
+
_ignorePaths = [];
|
|
51
51
|
};
|
|
52
52
|
},
|
|
53
53
|
});
|
|
@@ -29,7 +29,7 @@ const isTraceStorageQuery = (sql) => {
|
|
|
29
29
|
const emit = (query, params, duration, connection = 'default') => {
|
|
30
30
|
if (_storage === null || _config === null)
|
|
31
31
|
return;
|
|
32
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_config.ignoreRoutes, _config.
|
|
32
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_config.ignoreRoutes, _config.ignorePaths))
|
|
33
33
|
return;
|
|
34
34
|
if (isTraceStorageQuery(query))
|
|
35
35
|
return;
|
|
@@ -4,12 +4,12 @@ import { AuthTag } from '../utils/authTag.js';
|
|
|
4
4
|
import { RequestFilter } from '../utils/requestFilter.js';
|
|
5
5
|
let _storage = null;
|
|
6
6
|
let _ignoreRoutes = [];
|
|
7
|
-
let
|
|
7
|
+
let _ignorePaths = [];
|
|
8
8
|
/** Emit a redis command trace. Key/value payload is intentionally omitted for security. */
|
|
9
9
|
const emit = (command, duration) => {
|
|
10
10
|
if (!_storage)
|
|
11
11
|
return;
|
|
12
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
12
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
13
13
|
return;
|
|
14
14
|
const content = { command, duration, hostname: TraceContext.getHostname() };
|
|
15
15
|
_storage
|
|
@@ -31,11 +31,11 @@ export const RedisWatcher = Object.freeze({
|
|
|
31
31
|
return () => undefined;
|
|
32
32
|
_storage = storage;
|
|
33
33
|
_ignoreRoutes = config.ignoreRoutes;
|
|
34
|
-
|
|
34
|
+
_ignorePaths = config.ignorePaths;
|
|
35
35
|
return () => {
|
|
36
36
|
_storage = null;
|
|
37
37
|
_ignoreRoutes = [];
|
|
38
|
-
|
|
38
|
+
_ignorePaths = [];
|
|
39
39
|
};
|
|
40
40
|
},
|
|
41
41
|
});
|
|
@@ -6,11 +6,11 @@ import { EntryType } from '../types.js';
|
|
|
6
6
|
import { RequestFilter } from '../utils/requestFilter.js';
|
|
7
7
|
let _storage = null;
|
|
8
8
|
let _ignoreRoutes = [];
|
|
9
|
-
let
|
|
9
|
+
let _ignorePaths = [];
|
|
10
10
|
const emit = (name, expression, status, duration, output) => {
|
|
11
11
|
if (!_storage)
|
|
12
12
|
return;
|
|
13
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
13
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
14
14
|
return;
|
|
15
15
|
const content = {
|
|
16
16
|
name,
|
|
@@ -39,11 +39,11 @@ export const ScheduleWatcher = Object.freeze({
|
|
|
39
39
|
return () => undefined;
|
|
40
40
|
_storage = storage;
|
|
41
41
|
_ignoreRoutes = config.ignoreRoutes;
|
|
42
|
-
|
|
42
|
+
_ignorePaths = config.ignorePaths;
|
|
43
43
|
return () => {
|
|
44
44
|
_storage = null;
|
|
45
45
|
_ignoreRoutes = [];
|
|
46
|
-
|
|
46
|
+
_ignorePaths = [];
|
|
47
47
|
};
|
|
48
48
|
},
|
|
49
49
|
});
|
|
@@ -3,11 +3,11 @@ import { EntryType } from '../types.js';
|
|
|
3
3
|
import { RequestFilter } from '../utils/requestFilter.js';
|
|
4
4
|
let _storage = null;
|
|
5
5
|
let _ignoreRoutes = [];
|
|
6
|
-
let
|
|
6
|
+
let _ignorePaths = [];
|
|
7
7
|
const emit = (template, duration) => {
|
|
8
8
|
if (!_storage)
|
|
9
9
|
return;
|
|
10
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes,
|
|
10
|
+
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes, _ignorePaths))
|
|
11
11
|
return;
|
|
12
12
|
const content = { template, duration, hostname: TraceContext.getHostname() };
|
|
13
13
|
_storage
|
|
@@ -29,11 +29,11 @@ export const ViewWatcher = Object.freeze({
|
|
|
29
29
|
return () => undefined;
|
|
30
30
|
_storage = storage;
|
|
31
31
|
_ignoreRoutes = config.ignoreRoutes;
|
|
32
|
-
|
|
32
|
+
_ignorePaths = config.ignorePaths;
|
|
33
33
|
return () => {
|
|
34
34
|
_storage = null;
|
|
35
35
|
_ignoreRoutes = [];
|
|
36
|
-
|
|
36
|
+
_ignorePaths = [];
|
|
37
37
|
};
|
|
38
38
|
},
|
|
39
39
|
});
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -259,7 +259,7 @@ const DEFAULTS: ITraceConfig = Object.freeze({
|
|
|
259
259
|
observeConnection: undefined,
|
|
260
260
|
pruneAfterHours: 24,
|
|
261
261
|
ignoreRoutes: ['/trace', '/health', '/ping'],
|
|
262
|
-
|
|
262
|
+
ignorePaths: [],
|
|
263
263
|
slowQueryThreshold: 100,
|
|
264
264
|
captureCachePayloads: false,
|
|
265
265
|
captureQueryBindings: true,
|
|
@@ -351,7 +351,7 @@ export const TraceConfig = Object.freeze({
|
|
|
351
351
|
query: mergeStringLists(DEFAULTS.redaction.query, overrides.redaction?.query),
|
|
352
352
|
},
|
|
353
353
|
ignoreRoutes: overrides.ignoreRoutes ?? DEFAULTS.ignoreRoutes,
|
|
354
|
-
|
|
354
|
+
ignorePaths: overrides.ignorePaths ?? DEFAULTS.ignorePaths,
|
|
355
355
|
});
|
|
356
356
|
},
|
|
357
357
|
|