From 107237d9afd5dd5d9d25c0de55740810bf873a42 Mon Sep 17 00:00:00 2001 From: Bob Evans Date: Wed, 24 Apr 2024 15:48:16 -0400 Subject: [PATCH] chore: Updated instrumentation to use type constants instead of raw strings --- lib/instrumentation/amqplib/nr-hooks.js | 5 +++-- lib/instrumentation/grpc-js/nr-hooks.js | 7 ++++--- lib/instrumentation/langchain/nr-hooks.js | 9 +++++---- lib/instrumentation/mysql/nr-hooks.js | 7 ++++--- lib/instrumentation/pino/nr-hooks.js | 3 ++- lib/instrumentation/when/nr-hooks.js | 3 ++- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/instrumentation/amqplib/nr-hooks.js b/lib/instrumentation/amqplib/nr-hooks.js index cb5ea822e4..bd1285e26c 100644 --- a/lib/instrumentation/amqplib/nr-hooks.js +++ b/lib/instrumentation/amqplib/nr-hooks.js @@ -5,16 +5,17 @@ 'use strict' const amqplib = require('./amqplib') +const InstrumentationDescriptor = require('../../instrumentation-descriptor') module.exports = [ { moduleName: 'amqplib/callback_api', - type: 'message', + type: InstrumentationDescriptor.TYPE_MESSAGE, onRequire: amqplib.instrumentCallbackAPI }, { moduleName: 'amqplib/channel_api', - type: 'message', + type: InstrumentationDescriptor.TYPE_MESSAGE, onRequire: amqplib.instrumentPromiseAPI } ] diff --git a/lib/instrumentation/grpc-js/nr-hooks.js b/lib/instrumentation/grpc-js/nr-hooks.js index 7977dfd091..afb2eb7f24 100644 --- a/lib/instrumentation/grpc-js/nr-hooks.js +++ b/lib/instrumentation/grpc-js/nr-hooks.js @@ -5,25 +5,26 @@ 'use strict' const grpc = require('./grpc') +const InstrumentationDescriptor = require('../../instrumentation-descriptor') /** * Need to use nr-hooks style for grpc because we're instrumentation a submodule. */ module.exports = [ { - type: 'generic', + type: InstrumentationDescriptor.TYPE_GENERIC, moduleName: '@grpc/grpc-js/build/src/resolving-call', isEsm: true, onRequire: grpc.wrapStartResolve }, { - type: 'generic', + type: InstrumentationDescriptor.TYPE_GENERIC, moduleName: '@grpc/grpc-js/build/src/call-stream', isEsm: true, onRequire: grpc.wrapStartCall }, { - type: 'web-framework', + type: InstrumentationDescriptor.TYPE_WEB_FRAMEWORK, moduleName: '@grpc/grpc-js/build/src/server', isEsm: true, onRequire: grpc.wrapServer diff --git a/lib/instrumentation/langchain/nr-hooks.js b/lib/instrumentation/langchain/nr-hooks.js index 961257c917..23cde12459 100644 --- a/lib/instrumentation/langchain/nr-hooks.js +++ b/lib/instrumentation/langchain/nr-hooks.js @@ -8,25 +8,26 @@ const toolsInstrumentation = require('./tools') const cbManagerInstrumentation = require('./callback-manager') const runnableInstrumentation = require('./runnable') const vectorstoreInstrumentation = require('./vectorstore') +const InstrumentationDescriptor = require('../../instrumentation-descriptor') module.exports = [ { - type: 'generic', + type: InstrumentationDescriptor.TYPE_GENERIC, moduleName: '@langchain/core/tools', onRequire: toolsInstrumentation }, { - type: 'generic', + type: InstrumentationDescriptor.TYPE_GENERIC, moduleName: '@langchain/core/dist/callbacks/manager', onRequire: cbManagerInstrumentation }, { - type: 'generic', + type: InstrumentationDescriptor.TYPE_GENERIC, moduleName: '@langchain/core/dist/runnables/base', onRequire: runnableInstrumentation }, { - type: 'generic', + type: InstrumentationDescriptor.TYPE_GENERIC, moduleName: '@langchain/core/vectorstores', onRequire: vectorstoreInstrumentation } diff --git a/lib/instrumentation/mysql/nr-hooks.js b/lib/instrumentation/mysql/nr-hooks.js index 95b2039af1..97fa78b1b2 100644 --- a/lib/instrumentation/mysql/nr-hooks.js +++ b/lib/instrumentation/mysql/nr-hooks.js @@ -5,20 +5,21 @@ 'use strict' const instrumentation = require('./mysql') +const InstrumentationDescriptor = require('../../instrumentation-descriptor') module.exports = [ { - type: 'datastore', + type: InstrumentationDescriptor.TYPE_DATASTORE, moduleName: 'mysql', onRequire: instrumentation.callbackInitialize }, { - type: 'datastore', + type: InstrumentationDescriptor.TYPE_DATASTORE, moduleName: 'mysql2', onRequire: instrumentation.callbackInitialize }, { - type: 'datastore', + type: InstrumentationDescriptor.TYPE_DATASTORE, moduleName: 'mysql2/promise', onRequire: instrumentation.promiseInitialize } diff --git a/lib/instrumentation/pino/nr-hooks.js b/lib/instrumentation/pino/nr-hooks.js index 043cfbf44d..72f941b8d0 100644 --- a/lib/instrumentation/pino/nr-hooks.js +++ b/lib/instrumentation/pino/nr-hooks.js @@ -5,13 +5,14 @@ 'use strict' const pino = require('./pino') +const InstrumentationDescriptor = require('../../instrumentation-descriptor') /** * Need to use nr-hooks style because we are instrumenting a submodule. */ module.exports = [ { - type: 'generic', + type: InstrumentationDescriptor.TYPE_GENERIC, moduleName: 'pino/lib/tools', onRequire: pino } diff --git a/lib/instrumentation/when/nr-hooks.js b/lib/instrumentation/when/nr-hooks.js index da00bf2f9f..dee08eef3e 100644 --- a/lib/instrumentation/when/nr-hooks.js +++ b/lib/instrumentation/when/nr-hooks.js @@ -5,10 +5,11 @@ 'use strict' const instrumentation = require('./index') +const InstrumentationDescriptor = require('../../instrumentation-descriptor') module.exports = [ { - type: null, + type: InstrumentationDescriptor.TYPE_GENERIC, moduleName: 'when', onRequire: instrumentation }