@zintrust/trace 1.6.3 → 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.
|
@@ -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();
|