opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

Hook support for adding custom dynamic metric attributes/ dimensions

Open alexa-gt opened this issue 1 year ago • 0 comments
trafficstars

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

  • Stick strictly to the semconv metric
    • allows no deviation or possibility of deviation without completely ditching the autoinstrumentation library, or writing a custom middleware.
  • spanmetrics connector in the OTEL connector with the selected dimension
    • this is not possible for my use case as I am unable to deploy otel-col in my architecture in the near term. It has to be an app-solution.
  • this hack that embeds additional info in http.route.
    • seems very strange to build an app's routing system around a workaround

Additional context

None.

alexa-gt avatar Aug 22 '24 00:08 alexa-gt