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

express instrumentation - span end prematurely for non-middleware instrumentations #2442

Open
2 tasks done
jzhou7-atl opened this issue Sep 21, 2024 · 3 comments · May be fixed by #2603
Open
2 tasks done

express instrumentation - span end prematurely for non-middleware instrumentations #2442

jzhou7-atl opened this issue Sep 21, 2024 · 3 comments · May be fixed by #2603

Comments

@jzhou7-atl
Copy link

jzhou7-atl commented Sep 21, 2024

  • This only affects the JavaScript OpenTelemetry library
  • This may affect other libraries, but I would like to get opinions here first

Hi, I want to verify if this is a bug or intended behavior of the current instrumentation code.
I notice in the instrumentation code: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts#L236-L242

The span is ended right after it is created unless it's a middleware. It does not even measure the sync execution time of the actual handler.

Should it be put after this line to measure the original handle execution time? https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts#L285

I ran a few tests, the time measured for 'request handler' is extremely short, only a couple of microseconds.

Much appreciated for looking into this!

@Lms24
Copy link

Lms24 commented Dec 12, 2024

I can confirm that this happens for me, too after looking into a bug report in our Sentry SDK repository. Looking at the code I can see that a bit further below the middleware check, the callback is patched but the span is also ended before the original callback is invoked.

In addition to @jzhou7-atl's question: Shouldn't the span only be ended after the original callback is called and returns?

@aabmass
Copy link
Member

aabmass commented Dec 17, 2024

Is this the same as #2023?

@raphael-theriault-swi
Copy link
Contributor

Looks the same to me yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants