dd-trace-js icon indicating copy to clipboard operation
dd-trace-js copied to clipboard

[BUG]: Main express operation and metrics renamed from `express.request` to `web.request` was not mentioned in the docs

Open alejandro-delgado-garcia opened this issue 1 month ago • 6 comments

Package Name

No response

Package Version(s)

5.76.0

Describe the feature you'd like

I think you should document in the release notes that you have renamed the main express operation from express.request to web.request

Is your feature request related to a problem?

The main operation and trace metrics for Express have been renamed, which is now causing issues with our existing alerts and monitors. Consequently, these metrics are no longer reported under the previous name, trace.express.request, but have been moved to a completely new metric named trace.web.request. This change means the original metrics are no longer being reported.

Describe alternatives you've considered

Updating our monitors is one alternative, but without any mention in the docs, we can only know after deploying our app.

Additional context

No response

@alejandro-delgado-garcia that is indeed not ideal and should not be intentional. Could you name the version jump you did?

BridgeAR avatar Nov 06 '25 14:11 BridgeAR

@alejandro-delgado-garcia that is indeed not ideal and should not be intentional. Could you name the version jump you did?

v5.22.0 to v5.76.0

I went back and check our traces before we did the upgrade and noticed that the traces are now using component: http instead of component: express, wondering if this could be useful for investigation purposes

👋 New update regarding this. We tried 5.63, and this issue doesn't happen

@BridgeAR We're encountering this issue as well! It seems like express instrumentation is broadly broken. We also stop getting express.middleware spans. It seems like this was introduced in version 5.68.0 and affects all later versions. 5.67.0 works fine in my testing

michaelsmithxyz avatar Dec 10 '25 20:12 michaelsmithxyz

This change seems a bit suspicious scanning the diff between those two releases, but I don't know enough about how dd-trace works to say for sure: https://github.com/DataDog/dd-trace-js/pull/6401

michaelsmithxyz avatar Dec 10 '25 20:12 michaelsmithxyz

Is there anything in common with folks having this issue? For example, is everyone bundling with esbuild?

tlhunter avatar Dec 19 '25 19:12 tlhunter

As an update: in our case this was due to subtly improper dd-trace initialization. Our initialization was slightly wrong such that we were in some weird partially initialized state wherein the Express integration fully worked prior to 5.68.0 (which is why we never noticed), but changed behavior in versions later than 5.68.0. I don't think this is a bug though, since we weren't initializing correctly.

In either case, here's a minimal reproduction of what I'm talking about: https://gist.github.com/michaelsmithxyz/75ff8db79df2c357162e8a6d5be140e8

If you require('express'), initialize the tracer, and then configure your Express app in an module that requires express again, you end up in a state where the Express instrumentation works prior to 5.68.0, but generates web.request spans in newer versions. When I fixed our app to actually initialize the tracer first, the integration works fine!

michaelsmithxyz avatar Dec 19 '25 22:12 michaelsmithxyz

@michaelsmithxyz we definitely break in unexpected ways when any module that we instrument is required before the tracer. It's actually very surprising that it worked beforehand. It's likely that some functionality was broken in that state.

Can others who are experiencing this issue please check if this is also happening? You can do so like this:

DD_TRACE_DEBUG=true node app.js

Warning: Package 'express' was loaded before dd-trace! This may break instrumentation.
Warning: Package 'body-parser' was loaded before dd-trace! This may break instrumentation.
Warning: Package 'router' was loaded before dd-trace! This may break instrumentation.
Warning: Package 'cookie' was loaded before dd-trace! This may break instrumentation.
Warning: Please ensure dd-trace is loaded before other modules.

tlhunter avatar Dec 22 '25 17:12 tlhunter