Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

knex integration does not work with OpenTelemetry (possible OpenCensus) for node.js <14.5.0 #25

Open
aabmass opened this issue Nov 11, 2020 · 0 comments

Comments

@aabmass
Copy link
Member

aabmass commented Nov 11, 2020

OpenTelemetry relies on node.js async hooks context in async calls. More details here:

This package provides async-hooks based context manager which is used internally by OpenTelemetry plugins to propagate specific context between function calls and async operations. It only targets NodeJS since async-hooks is only available there.

Unfortunately, this doesn't work with "thenables" which is knex.js uses (see open-telemetry/opentelemetry-js#940, knex/knex#3550) for node versions <14.5.0 (see nodejs/node#22360).

Thankfully, there is an existing plugin that solves this has solved this context issue for knex, which sqlcommenter-knex can base a solution on: https://github.com/myrotvorets/opentelemetry-plugin-knex/blob/bd5f2d918eeaa86c257f5e433772ec57b4834582/lib/knex.ts#L115

I have verified that this is working in newer node versions without any code changes.

@aabmass aabmass changed the title knex integration does not work with OpenTelemetry (possible OpenCensus) knex integration does not work with OpenTelemetry (possible OpenCensus) for node.js <14.5.0 Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant