Skip to content

Commit bb74f84

Browse files
committed
Instrument MULTI instead
1 parent f0da50f commit bb74f84

File tree

4 files changed

+37
-61
lines changed

4 files changed

+37
-61
lines changed

lib/subscribers/redis/config.js

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,46 +33,31 @@ const sendCommand = {
3333
]
3434
}
3535

36-
const executeMulti = {
37-
path: './redis/execute-multi',
38-
instrumentations: [
39-
{
40-
channelName: 'nr_executeMulti',
41-
module: { name: '@redis/client', versionRange: '>=4', filePath: 'dist/lib/client/index.js' },
42-
functionQuery: {
43-
className: 'RedisClient',
44-
methodName: '_executeMulti',
45-
kind: 'Async'
46-
}
47-
},
48-
]
49-
}
50-
51-
const executePipeline = {
52-
path: './redis/execute-multi',
36+
const clientSelect = {
37+
path: './redis/select',
5338
instrumentations: [
5439
{
55-
channelName: 'nr_executePipeline',
40+
channelName: 'nr_select',
5641
module: { name: '@redis/client', versionRange: '>=4', filePath: 'dist/lib/client/index.js' },
5742
functionQuery: {
5843
className: 'RedisClient',
59-
methodName: '_executePipeline',
44+
methodName: 'SELECT',
6045
kind: 'Async'
6146
}
62-
},
47+
}
6348
]
6449
}
6550

66-
const clientSelect = {
67-
path: './redis/select',
51+
const clientMulti = {
52+
path: './redis/multi',
6853
instrumentations: [
6954
{
70-
channelName: 'nr_select',
55+
channelName: 'nr_multi',
7156
module: { name: '@redis/client', versionRange: '>=4', filePath: 'dist/lib/client/index.js' },
7257
functionQuery: {
7358
className: 'RedisClient',
74-
methodName: 'SELECT',
75-
kind: 'Async'
59+
methodName: 'MULTI',
60+
kind: 'Sync'
7661
}
7762
}
7863
]
@@ -83,7 +68,6 @@ module.exports = {
8368
addCommand,
8469
sendCommand,
8570
clientSelect,
86-
executeMulti,
87-
executePipeline
71+
clientMulti
8872
]
8973
}

lib/subscribers/redis/execute-multi.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

lib/subscribers/redis/execute-pipeline.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

lib/subscribers/redis/multi.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2026 New Relic Corporation. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
'use strict'
7+
const ClientPropagationSubscriber = require('./client-propagation')
8+
const { redisClientOpts } = require('../../symbols')
9+
10+
/**
11+
* Propagates the context in `RedisClient.MULTI` and
12+
* `RedisClient[redisClientOpts]` into `RedisCommandQueue.addCommand`.
13+
*/
14+
module.exports = class ClientMultiSubscriber extends ClientPropagationSubscriber {
15+
constructor({ agent, logger }) {
16+
super({ agent, logger, channelName: 'nr_multi' })
17+
this.events = ['start']
18+
}
19+
20+
start(data) {
21+
const { self: client } = data
22+
if (!client[redisClientOpts]) {
23+
client[redisClientOpts] = this.getRedisParams(client.options)
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)