Skip to content

@hono/otel overwrites http.route set by downstream middleware #1914

Description

@superxiao

Which middleware has the bug?

@hono/otel

What version of the middleware?

1.1.2

What version of Hono are you using?

4.12.23

What runtime/platform is your app running on? (with version if possible)

Node.js 24

What steps can reproduce the bug?

A Hono app uses @hono/otel around an adapter route such as /rpc/*. A downstream RPC adapter resolves the actual operation and sets http.route on the active span.

Example:

  • Hono route: /rpc/*
  • Resolved operation: /rpc/user/getProfile
  • Downstream middleware sets http.route = "/rpc/user/getProfile"

After the request finishes, @hono/otel runs its finalize step and sets http.route back to routePath(c), which is /rpc/*.

What is the expected behavior?

If downstream middleware changes http.route, @hono/otel should not overwrite it during finalize, or it should provide a config hook for choosing the final route value.

The same final route value should be used for http.server.request.duration, since today that metric also uses routePath(c) directly.

What do you see instead?

The span is finalized with http.route = "/rpc/*", and request duration metrics are also recorded under /rpc/*. All RPC operations behind the adapter route are grouped together even though the actual operation is known during request handling.

Additional information

spanNameFactory does not fully solve this because it only changes the span name. It does not control the final http.route attribute or the request duration metric attributes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions