File tree 2 files changed +8
-4
lines changed
collector/test/tracing/database/ioredis
core/src/tracing/instrumentation/database
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ const mochaSuiteFn =
26
26
27
27
function checkConnection ( span , setupType ) {
28
28
if ( setupType === 'cluster' ) {
29
- // Internal IP of azure cluster.
30
29
expect ( span . data . redis . connection ) . to . equal ( process . env . AZURE_REDIS_CLUSTER ) ;
31
30
} else {
32
31
expect ( span . data . redis . connection ) . to . equal ( process . env . REDIS ) ;
Original file line number Diff line number Diff line change @@ -36,7 +36,11 @@ function instrument(ioredis) {
36
36
constructor ( ) {
37
37
super ( ...arguments ) ;
38
38
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
+ }
40
44
}
41
45
}
42
46
@@ -47,8 +51,9 @@ function instrument(ioredis) {
47
51
enumerable : true
48
52
} ) ;
49
53
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.
52
57
shimmer . wrap ( ioredis . prototype , 'sendCommand' , instrumentSendCommand ) ;
53
58
shimmer . wrap ( ioredis . prototype , 'multi' , instrumentMultiCommand ) ;
54
59
shimmer . wrap ( ioredis . prototype , 'pipeline' , instrumentPipelineCommand ) ;
You can’t perform that action at this time.
0 commit comments