Skip to content

fix(instrumentation-express): preserve matched route after handler - #3747

Open
Philipp-Perepelitsky wants to merge 1 commit into
open-telemetry:mainfrom
Philipp-Perepelitsky:fix/express-route-overwrite-2884
Open

fix(instrumentation-express): preserve matched route after handler#3747
Philipp-Perepelitsky wants to merge 1 commit into
open-telemetry:mainfrom
Philipp-Perepelitsky:fix/express-route-overwrite-2884

Conversation

@Philipp-Perepelitsky

Copy link
Copy Markdown

Assisted-by: ChatGPT 5.6 Sol

Which problem is this PR solving?

Fixes #2884.

Express middleware that runs after a matched request handler can overwrite RPCMetadata.route with a less specific middleware route. This can cause the HTTP server span to report an incorrect http.route.

Short description of the changes

-Preserve the route set by a request handler when later middleware executes.
-Continue allowing middleware to update route metadata before a request handler has matched.
-Add a regression test covering a /users/:id request handler followed by /users middleware.

Testing

-npm test -- --grep "rpcMetadata.route|should not overwrite route metadata" — 5 passing
-npm run compile — passing
-git diff --check — passing

@Philipp-Perepelitsky
Philipp-Perepelitsky requested a review from a team as a code owner September 9, 2026 08:08
@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 9, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Philipp-Perepelitsky / name: Philipp-Perepelitsky (70ee6ef)

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-js-contrib.

Important reminders:

  • Read our Contributing Guidelines.
  • Sign the CLA if you haven't already.
  • Follow the OpenTelemetry Generative AI policy: disclose any AI use in your contribution, and communicate (PR descriptions, review replies) in your own words rather than AI-generated text.
  • Give reviewers at least a few days before pinging them for feedback.
  • If you need help with general setup, development process, or contributor etiquette, ask in #opentelemetry-new-contributors.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 9, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-09-09 08:17 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Express instrumentation: rpcMetadata.route overwritten by middlewares after request handler

4 participants