@lensmcp/nest-instrumentation 1.16.31 → 1.17.0
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/lib/provider-tracker.d.ts.map +1 -1
- package/lib/provider-tracker.js +35 -2
- package/lib/state.d.ts.map +1 -1
- package/lib/state.js +1 -0
- package/lib/types.d.ts +12 -0
- package/lib/types.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-tracker.d.ts","sourceRoot":"","sources":["../../src/lib/provider-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,sBAAsB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"provider-tracker.d.ts","sourceRoot":"","sources":["../../src/lib/provider-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,sBAAsB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAwDzC;;;;;;;;;;GAUG;AACH,qBACa,sBAAuB,YAAW,sBAAsB,EAAE,eAAe;IAGxE,OAAO,CAAC,QAAQ,CAAC,SAAS;IAFtC,OAAO,CAAC,MAAM,CAA6B;gBAEd,SAAS,EAAE,SAAS;IAEjD,sBAAsB,IAAI,IAAI;IA2F9B,eAAe,IAAI,IAAI;IAavB;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;CAuC5B"}
|
package/lib/provider-tracker.js
CHANGED
|
@@ -15,6 +15,39 @@ const SKIP_METHODS = new Set([
|
|
|
15
15
|
'beforeApplicationShutdown',
|
|
16
16
|
'onApplicationShutdown',
|
|
17
17
|
]);
|
|
18
|
+
// Framework NOISE methods — pure in-memory metadata lookups that fire dozens
|
|
19
|
+
// of times per request, always at ~0ms, and never represent real work.
|
|
20
|
+
// Measured (foodguard, 2026-07-29): 373 of the first 500 events in one
|
|
21
|
+
// run-detail page-load flow were `DataSource.findMetadata/getMetadata/
|
|
22
|
+
// hasMetadata` + `Reflector.get*` spans. Skipped at WRAP time (not at emit)
|
|
23
|
+
// so the suppressed methods also skip the per-call Date.now()/ulid/event
|
|
24
|
+
// allocation. Gated by `trace.suppressNoiseMethods` (default true).
|
|
25
|
+
// Real work stays traced: `Repository.find`, `EntityManager.find`, driver
|
|
26
|
+
// query wraps, and every app-defined provider method are unaffected.
|
|
27
|
+
const NOISE_METHODS = {
|
|
28
|
+
// TypeORM DataSource — metadata table lookups + structural allocators.
|
|
29
|
+
DataSource: new Set([
|
|
30
|
+
'findMetadata', 'getMetadata', 'hasMetadata', 'getRepository',
|
|
31
|
+
'getTreeRepository', 'getMongoRepository', 'createQueryBuilder',
|
|
32
|
+
'createEntityManager', 'createQueryRunner', 'defaultReplicationModeForReads',
|
|
33
|
+
]),
|
|
34
|
+
// TypeORM EntityManager — same structural allocators (queries stay traced).
|
|
35
|
+
EntityManager: new Set([
|
|
36
|
+
'getRepository', 'getTreeRepository', 'getCustomRepository', 'createQueryBuilder',
|
|
37
|
+
]),
|
|
38
|
+
// Nest core Reflector — decorator-metadata reads on every guard/interceptor hop.
|
|
39
|
+
Reflector: new Set(['get', 'getAll', 'getAllAndOverride', 'getAllAndMerge']),
|
|
40
|
+
};
|
|
41
|
+
function isNoiseMethod(cls, name) {
|
|
42
|
+
let suppress = true;
|
|
43
|
+
try {
|
|
44
|
+
suppress = activeOptions().trace.suppressNoiseMethods;
|
|
45
|
+
}
|
|
46
|
+
catch { /* pre-bootstrap: default on */ }
|
|
47
|
+
if (!suppress)
|
|
48
|
+
return false;
|
|
49
|
+
return NOISE_METHODS[cls]?.has(name) ?? false;
|
|
50
|
+
}
|
|
18
51
|
// Provider "class" names that are really built-ins (value/factory providers).
|
|
19
52
|
const BUILTIN_CLASS = /^(_|Object|String|Number|Array|Promise|Function|RegExp|Map|Set)$/;
|
|
20
53
|
// Marks a shared prototype already auto-instrumented, so request-scoped /
|
|
@@ -245,7 +278,7 @@ function autoInstrumentProviderMethods(instance, ctor, cls) {
|
|
|
245
278
|
if (!proto || proto === Object.prototype)
|
|
246
279
|
return;
|
|
247
280
|
for (const name of Object.getOwnPropertyNames(proto)) {
|
|
248
|
-
if (SKIP_METHODS.has(name))
|
|
281
|
+
if (SKIP_METHODS.has(name) || isNoiseMethod(cls, name))
|
|
249
282
|
continue;
|
|
250
283
|
const desc = Object.getOwnPropertyDescriptor(proto, name);
|
|
251
284
|
if (!desc || typeof desc.value !== 'function' || desc.get || desc.set)
|
|
@@ -286,7 +319,7 @@ function autoInstrumentPrototypeMethods(metatype, cls) {
|
|
|
286
319
|
return;
|
|
287
320
|
const wrappedNames = [];
|
|
288
321
|
for (const name of Object.getOwnPropertyNames(proto)) {
|
|
289
|
-
if (SKIP_METHODS.has(name))
|
|
322
|
+
if (SKIP_METHODS.has(name) || isNoiseMethod(cls, name))
|
|
290
323
|
continue;
|
|
291
324
|
const desc = Object.getOwnPropertyDescriptor(proto, name);
|
|
292
325
|
if (!desc || typeof desc.value !== 'function' || desc.get || desc.set)
|
package/lib/state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/lib/state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAUxE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/lib/state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAUxE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,eAAe,CAwB5E;AAED,wBAAgB,aAAa,IAAI,eAAe,CAQ/C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
|
package/lib/state.js
CHANGED
|
@@ -21,6 +21,7 @@ export function setActiveOptions(opts) {
|
|
|
21
21
|
redis: opts.trace?.redis ?? false,
|
|
22
22
|
queues: opts.trace?.queues ?? false,
|
|
23
23
|
autoInstrumentMethods: opts.trace?.autoInstrumentMethods ?? false,
|
|
24
|
+
suppressNoiseMethods: opts.trace?.suppressNoiseMethods ?? true,
|
|
24
25
|
},
|
|
25
26
|
memory: {
|
|
26
27
|
mode: opts.memory?.mode ?? 'off',
|
package/lib/types.d.ts
CHANGED
|
@@ -30,6 +30,18 @@ export interface LensmcpModuleOptions {
|
|
|
30
30
|
* `@TraceMethod` (or marked `@LensmcpIgnore`) are skipped.
|
|
31
31
|
*/
|
|
32
32
|
autoInstrumentMethods?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Skip wrapping known framework NOISE methods — pure in-memory metadata
|
|
35
|
+
* lookups (TypeORM `DataSource.findMetadata`/`getMetadata`, Nest
|
|
36
|
+
* `Reflector.get`, …) that fire dozens of times per request, always at
|
|
37
|
+
* ~0ms, and never represent real work. Measured on a real workspace:
|
|
38
|
+
* 373 of the first 500 events in one page-load flow were these lookups
|
|
39
|
+
* — they drown the flow's actual signal and inflate the event log >3×.
|
|
40
|
+
* Skipping happens at WRAP time, so the suppressed methods also skip
|
|
41
|
+
* the per-call `Date.now()`/ulid/event allocation entirely.
|
|
42
|
+
* Default: true. Set false to trace absolutely everything.
|
|
43
|
+
*/
|
|
44
|
+
suppressNoiseMethods?: boolean;
|
|
33
45
|
};
|
|
34
46
|
/** Memory tracking (Phase 7). */
|
|
35
47
|
memory?: {
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;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AK,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB;;;;;WAKG;QACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;QAChC;;;;;;;;;;WAUG;QACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;KAChC,CAAC;IACF,iCAAiC;IACjC,MAAM,CAAC,EAAE;QACP,yFAAyF;QACzF,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;QAChC,wFAAwF;QACxF,KAAK,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;KAC1B,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,EAAE;QACN,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;QAC/B,KAAK,EAAE,QAAQ,GAAG,KAAK,CAAC;KACzB,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensmcp/nest-instrumentation",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lensmcp/core": "1.
|
|
18
|
-
"@lensmcp/memory-tracker": "1.
|
|
19
|
-
"@lensmcp/protocol-types": "1.
|
|
17
|
+
"@lensmcp/core": "1.17.0",
|
|
18
|
+
"@lensmcp/memory-tracker": "1.17.0",
|
|
19
|
+
"@lensmcp/protocol-types": "1.17.0",
|
|
20
20
|
"tslib": "^2.3.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|