Skip to content

Commit f6e6414

Browse files
authored
Merge branch 'main' into trentm/issue1692-ioredis-esm
2 parents cc31725 + 659d7ba commit f6e6414

File tree

7 files changed

+110
-48
lines changed

7 files changed

+110
-48
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.28.2","detectors/node/opentelemetry-resource-detector-aws":"1.3.2","detectors/node/opentelemetry-resource-detector-container":"0.3.2","detectors/node/opentelemetry-resource-detector-gcp":"0.29.2","detectors/node/opentelemetry-resource-detector-github":"0.28.1","detectors/node/opentelemetry-resource-detector-instana":"0.5.2","metapackages/auto-instrumentations-node":"0.39.3","metapackages/auto-instrumentations-web":"0.33.2","packages/opentelemetry-host-metrics":"0.33.1","packages/opentelemetry-id-generator-aws-xray":"1.2.1","packages/opentelemetry-propagation-utils":"0.30.2","packages/opentelemetry-redis-common":"0.36.1","packages/opentelemetry-sql-common":"0.40.0","packages/opentelemetry-test-utils":"0.34.2","plugins/node/instrumentation-amqplib":"0.33.2","plugins/node/instrumentation-cucumber":"0.1.1","plugins/node/instrumentation-dataloader":"0.5.2","plugins/node/instrumentation-fs":"0.8.2","plugins/node/instrumentation-lru-memoizer":"0.33.2","plugins/node/instrumentation-mongoose":"0.33.2","plugins/node/instrumentation-socket.io":"0.34.2","plugins/node/instrumentation-tedious":"0.6.2","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.37.1","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.36.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.32.2","plugins/node/opentelemetry-instrumentation-cassandra":"0.33.2","plugins/node/opentelemetry-instrumentation-connect":"0.32.2","plugins/node/opentelemetry-instrumentation-dns":"0.32.3","plugins/node/opentelemetry-instrumentation-express":"0.33.2","plugins/node/opentelemetry-instrumentation-fastify":"0.32.3","plugins/node/opentelemetry-instrumentation-generic-pool":"0.32.3","plugins/node/opentelemetry-instrumentation-graphql":"0.35.2","plugins/node/opentelemetry-instrumentation-hapi":"0.33.1","plugins/node/opentelemetry-instrumentation-ioredis":"0.35.2","plugins/node/opentelemetry-instrumentation-knex":"0.32.2","plugins/node/opentelemetry-instrumentation-koa":"0.36.1","plugins/node/opentelemetry-instrumentation-memcached":"0.32.2","plugins/node/opentelemetry-instrumentation-mongodb":"0.37.1","plugins/node/opentelemetry-instrumentation-mysql":"0.34.2","plugins/node/opentelemetry-instrumentation-mysql2":"0.34.2","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.33.2","plugins/node/opentelemetry-instrumentation-net":"0.32.2","plugins/node/opentelemetry-instrumentation-pg":"0.36.2","plugins/node/opentelemetry-instrumentation-pino":"0.34.2","plugins/node/opentelemetry-instrumentation-redis":"0.35.2","plugins/node/opentelemetry-instrumentation-redis-4":"0.35.2","plugins/node/opentelemetry-instrumentation-restify":"0.34.1","plugins/node/opentelemetry-instrumentation-router":"0.33.2","plugins/node/opentelemetry-instrumentation-winston":"0.32.2","plugins/web/opentelemetry-instrumentation-document-load":"0.33.2","plugins/web/opentelemetry-instrumentation-long-task":"0.33.2","plugins/web/opentelemetry-instrumentation-user-interaction":"0.33.2","plugins/web/opentelemetry-plugin-react-load":"0.29.1","propagators/opentelemetry-propagator-aws-xray":"1.3.1","propagators/opentelemetry-propagator-grpc-census-binary":"0.27.1","propagators/opentelemetry-propagator-instana":"0.3.1","propagators/opentelemetry-propagator-ot-trace":"0.27.1"}
1+
{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.28.2","detectors/node/opentelemetry-resource-detector-aws":"1.3.2","detectors/node/opentelemetry-resource-detector-container":"0.3.2","detectors/node/opentelemetry-resource-detector-gcp":"0.29.2","detectors/node/opentelemetry-resource-detector-github":"0.28.1","detectors/node/opentelemetry-resource-detector-instana":"0.5.2","metapackages/auto-instrumentations-node":"0.39.4","metapackages/auto-instrumentations-web":"0.33.2","packages/opentelemetry-host-metrics":"0.33.1","packages/opentelemetry-id-generator-aws-xray":"1.2.1","packages/opentelemetry-propagation-utils":"0.30.2","packages/opentelemetry-redis-common":"0.36.1","packages/opentelemetry-sql-common":"0.40.0","packages/opentelemetry-test-utils":"0.34.2","plugins/node/instrumentation-amqplib":"0.33.2","plugins/node/instrumentation-cucumber":"0.1.1","plugins/node/instrumentation-dataloader":"0.5.2","plugins/node/instrumentation-fs":"0.8.2","plugins/node/instrumentation-lru-memoizer":"0.33.2","plugins/node/instrumentation-mongoose":"0.33.2","plugins/node/instrumentation-socket.io":"0.34.2","plugins/node/instrumentation-tedious":"0.6.2","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.37.1","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.36.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.32.2","plugins/node/opentelemetry-instrumentation-cassandra":"0.33.2","plugins/node/opentelemetry-instrumentation-connect":"0.32.2","plugins/node/opentelemetry-instrumentation-dns":"0.32.3","plugins/node/opentelemetry-instrumentation-express":"0.33.2","plugins/node/opentelemetry-instrumentation-fastify":"0.32.3","plugins/node/opentelemetry-instrumentation-generic-pool":"0.32.3","plugins/node/opentelemetry-instrumentation-graphql":"0.35.2","plugins/node/opentelemetry-instrumentation-hapi":"0.33.1","plugins/node/opentelemetry-instrumentation-ioredis":"0.35.2","plugins/node/opentelemetry-instrumentation-knex":"0.32.2","plugins/node/opentelemetry-instrumentation-koa":"0.36.1","plugins/node/opentelemetry-instrumentation-memcached":"0.32.2","plugins/node/opentelemetry-instrumentation-mongodb":"0.37.1","plugins/node/opentelemetry-instrumentation-mysql":"0.34.2","plugins/node/opentelemetry-instrumentation-mysql2":"0.34.2","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.33.2","plugins/node/opentelemetry-instrumentation-net":"0.32.2","plugins/node/opentelemetry-instrumentation-pg":"0.36.2","plugins/node/opentelemetry-instrumentation-pino":"0.34.2","plugins/node/opentelemetry-instrumentation-redis":"0.35.2","plugins/node/opentelemetry-instrumentation-redis-4":"0.35.3","plugins/node/opentelemetry-instrumentation-restify":"0.34.1","plugins/node/opentelemetry-instrumentation-router":"0.33.2","plugins/node/opentelemetry-instrumentation-winston":"0.32.2","plugins/web/opentelemetry-instrumentation-document-load":"0.33.2","plugins/web/opentelemetry-instrumentation-long-task":"0.33.2","plugins/web/opentelemetry-instrumentation-user-interaction":"0.33.2","plugins/web/opentelemetry-plugin-react-load":"0.29.1","propagators/opentelemetry-propagator-aws-xray":"1.3.1","propagators/opentelemetry-propagator-grpc-census-binary":"0.27.1","propagators/opentelemetry-propagator-instana":"0.3.1","propagators/opentelemetry-propagator-ot-trace":"0.27.1"}

metapackages/auto-instrumentations-node/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@
101101
* @opentelemetry/instrumentation-fastify bumped from ^0.32.1 to ^0.32.2
102102
* @opentelemetry/instrumentation-mongodb bumped from ^0.36.1 to ^0.37.0
103103

104+
### Dependencies
105+
106+
* The following workspace dependencies were updated
107+
* dependencies
108+
* @opentelemetry/instrumentation-redis-4 bumped from ^0.35.2 to ^0.35.3
109+
104110
## [0.39.3](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/auto-instrumentations-node-v0.39.2...auto-instrumentations-node-v0.39.3) (2023-10-10)
105111

106112

metapackages/auto-instrumentations-node/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opentelemetry/auto-instrumentations-node",
3-
"version": "0.39.3",
3+
"version": "0.39.4",
44
"description": "Metapackage which bundles opentelemetry node core and contrib instrumentations",
55
"author": "OpenTelemetry Authors",
66
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/metapackages/auto-instrumentations-node#readme",
@@ -81,7 +81,7 @@
8181
"@opentelemetry/instrumentation-pg": "^0.36.2",
8282
"@opentelemetry/instrumentation-pino": "^0.34.2",
8383
"@opentelemetry/instrumentation-redis": "^0.35.2",
84-
"@opentelemetry/instrumentation-redis-4": "^0.35.2",
84+
"@opentelemetry/instrumentation-redis-4": "^0.35.3",
8585
"@opentelemetry/instrumentation-restify": "^0.34.1",
8686
"@opentelemetry/instrumentation-router": "^0.33.2",
8787
"@opentelemetry/instrumentation-socket.io": "^0.34.2",

plugins/node/opentelemetry-instrumentation-redis-4/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
* dependencies
77
* @opentelemetry/redis-common bumped from ^0.34.0 to ^0.35.0
88

9+
## [0.35.3](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-redis-4-v0.35.2...instrumentation-redis-4-v0.35.3) (2023-10-13)
10+
11+
12+
### Bug Fixes
13+
14+
* **instrumentation-redis-4:** avoid shimmer warning by only wrapping multi/MULTI if they exist ([#1729](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1729)) ([247a81c](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/247a81c047264ba638abb9a2ef2ca14801094040))
15+
* **instrumentation-redis-4:** fix unhandledRejection in client.multi(...) handling ([#1730](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1730)) ([d953531](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/d95353179279e3cf35ec37b6ca18f1e920691e16))
16+
917
## [0.35.2](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-redis-4-v0.35.1...instrumentation-redis-4-v0.35.2) (2023-10-10)
1018

1119

plugins/node/opentelemetry-instrumentation-redis-4/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opentelemetry/instrumentation-redis-4",
3-
"version": "0.35.2",
3+
"version": "0.35.3",
44
"description": "Automatic OpenTelemetry instrumentation for redis package version 4",
55
"main": "build/src/index.js",
66
"types": "build/src/index.d.ts",

plugins/node/opentelemetry-instrumentation-redis-4/src/instrumentation.ts

Lines changed: 71 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,31 @@ export class RedisInstrumentation extends InstrumentationBase<any> {
166166
this._diag.debug('Patching redis client');
167167
const redisClientPrototype = moduleExports?.default?.prototype;
168168

169-
if (isWrapped(redisClientPrototype?.multi)) {
170-
this._unwrap(redisClientPrototype, 'multi');
169+
// In some @redis/client versions 'multi' is a method. In later
170+
// versions, as of https://github.com/redis/node-redis/pull/2324,
171+
// 'MULTI' is a method and 'multi' is a property defined in the
172+
// constructor that points to 'MULTI', and therefore it will not
173+
// be defined on the prototype.
174+
if (redisClientPrototype?.multi) {
175+
if (isWrapped(redisClientPrototype?.multi)) {
176+
this._unwrap(redisClientPrototype, 'multi');
177+
}
178+
this._wrap(
179+
redisClientPrototype,
180+
'multi',
181+
this._getPatchRedisClientMulti()
182+
);
171183
}
172-
this._wrap(
173-
redisClientPrototype,
174-
'multi',
175-
this._getPatchRedisClientMulti()
176-
);
177-
178-
if (isWrapped(redisClientPrototype?.MULTI)) {
179-
this._unwrap(redisClientPrototype, 'MULTI');
184+
if (redisClientPrototype?.MULTI) {
185+
if (isWrapped(redisClientPrototype?.MULTI)) {
186+
this._unwrap(redisClientPrototype, 'MULTI');
187+
}
188+
this._wrap(
189+
redisClientPrototype,
190+
'MULTI',
191+
this._getPatchRedisClientMulti()
192+
);
180193
}
181-
this._wrap(
182-
redisClientPrototype,
183-
'MULTI',
184-
this._getPatchRedisClientMulti()
185-
);
186194

187195
if (isWrapped(redisClientPrototype?.sendCommand)) {
188196
this._unwrap(redisClientPrototype, 'sendCommand');
@@ -278,41 +286,61 @@ export class RedisInstrumentation extends InstrumentationBase<any> {
278286
return execRes;
279287
}
280288

281-
execRes.then((redisRes: unknown[]) => {
282-
const openSpans = this[OTEL_OPEN_SPANS];
283-
if (!openSpans) {
284-
return plugin._diag.error(
285-
'cannot find open spans to end for redis multi command'
286-
);
287-
}
288-
if (redisRes.length !== openSpans.length) {
289-
return plugin._diag.error(
290-
'number of multi command spans does not match response from redis'
291-
);
292-
}
293-
for (let i = 0; i < openSpans.length; i++) {
294-
const { span, commandName, commandArgs } = openSpans[i];
295-
const currCommandRes = redisRes[i];
296-
if (currCommandRes instanceof Error) {
297-
plugin._endSpanWithResponse(
298-
span,
299-
commandName,
300-
commandArgs,
301-
null,
302-
currCommandRes
289+
return execRes
290+
.then((redisRes: unknown[]) => {
291+
const openSpans = this[OTEL_OPEN_SPANS];
292+
if (!openSpans) {
293+
return plugin._diag.error(
294+
'cannot find open spans to end for redis multi command'
295+
);
296+
}
297+
if (redisRes.length !== openSpans.length) {
298+
return plugin._diag.error(
299+
'number of multi command spans does not match response from redis'
300+
);
301+
}
302+
for (let i = 0; i < openSpans.length; i++) {
303+
const { span, commandName, commandArgs } = openSpans[i];
304+
const currCommandRes = redisRes[i];
305+
if (currCommandRes instanceof Error) {
306+
plugin._endSpanWithResponse(
307+
span,
308+
commandName,
309+
commandArgs,
310+
null,
311+
currCommandRes
312+
);
313+
} else {
314+
plugin._endSpanWithResponse(
315+
span,
316+
commandName,
317+
commandArgs,
318+
currCommandRes,
319+
undefined
320+
);
321+
}
322+
}
323+
return redisRes;
324+
})
325+
.catch((err: Error) => {
326+
const openSpans = this[OTEL_OPEN_SPANS];
327+
if (!openSpans) {
328+
return plugin._diag.error(
329+
'cannot find open spans to end for redis multi command'
303330
);
304-
} else {
331+
}
332+
for (let i = 0; i < openSpans.length; i++) {
333+
const { span, commandName, commandArgs } = openSpans[i];
305334
plugin._endSpanWithResponse(
306335
span,
307336
commandName,
308337
commandArgs,
309-
currCommandRes,
310-
undefined
338+
null,
339+
err
311340
);
312341
}
313-
}
314-
});
315-
return execRes;
342+
return Promise.reject(err);
343+
});
316344
};
317345
};
318346
}

plugins/node/opentelemetry-instrumentation-redis-4/test/redis.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const instrumentation = registerInstrumentationTesting(
3232
new RedisInstrumentation()
3333
);
3434

35-
import { createClient } from 'redis';
35+
import { createClient, WatchError } from 'redis';
3636
import {
3737
Span,
3838
SpanKind,
@@ -398,6 +398,26 @@ describe('redis@^4.0.0', () => {
398398
);
399399
});
400400

401+
it('multi command that rejects', async () => {
402+
const watchedKey = 'watched-key';
403+
await client.watch(watchedKey);
404+
await client.set(watchedKey, 'a different value');
405+
try {
406+
await client.multi().get(watchedKey).exec();
407+
assert.fail('expected WatchError to be thrown and caught in try/catch');
408+
} catch (error) {
409+
assert.ok(error instanceof WatchError);
410+
}
411+
412+
// All the multi spans' status are set to ERROR.
413+
const [_watchSpan, _setSpan, multiGetSpan] = getTestSpans();
414+
assert.strictEqual(multiGetSpan?.status.code, SpanStatusCode.ERROR);
415+
assert.strictEqual(
416+
multiGetSpan?.status.message,
417+
'One (or more) of the watched keys has been changed'
418+
);
419+
});
420+
401421
it('duration covers create until server response', async () => {
402422
await client.set('another-key', 'another-value');
403423
const multiClient = client.multi();

0 commit comments

Comments
 (0)