open-telemetry / opentelemetry-js-contrib

OpenTelemetry instrumentation for JavaScript modules
https://opentelemetry.io
Apache License 2.0
686 stars 502 forks source link

Hook support for adding custom dynamic metric attributes/ dimensions #2387

Closed alexa-gt closed 1 month ago

alexa-gt commented 1 month ago

Is your feature request related to a problem? Please describe

I am currently looking at implementing the following but running into an issue of not being able to add custom attributes/dimension, namely peer.service to the http.server.duration/ http.server.request.duration metric.

Describe the solution you'd like to see

The ability to add custom attributes and dimensions as a hook to the http.server.duration/ http.server.request.duration metric emitted by @opentelemetry/instrumentation-http, with something of the following signature:

export interface HttpRequestCustomMetricAttributeFunction {
    (request: ClientRequest, response: ServerResponse, incomingMessage: IncomingMessage): Attributes;
}

Describe alternatives you've considered

Additional context

None.

alexa-gt commented 1 month ago

Closed in favour of https://github.com/open-telemetry/opentelemetry-js/issues/4943 as that's where @opentelemetry/instrumentation-http currently is.