opentelemetry-js
opentelemetry-js copied to clipboard
@opentelemetry/api 1.8.0 produces detached spans from knex.raw() calls
What happened?
Steps to Reproduce
Use @opentelemetry/api and @opentelemetry/instrumentation-knex where sql queries executed by knex are nested inside some other trace.
Specifically, calling a raw select like so should be nested under the active parent span:
knex.raw('select 1=1')
Expected Result
The span produced by knex.raw call has parentSpanId set to the parent span ID.
Actual Result
The span produced by knex.raw call has parentSpanId set to undefined.
Additional Details
This specifically breaks when going from version 1.7.0 to 1.8.0 of the @opentelemetry/api package as the only change in the repo.
I can provide more details - I can provide a full span object with 1.7.0 and 1.8.0 if that helps or .. I can work on a fully reproducible example. But just wanted to post this in case someone knows what might be going on. We observed in our Honeycomb UI that all knex.raw calls "fell out" of their parent spans after upgrading to 1.8.0.
OpenTelemetry Setup Code
import { HoneycombSDK } from '@honeycombio/opentelemetry-node'
import { Instrumentation as FeathersInstrumentation } from '@humaans/instrumentation-feathers/instrumentation.ts'
import { Attributes, Span, SpanStatusCode, Tracer } from '@opentelemetry/api'
import { KnexInstrumentation } from '@opentelemetry/instrumentation-knex'
if (config.get('honeycomb.enabled')) {
const sdk = new HoneycombSDK({
apiKey: config.get('apiKey')
instrumentations: [
new KnexInstrumentation(),
new FeathersInstrumentation({ getSpanAttributes }),
],
})
sdk.start()
}
package.json
No response
Relevant log output
No response
I can work on a fully reproducible example.
That would be very helpful, yes, please.
Also, I'm curious if there are other package version changes. Perhaps showing the output of npm ls -a for both the working and failling cases might help show that.