Express Route Conditional Middleware breaks resource names
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.
@rochdev suggested prioritizing string routes over regex routes which should be a reasonable fix for this.
@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!