Skip to content

Instantly share code, notes, and snippets.

@rowanmanning
Last active August 19, 2024 16:01
Show Gist options
  • Save rowanmanning/0c84d824d12405f00761f47a3d33db43 to your computer and use it in GitHub Desktop.
Save rowanmanning/0c84d824d12405f00761f47a3d33db43 to your computer and use it in GitHub Desktop.
OpenTelemetry Redis Instrumentations reduced test case
node_modules
package-lock.json

OpenTelemetry Redis Instrumentations reduced test case

To see the error:

  • Clone this gist
  • Install dependencies: npm install
  • Run: node --require ./bootstrap.js ./index.js

You should see the app crash with the following error:

TypeError: Cannot read properties of undefined (reading 'error')
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const opentelemetry = require('@opentelemetry/sdk-node');
const sdk = new opentelemetry.NodeSDK({
instrumentations: [
getNodeAutoInstrumentations()
]
});
sdk.start();
const redis = require('redis');
// Note: URL is set to an empty string. Redis itself does not error
// but OpenTelemetry Redis instrumentations cannot access `diag`
const client = redis.createClient({ url: '' });
client.on('error', error => console.error('Redis errored', error));
client.on('connect', () => console.info('Redis connected'));
client.connect();
{
"name": "opentelemetry-redis-error",
"dependencies": {
"@opentelemetry/auto-instrumentations-node": "^0.49.1",
"@opentelemetry/sdk-node": "^0.52.1",
"redis": "^4.7.0"
},
"volta": {
"node": "20.16.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment