Skip to content

@opentelemetry/instrumentation-express handler does not account for async work #2023

@aabmass

Description

@aabmass

What version of OpenTelemetry are you using?

├── @opentelemetry/[email protected]
└─┬ @opentelemetry/[email protected]
  ├── @opentelemetry/[email protected] deduped
  └── @opentelemetry/[email protected]

What version of Node are you using?

v18.19.1

What did you do?

Run the included express sample https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/express

What did you expect to see?

Async work should be accounted for in the handler duration.

What did you see instead?

The handler span has very short duration, only accounting for synchronous work. This is already a known caveat documented here but I couldn't find a tracking bug.

This screenshot demonstrates the problems
image

Additional context

A common pattern for express is to use an async function as the handler, as demonstrated in the sample

app.get('/run_test', async (req, res) => {

For handlers that return a promise, it should be possible to chain a span.end() call to the promise. However this also seems related to #2022

Metadata

Metadata

Labels

bugSomething isn't workingpkg:instrumentation-expresspriority:p2Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions