Skip to content

Support --import flag for Node.js instrumentation #3414

Open
@raphael-theriault-swi

Description

Component(s)

auto-instrumentation

Is your feature request related to a problem? Please describe.

Currently it's not possible to instrument a Node.js application that uses ESM, or to create a custom auto-instrumentation image with asynchronous initialisation logic, because the --require flag injected in the NODE_OPTIONS environment variable doesn't support these use cases.

Describe the solution you'd like

Adding a new useImport or similar flag to the Node.js auto-instrumentation that injects --import /otel-auto-instrumentation-nodejs/autoinstrumentation.mjs instead of --require /otel-auto-instrumentation-nodejs/autoinstrumentation.js, and adding the new file to the provided image that delegates to autoinstrumentation.js but also registers hooks for ESM instrumentation.

Describe alternatives you've considered

No response

Additional context

I'd be happy to work on this.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions