Skip to content

Commit c592030

Browse files
committed
chore: cleanup
1 parent 8f18420 commit c592030

File tree

2 files changed

+8
-4
lines changed
  • packages
    • collector/test/tracing/database/ioredis
    • core/src/tracing/instrumentation/database

2 files changed

+8
-4
lines changed

Diff for: packages/collector/test/tracing/database/ioredis/test.js

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const mochaSuiteFn =
2626

2727
function checkConnection(span, setupType) {
2828
if (setupType === 'cluster') {
29-
// Internal IP of azure cluster.
3029
expect(span.data.redis.connection).to.equal(process.env.AZURE_REDIS_CLUSTER);
3130
} else {
3231
expect(span.data.redis.connection).to.equal(process.env.REDIS);

Diff for: packages/core/src/tracing/instrumentation/database/ioredis.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ function instrument(ioredis) {
3636
constructor() {
3737
super(...arguments);
3838

39-
clusterConnectionString = this.startupNodes.map(node => `${node.host}:${node.port}`).join(',');
39+
try {
40+
clusterConnectionString = this.startupNodes.map(node => `${node.host}:${node.port}`).join(',');
41+
} catch (e) {
42+
// ignore
43+
}
4044
}
4145
}
4246

@@ -47,8 +51,9 @@ function instrument(ioredis) {
4751
enumerable: true
4852
});
4953

50-
// The "sendCommand" is called on the cluster instance as well, but `client.isCluster` is false.
51-
// We need to workaround and getting the cluster connection via the class constructor.
54+
// We cannot register `ioredis.Cluster.prototype.sendCommand` otherwise we produce two spans for the same command.
55+
// Because `ioredis.prototype.sendCommand` is triggerd when using a cluster, but `client.isCluster` is false.
56+
// Thats why we override the Cluster Class and extract the connection string.
5257
shimmer.wrap(ioredis.prototype, 'sendCommand', instrumentSendCommand);
5358
shimmer.wrap(ioredis.prototype, 'multi', instrumentMultiCommand);
5459
shimmer.wrap(ioredis.prototype, 'pipeline', instrumentPipelineCommand);

0 commit comments

Comments
 (0)