@zintrust/trace 1.6.2 → 1.6.4
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/register.js
CHANGED
|
@@ -291,11 +291,6 @@ const createTraceWatcherArgs = async (core, Env, config) => {
|
|
|
291
291
|
globalTraceRegisterState.__zintrust_system_trace_connection_name__ = resolvedConnectionName;
|
|
292
292
|
globalTraceRegisterState.__zintrust_system_trace_observe_connection_name__ =
|
|
293
293
|
resolvedObservedConnectionName;
|
|
294
|
-
const observedDb = core.useDatabase?.(undefined, resolvedObservedConnectionName);
|
|
295
|
-
assertTraceConnectionResolved(core, observedDb, {
|
|
296
|
-
connectionName: resolvedObservedConnectionName,
|
|
297
|
-
envKey: 'TRACE_QUERY_CONNECTION',
|
|
298
|
-
});
|
|
299
294
|
let resolvedStorage;
|
|
300
295
|
if (config.proxy.enabled) {
|
|
301
296
|
resolvedStorage = ProxyTraceStorage.create({
|
|
@@ -315,6 +310,11 @@ const createTraceWatcherArgs = async (core, Env, config) => {
|
|
|
315
310
|
await assertTraceStorageReady(core, storageDb, resolvedConnectionName);
|
|
316
311
|
resolvedStorage = TraceStorage.resolveStorage(storageDb);
|
|
317
312
|
}
|
|
313
|
+
const observedDb = core.useDatabase?.(undefined, resolvedObservedConnectionName);
|
|
314
|
+
assertTraceConnectionResolved(core, observedDb, {
|
|
315
|
+
connectionName: resolvedObservedConnectionName,
|
|
316
|
+
envKey: 'TRACE_QUERY_CONNECTION',
|
|
317
|
+
});
|
|
318
318
|
const storage = TraceWriteDiagnostics.wrapStorage(TraceContentBudget.wrapStorage(TraceContentRedaction.wrapStorage(TraceEntryFiltering.wrapStorage(TraceServiceTag.wrapStorage(resolvedStorage, config), config), config.redaction), config), {
|
|
319
319
|
connectionName: resolvedConnectionName,
|
|
320
320
|
logger: core.Logger,
|
|
@@ -2,7 +2,6 @@ import { TraceContext } from '../context.js';
|
|
|
2
2
|
import { EntryType } from '../types.js';
|
|
3
3
|
import { TraceEntryFilter } from '../utils/entryFilter.js';
|
|
4
4
|
import { RequestFilter } from '../utils/requestFilter.js';
|
|
5
|
-
const MAX_IGNORED_BATCHES = 512;
|
|
6
5
|
const isObjectValue = (value) => {
|
|
7
6
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
7
|
};
|
|
@@ -13,51 +12,27 @@ const getEntryUri = (entry) => {
|
|
|
13
12
|
const uri = content?.['uri'];
|
|
14
13
|
return typeof uri === 'string' && uri.trim() !== '' ? uri : undefined;
|
|
15
14
|
};
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const remember = (batchId) => {
|
|
20
|
-
if (ignoredBatchIds.has(batchId))
|
|
21
|
-
return;
|
|
22
|
-
ignoredBatchIds.add(batchId);
|
|
23
|
-
ignoredBatchOrder.push(batchId);
|
|
24
|
-
if (ignoredBatchOrder.length <= MAX_IGNORED_BATCHES)
|
|
25
|
-
return;
|
|
26
|
-
const evictedBatchId = ignoredBatchOrder.shift();
|
|
27
|
-
if (evictedBatchId !== undefined) {
|
|
28
|
-
ignoredBatchIds.delete(evictedBatchId);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const has = (batchId) => {
|
|
32
|
-
return ignoredBatchIds.has(batchId);
|
|
33
|
-
};
|
|
34
|
-
return Object.freeze({ has, remember });
|
|
35
|
-
};
|
|
36
|
-
const shouldDropForIgnoredRequest = (entry, config, tracker) => {
|
|
37
|
-
if (tracker.has(entry.batchId)) {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
15
|
+
const shouldDropForIgnoredRequest = (entry, config) => {
|
|
16
|
+
if (entry.type !== EntryType.REQUEST)
|
|
17
|
+
return false;
|
|
40
18
|
const currentPath = TraceContext.getRequestPath();
|
|
41
19
|
if (typeof currentPath === 'string' &&
|
|
42
20
|
currentPath !== '' &&
|
|
43
21
|
RequestFilter.matchesIgnoredPath(currentPath, config)) {
|
|
44
|
-
tracker.remember(entry.batchId);
|
|
45
22
|
return true;
|
|
46
23
|
}
|
|
47
24
|
const uri = getEntryUri(entry);
|
|
48
25
|
if (typeof uri === 'string' && RequestFilter.matchesIgnoredPath(uri, config)) {
|
|
49
|
-
tracker.remember(entry.batchId);
|
|
50
26
|
return true;
|
|
51
27
|
}
|
|
52
28
|
return false;
|
|
53
29
|
};
|
|
54
30
|
export const TraceEntryFiltering = Object.freeze({
|
|
55
31
|
wrapStorage(storage, config) {
|
|
56
|
-
const ignoredBatchTracker = createIgnoredBatchTracker();
|
|
57
32
|
return Object.freeze({
|
|
58
33
|
...storage,
|
|
59
34
|
async writeEntry(entry) {
|
|
60
|
-
if (shouldDropForIgnoredRequest(entry, config
|
|
35
|
+
if (shouldDropForIgnoredRequest(entry, config))
|
|
61
36
|
return;
|
|
62
37
|
if (!TraceEntryFilter.shouldCapture(entry, config))
|
|
63
38
|
return;
|
|
@@ -5,7 +5,6 @@ import { TraceContext } from '../context.js';
|
|
|
5
5
|
import { TraceStorage } from '../storage/index.js';
|
|
6
6
|
import { EntryType } from '../types.js';
|
|
7
7
|
import { AuthTag } from '../utils/authTag.js';
|
|
8
|
-
import { RequestFilter } from '../utils/requestFilter.js';
|
|
9
8
|
let _storage = null;
|
|
10
9
|
let _config = null;
|
|
11
10
|
const bindingsInterpolated = (sql, params) => {
|
|
@@ -29,8 +28,6 @@ const isTraceStorageQuery = (sql) => {
|
|
|
29
28
|
const emit = (query, params, duration, connection = 'default') => {
|
|
30
29
|
if (_storage === null || _config === null)
|
|
31
30
|
return;
|
|
32
|
-
if (RequestFilter.shouldIgnoreCurrentRequest(_config.ignoreRoutes, _config.ignorePaths))
|
|
33
|
-
return;
|
|
34
31
|
if (isTraceStorageQuery(query))
|
|
35
32
|
return;
|
|
36
33
|
const batchId = TraceContext.getBatchId();
|