Skip to content

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

Open
@aabmass

Description

@aabmass

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions