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

Express Route Conditional Middleware breaks resource names

Open arwilczek90 opened this issue 3 years ago • 1 comments

Expected behaviour

If I have middleware in express that has a regex for route inclusion or exclusion it should use the most specific path as the resource name. Actual behaviour

If I have middleware in express that has a regex for route inclusion or exclusion all traces get lumped under the longest path as its resource if it is shorter than the regex.

Steps to reproduce

app.use(/^\/(?!notThisRoute)\/.*/i, someMiddleware);

app.post('/form/:id', handler);

Environment

  • Operation system: Linux
  • Node.js version: 12.18.3
  • Tracer version: 2.15.0
  • Agent version: 7.38.2
  • Relevant library versions: express=4.12.4

This seems to come from the logic here.

arwilczek90 avatar Sep 15 '22 14:09 arwilczek90

@rochdev suggested prioritizing string routes over regex routes which should be a reasonable fix for this.

Qard avatar Sep 28 '22 13:09 Qard

@arwilczek90 I'm pretty sure we fixed this one a while ago so I'll close the issue. If you are using a recent version of the tracer and still have the issue then please reopen!

tlhunter avatar Dec 18 '23 22:12 tlhunter