Skip to content

[otel] Add support for specifying http.route on automatic HTTP server metrics #28445

@lucacasonato

Description

@lucacasonato

We should support users specifying the http.route and error.type attribute on automatically instrumented HTTP metrics.

To do this, I propose we copy the relevant attributes off the associated span on span completion. I suggest we do this as follows:

  • The span for the HTTP server is created in Rust (as an OtelSpan struct) and is associated with the request.
  • The span object can be exposed to JS with an op, similar to how op_http_get_request_method_and_url works. It takes the external for the HttpRequest, and returns a OtelSpan. The span is then put into AsyncContext.
  • The user can now update the span (adding http.route, error.type, etc).
  • When the response is finalized, we read the attributes relevant to the metric we'd like to record, in Rust, from the span.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions