-
Notifications
You must be signed in to change notification settings - Fork 552
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 does not normalize paths (removing double slashes) #1547
Comments
Thanks for reporting this @rrva! Adding a link to the CNCF Slack conversation for additional context: https://cloud-native.slack.com/archives/C01NL1GRPQR/p1687429185406239 |
I took a closer look at this and I think |
Hmm, I think The semconv spec mentions that we should use
While unlikely, if EDIT: looks like I forgot to link the line in the express instrumentation |
Like @pichlermarc said, the value of Here's where this metadata is set in the Express instrumentation, with the |
So it's the server framework instrumentation which detects the route and it is also responsible to format it correct. express and others besides connect are implemented more complex then needed for historic reasons. #1534 shows how it should look like. |
Thanks for the clarification all! I was initially thinking something simple like this regex replace but wondering if it's still too naive... const route = (req[_LAYERS_STORE_PROPERTY] as string[])
.filter(path => path !== '/' && path !== '/*')
.join('')
// remove duplicate slashes to normalize route
.replace(/\/{2,}/g, '/'); There is something similar happening for connect in #1555 that has a lot more logic compared to this simple regex replace 🤔 . I'll have to look at that a bit more to see if it's closer to what we need here. Also I see #1557 was created for express that is similar to that connect PR #1534 so these may end up being somewhat tied together in implementation. |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
What version of OpenTelemetry are you using?
auto-instrumentations-node 0.37.1
instrumentation-express 0.32.4
What version of Node are you using?
18
What did you do?
define some routes like this:
What did you expect to see?
http.route attribute in traces should contain:
Instrumentation should normalise the path in the same way that Express does (Express knows that declaring /v5/ inside /foo/ means /foo/v5/ not /foo//v5/ )
What did you see instead?
Additional context
express 4.18.2
The text was updated successfully, but these errors were encountered: