Description
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 theHttpRequest
, and returns aOtelSpan
. The span is then put intoAsyncContext
. - 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.