opentelemetry-js
opentelemetry-js copied to clipboard
Enhance the instrumentation-http hooks or add new ones to allow users to add their own attributes to the server and client metrics
NB: Before opening a feature request against this repo, consider whether the feature should/could be implemented in the other OpenTelemetry client libraries. If so, please open an issue on opentelemetry-specification first.
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
This is related to https://github.com/open-telemetry/opentelemetry-js/issues/3683.
Our need is to add extra attributes to the http_server and http_client metrics provided by the HTTP instrumentation.
That's not actually possible because of this https://github.com/open-telemetry/opentelemetry-js/issues/3683#issuecomment-1477373472.
Ideally we would use the requestHook https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_instrumentation_http.HttpInstrumentationConfig.html#requestHook to inject custom attributes to those metrics, but any additional hook would work as far as we can add additional attributes to http server and client duration metrics.
Describe alternatives you've considered
The alternative is actually using the instrumentation-express, which adds the http_route to the server metric. However, we have the need to add additional custom attributes to both, server and client metrics.
Additional context
Add any other context or screenshots about the feature request here.