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')
node_modules | |
package-lock.json |
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" | |
} | |
} |