tls instrumentation in @opentelemetry/instrumentation-net
tries to operate on closed span
#1775
Labels
bug
Something isn't working
pkg:instrumentation-net
priority:p4
Bugs and spec inconsistencies which do not fall into a higher prioritization
What version of OpenTelemetry are you using?
@opentelemetry/auto-instrumentations-node@0.39.4
@opentelemetry/sdk-node@0.44.0
What version of Node are you using?
Reproduced on:
What did you do?
When instrumented code uses
fetch
in a non-idiomatic manner, the tls instrumentation attempts to do an action on a closedtls.connect
span.For example, instrumenting the following code:
The
fetch
timeouts since the response is not properly handled.Point
A
is called when theCONNECT
event is emitted, handled inside otel here:opentelemetry-js-contrib/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts
Lines 122 to 143 in de6156a
Point
B
is called when theERROR
event is emitted, handled here:opentelemetry-js-contrib/plugins/node/opentelemetry-instrumentation-net/src/instrumentation.ts
Lines 145 to 151 in de6156a
First
A
is emitted, setting some attributes andend
ing the span. ThenB
is hit, which attempts to set a status and close the span. That's invalid, since the span has already ended. WithOTEL_LOG_LEVEL
set toinfo
, it prints something like the following:What did you expect to see?
The tls instrumentation handles these scenarios without stepping on its own toes.
What did you see instead?
When a
fetch
timeouts, the tls instrumentation tries doing operations on an ended spanPossible solutions
A couple of options (of course, more are possible):
connect
handlertls.connect
is a child span. Subsequent errors hit the longer parent spanI'm more than willing to create a followup PR for this
The text was updated successfully, but these errors were encountered: