open-telemetry / opentelemetry-js-contrib

OpenTelemetry instrumentation for JavaScript modules
https://opentelemetry.io
Apache License 2.0
638 stars 475 forks source link

ioredis instrumentation span.end getting called twice #2254

Open peterabbott opened 1 month ago

peterabbott commented 1 month ago

What version of OpenTelemetry are you using?

"@opentelemetry/instrumentation-ioredis"@0.40.0 (probably earlier ones too)

What version of Node are you using?

20

What did you do?

Enable IORedisInstrumentation class. On error querying Redis, causes warning around calling end on span already ended.

Looking at the code here, end is getting called both on reject but again in the catch.

What did you expect to see?

no errors

What did you see instead?

Messages like the follwing

"@opentelemetry/diag - get TRACE_ID-SPAN_ID - You can only call end() on a span once."

Additional context

There is obviously an issue with our Redis setup, but using the IORedis instrumentation is actually causing issues. When we remove the instrumentation class the issues we see with our Redis go away (as well obviosuly of the error mentioned above).

peterabbott commented 1 month ago

Potentially the utils endSpan method could have a isRecording checking

AbhiPrasad commented 1 month ago

Opened a PR for this https://github.com/open-telemetry/opentelemetry-js-contrib/pull/2256

pichlermarc commented 2 weeks ago

@AbhiPrasad can I assign you? :slightly_smiling_face:

AbhiPrasad commented 2 weeks ago

@pichlermarc yes please feel free to assign me! I have the fix, just need some advice on how to best test it.