Open jmadureira opened 5 months ago
I opened https://github.com/open-telemetry/opentelemetry-js-contrib/pull/2298 to address this! Reviews appreciated :)
@AbhiPrasad thanks for working on the fix, would you mind if I assign you? :slightly_smiling_face:
For sure!
What version of OpenTelemetry are you using?
What version of Node are you using?
v18.18.2
What did you do?
Instrument any application that uses knex and better-sqlite3 and trigger any SQL error.
What did you expect to see?
A span or trace should be correctly created and emitted.
What did you see instead?
A
TypeError: Expected second argument to be a string
is thrown instead and the application probably stops. Either way not span gets created.Additional context
Looking at the stackstrace:
The problem seems to be between https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-knex/src/utils.ts#L48 that creates a new instance of the underlying error and https://github.com/WiseLibs/better-sqlite3/blob/master/lib/sqlite-error.js#L9 which requires callers to provide 2 arguments. The 2nd argument (
code
) is not being passed by the knex instrumenter.