Skip to content

Commit

Permalink
Merge branch 'main' into trentm/issue1692-ioredis-esm
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Oct 17, 2023
2 parents cc31725 + 659d7ba commit f6e6414
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -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"}
{"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"}
6 changes: 6 additions & 0 deletions metapackages/auto-instrumentations-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@
* @opentelemetry/instrumentation-fastify bumped from ^0.32.1 to ^0.32.2
* @opentelemetry/instrumentation-mongodb bumped from ^0.36.1 to ^0.37.0

### Dependencies

* The following workspace dependencies were updated
* dependencies
* @opentelemetry/instrumentation-redis-4 bumped from ^0.35.2 to ^0.35.3

## [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)


Expand Down
4 changes: 2 additions & 2 deletions metapackages/auto-instrumentations-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/auto-instrumentations-node",
"version": "0.39.3",
"version": "0.39.4",
"description": "Metapackage which bundles opentelemetry node core and contrib instrumentations",
"author": "OpenTelemetry Authors",
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/metapackages/auto-instrumentations-node#readme",
Expand Down Expand Up @@ -81,7 +81,7 @@
"@opentelemetry/instrumentation-pg": "^0.36.2",
"@opentelemetry/instrumentation-pino": "^0.34.2",
"@opentelemetry/instrumentation-redis": "^0.35.2",
"@opentelemetry/instrumentation-redis-4": "^0.35.2",
"@opentelemetry/instrumentation-redis-4": "^0.35.3",
"@opentelemetry/instrumentation-restify": "^0.34.1",
"@opentelemetry/instrumentation-router": "^0.33.2",
"@opentelemetry/instrumentation-socket.io": "^0.34.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
* dependencies
* @opentelemetry/redis-common bumped from ^0.34.0 to ^0.35.0

## [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)


### Bug Fixes

* **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))
* **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))

## [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)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/instrumentation-redis-4",
"version": "0.35.2",
"version": "0.35.3",
"description": "Automatic OpenTelemetry instrumentation for redis package version 4",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,31 @@ export class RedisInstrumentation extends InstrumentationBase<any> {
this._diag.debug('Patching redis client');
const redisClientPrototype = moduleExports?.default?.prototype;

if (isWrapped(redisClientPrototype?.multi)) {
this._unwrap(redisClientPrototype, 'multi');
// In some @redis/client versions 'multi' is a method. In later
// versions, as of https://github.com/redis/node-redis/pull/2324,
// 'MULTI' is a method and 'multi' is a property defined in the
// constructor that points to 'MULTI', and therefore it will not
// be defined on the prototype.
if (redisClientPrototype?.multi) {
if (isWrapped(redisClientPrototype?.multi)) {
this._unwrap(redisClientPrototype, 'multi');
}
this._wrap(
redisClientPrototype,
'multi',
this._getPatchRedisClientMulti()
);
}
this._wrap(
redisClientPrototype,
'multi',
this._getPatchRedisClientMulti()
);

if (isWrapped(redisClientPrototype?.MULTI)) {
this._unwrap(redisClientPrototype, 'MULTI');
if (redisClientPrototype?.MULTI) {
if (isWrapped(redisClientPrototype?.MULTI)) {
this._unwrap(redisClientPrototype, 'MULTI');
}
this._wrap(
redisClientPrototype,
'MULTI',
this._getPatchRedisClientMulti()
);
}
this._wrap(
redisClientPrototype,
'MULTI',
this._getPatchRedisClientMulti()
);

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

execRes.then((redisRes: unknown[]) => {
const openSpans = this[OTEL_OPEN_SPANS];
if (!openSpans) {
return plugin._diag.error(
'cannot find open spans to end for redis multi command'
);
}
if (redisRes.length !== openSpans.length) {
return plugin._diag.error(
'number of multi command spans does not match response from redis'
);
}
for (let i = 0; i < openSpans.length; i++) {
const { span, commandName, commandArgs } = openSpans[i];
const currCommandRes = redisRes[i];
if (currCommandRes instanceof Error) {
plugin._endSpanWithResponse(
span,
commandName,
commandArgs,
null,
currCommandRes
return execRes
.then((redisRes: unknown[]) => {
const openSpans = this[OTEL_OPEN_SPANS];
if (!openSpans) {
return plugin._diag.error(
'cannot find open spans to end for redis multi command'
);
}
if (redisRes.length !== openSpans.length) {
return plugin._diag.error(
'number of multi command spans does not match response from redis'
);
}
for (let i = 0; i < openSpans.length; i++) {
const { span, commandName, commandArgs } = openSpans[i];
const currCommandRes = redisRes[i];
if (currCommandRes instanceof Error) {
plugin._endSpanWithResponse(
span,
commandName,
commandArgs,
null,
currCommandRes
);
} else {
plugin._endSpanWithResponse(
span,
commandName,
commandArgs,
currCommandRes,
undefined
);
}
}
return redisRes;
})
.catch((err: Error) => {
const openSpans = this[OTEL_OPEN_SPANS];
if (!openSpans) {
return plugin._diag.error(
'cannot find open spans to end for redis multi command'
);
} else {
}
for (let i = 0; i < openSpans.length; i++) {
const { span, commandName, commandArgs } = openSpans[i];
plugin._endSpanWithResponse(
span,
commandName,
commandArgs,
currCommandRes,
undefined
null,
err
);
}
}
});
return execRes;
return Promise.reject(err);
});
};
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const instrumentation = registerInstrumentationTesting(
new RedisInstrumentation()
);

import { createClient } from 'redis';
import { createClient, WatchError } from 'redis';
import {
Span,
SpanKind,
Expand Down Expand Up @@ -398,6 +398,26 @@ describe('redis@^4.0.0', () => {
);
});

it('multi command that rejects', async () => {
const watchedKey = 'watched-key';
await client.watch(watchedKey);
await client.set(watchedKey, 'a different value');
try {
await client.multi().get(watchedKey).exec();
assert.fail('expected WatchError to be thrown and caught in try/catch');
} catch (error) {
assert.ok(error instanceof WatchError);
}

// All the multi spans' status are set to ERROR.
const [_watchSpan, _setSpan, multiGetSpan] = getTestSpans();
assert.strictEqual(multiGetSpan?.status.code, SpanStatusCode.ERROR);
assert.strictEqual(
multiGetSpan?.status.message,
'One (or more) of the watched keys has been changed'
);
});

it('duration covers create until server response', async () => {
await client.set('another-key', 'another-value');
const multiClient = client.multi();
Expand Down

0 comments on commit f6e6414

Please sign in to comment.