Skip to content

Commit b56edaa

Browse files
committed
address feedback
1 parent 357caef commit b56edaa

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

lib/subscribers/dc-base.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ const resolvePackageVersion = require('./resolve-package-version.js')
1818
* @property {object} logger An agent logger instance.
1919
* @property {string} packageName The package name being instrumented.
2020
* This is what a developer would provide to the `require` function.
21+
* @property {boolean} [skipUsageMetricRecording=false] When set to `true`, the
22+
* instrumentation will not attempt to record the usage metric. This is useful
23+
* when the module being instrumented is also being instrumented via the
24+
* Orchestrion based subscriber system. It is much cheaper to record the metric
25+
* via Orchestrion based subscribers than through this direct diagnostics
26+
* channel method (Orchestrion provides the module version, whereas we have
27+
* to perform expensive operations here to get the same information).
2128
*/
2229

2330
/**
@@ -42,11 +49,15 @@ class Subscriber {
4249
/**
4350
* @param {SubscriberParams} params to function
4451
*/
45-
constructor({ agent, logger, packageName }) {
52+
constructor({ agent, logger, packageName, skipUsageMetricRecording = false }) {
4653
this.agent = agent
4754
this.logger = logger.child({ component: `${packageName}-subscriber` })
4855
this.config = agent.config
4956
this.id = packageName
57+
58+
if (skipUsageMetricRecording === true) {
59+
this.#usageMetricRecorded = true
60+
}
5061
}
5162

5263
set channels(channels) {

lib/subscribers/fastify/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const MiddlewareWrapper = require('../middleware-wrapper')
1010

1111
class FastifyInitialization extends DcBase {
1212
constructor({ agent, logger }) {
13-
super({ agent, logger, packageName: 'fastify' })
13+
super({ agent, logger, packageName: 'fastify', skipUsageMetricRecording: true })
1414
this.channels = [
1515
{ channel: initChannel, hook: this.handler }
1616
]
@@ -24,7 +24,10 @@ class FastifyInitialization extends DcBase {
2424
return
2525
}
2626

27-
routeOptions.handler = self.wrapper.wrap({ handler: routeOptions.handler, route: routeOptions.path })
27+
routeOptions.handler = self.wrapper.wrap({
28+
handler: routeOptions.handler,
29+
route: routeOptions.path
30+
})
2831
})
2932
}
3033
}

lib/tracking-packages.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,7 @@ const trackingPkgs = [
1919
'fancy-log',
2020
'knex',
2121
'loglevel',
22-
'npmlog',
23-
// These packages are required for the tracking metrics
24-
// for @langchain/core to be created. Ideally, these
25-
// should not be here.
26-
// TODO: will be addressed in https://github.com/newrelic/node-newrelic/issues/3575
27-
'@langchain/core/prompts',
28-
'@langchain/core/tools',
29-
'@langchain/core/runnables',
30-
'@langchain/core/vectorstores',
22+
'npmlog'
3123
]
3224

3325
module.exports = trackingPkgs

0 commit comments

Comments
 (0)