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

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

Open
aabmass opened this issue Mar 18, 2024 · 3 comments
Assignees
Labels
bug Something isn't working pkg:instrumentation-express priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect

Comments

@aabmass
Copy link
Member

aabmass commented Mar 18, 2024

What version of OpenTelemetry are you using?

├── @opentelemetry/api@1.8.0
└─┬ @opentelemetry/auto-instrumentations-node@0.43.0
  ├── @opentelemetry/api@1.8.0 deduped
  └── @opentelemetry/instrumentation-express@0.36.1

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

@aabmass aabmass added the bug Something isn't working label Mar 18, 2024
@pichlermarc pichlermarc added the priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect label Mar 20, 2024
@raphael-theriault-swi
Copy link
Contributor

This was previously addressed in #1657 but it was decided to open a separate PR for it, which I then forgot to do. Will be taking this one since I already have the code for it.

@aabmass
Copy link
Member Author

aabmass commented Dec 17, 2024

@raphael-theriault-swi any update here?

@raphael-theriault-swi
Copy link
Contributor

#2603 looks like a fix, sorry I had completely forgotten about this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:instrumentation-express priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
Projects
None yet
Development

No branches or pull requests

4 participants