Skip to content

Commit

Permalink
chore: Updated instrumentation to use type constants instead of raw s…
Browse files Browse the repository at this point in the history
…trings (#2165)
  • Loading branch information
bizob2828 authored Apr 24, 2024
1 parent 301bbff commit c5b42cd
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
5 changes: 3 additions & 2 deletions lib/instrumentation/amqplib/nr-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
7 changes: 4 additions & 3 deletions lib/instrumentation/grpc-js/nr-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions lib/instrumentation/langchain/nr-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 4 additions & 3 deletions lib/instrumentation/mysql/nr-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion lib/instrumentation/pino/nr-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion lib/instrumentation/when/nr-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit c5b42cd

Please sign in to comment.