@zintrust/trace 0.4.81 → 0.4.82
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 +43 -43
- package/dist/config.js +2 -0
- package/dist/dashboard/ui.js +103 -8
- package/dist/register.js +16 -0
- package/dist/types.d.ts +29 -1
- package/dist/watchers/CacheWatcher.d.ts +1 -1
- package/dist/watchers/CacheWatcher.js +10 -2
- package/dist/watchers/HttpClientWatcher.d.ts +2 -2
- package/dist/watchers/HttpClientWatcher.js +17 -4
- package/dist/watchers/MailWatcher.d.ts +1 -1
- package/dist/watchers/MailWatcher.js +12 -3
- package/dist/watchers/NotificationWatcher.d.ts +1 -1
- package/dist/watchers/NotificationWatcher.js +9 -1
- package/dist/watchers/QueryWatcher.js +5 -1
- package/package.json +3 -3
- package/src/config.ts +2 -0
- package/src/dashboard/ui.ts +103 -8
- package/src/register.ts +16 -0
- package/src/types.ts +30 -1
- package/src/watchers/CacheWatcher.ts +13 -2
- package/src/watchers/HttpClientWatcher.ts +33 -11
- package/src/watchers/MailWatcher.ts +18 -3
- package/src/watchers/NotificationWatcher.ts +15 -1
- package/src/watchers/QueryWatcher.ts +5 -1
|
@@ -2,18 +2,30 @@ import { TraceContext } from '../context';
|
|
|
2
2
|
import type { ITraceWatcher, ITraceWatcherConfig, NotificationContent } from '../types';
|
|
3
3
|
import { EntryType } from '../types';
|
|
4
4
|
import { AuthTag } from '../utils/authTag';
|
|
5
|
+
import { redactUnknown } from '../utils/redact';
|
|
5
6
|
import { RequestFilter } from '../utils/requestFilter';
|
|
6
7
|
|
|
7
8
|
let _storage: ITraceWatcherConfig['storage'] | null = null;
|
|
9
|
+
let _redactionFields: string[] = [];
|
|
8
10
|
let _ignoreRoutes: string[] = [];
|
|
9
11
|
|
|
10
|
-
const emit = (
|
|
12
|
+
const emit = (
|
|
13
|
+
notification: string,
|
|
14
|
+
channels: string[],
|
|
15
|
+
notifiable?: string,
|
|
16
|
+
message?: string,
|
|
17
|
+
payload?: unknown
|
|
18
|
+
): void => {
|
|
11
19
|
if (!_storage) return;
|
|
12
20
|
if (RequestFilter.shouldIgnoreCurrentRequest(_ignoreRoutes)) return;
|
|
13
21
|
const content: NotificationContent = {
|
|
14
22
|
notification,
|
|
15
23
|
channels,
|
|
16
24
|
notifiable,
|
|
25
|
+
...(typeof message === 'string' && message !== ''
|
|
26
|
+
? { message: redactUnknown(message, _redactionFields) as string }
|
|
27
|
+
: {}),
|
|
28
|
+
...(payload === undefined ? {} : { payload: redactUnknown(payload, _redactionFields) }),
|
|
17
29
|
hostname: TraceContext.getHostname(),
|
|
18
30
|
};
|
|
19
31
|
_storage
|
|
@@ -34,9 +46,11 @@ export const NotificationWatcher: ITraceWatcher & { emit: typeof emit } = Object
|
|
|
34
46
|
register({ storage, config }: ITraceWatcherConfig): () => void {
|
|
35
47
|
if (config.watchers.notification === false) return () => undefined;
|
|
36
48
|
_storage = storage;
|
|
49
|
+
_redactionFields = [...config.redaction.keys, ...config.redaction.body];
|
|
37
50
|
_ignoreRoutes = config.ignoreRoutes;
|
|
38
51
|
return () => {
|
|
39
52
|
_storage = null;
|
|
53
|
+
_redactionFields = [];
|
|
40
54
|
_ignoreRoutes = [];
|
|
41
55
|
};
|
|
42
56
|
},
|
|
@@ -36,7 +36,8 @@ export const QueryWatcher: ITraceWatcher = Object.freeze({
|
|
|
36
36
|
if (isTraceStorageQuery(query)) return;
|
|
37
37
|
|
|
38
38
|
const batchId = TraceContext.getBatchId();
|
|
39
|
-
const
|
|
39
|
+
const includeBindings = config.captureQueryBindings !== false;
|
|
40
|
+
const sql = includeBindings ? bindingsInterpolated(query, params) : query;
|
|
40
41
|
const roundedDuration = Math.round(duration * 100) / 100;
|
|
41
42
|
const hash = TraceStorage.familyHash(query);
|
|
42
43
|
const slow = roundedDuration >= config.slowQueryThreshold;
|
|
@@ -44,6 +45,9 @@ export const QueryWatcher: ITraceWatcher = Object.freeze({
|
|
|
44
45
|
const content: QueryContent = {
|
|
45
46
|
connection: 'default',
|
|
46
47
|
sql,
|
|
48
|
+
statement: query,
|
|
49
|
+
...(includeBindings ? { bindings: [...params] } : {}),
|
|
50
|
+
bindingsIncluded: includeBindings,
|
|
47
51
|
time: roundedDuration,
|
|
48
52
|
duration: roundedDuration,
|
|
49
53
|
slow,
|