clj-otel 2024-10-21

Hi! Is it possible to add a http.route attribute to http.server.request.duration https://opentelemetry.io/docs/specs/semconv/http/http-metrics/#metric-httpserverrequestduration automatically created by the OpenTelemetry JavaAgent? We have e.g. steffan-westcott.clj-otel.api.trace.http/wrap-compojure-route to add such attributes to the spans in tracing, but steffan-westcott.clj-otel.api.metrics.http.server says it should not be used with the agent.

steffan-westcott.clj-otel.api.metrics.http.server contains functions for producing HTTP server metrics as described by the semantic coventions defined by OpenTelemetry. They are intended to be used without the OpenTelemetry instrumentation agent, which also produces these metrics. If used together, you will likely get both sets of metrics and possibly errors. Note also that the metrics produced by clj-otel will be less precise than those produced by the agent since the agent has much tighter integration with the instrumented libraries.

It's been a while since I looked at this, but I didn't find a way to add route information to the metrics produced by the agent.

This appears to work for both metrics and traces: https://github.com/steffan-westcott/clj-otel/pull/22

Thank you for looking into this. I had not examined the Java instrumentation API closely before. This API is outside the scope of the OpenTelemetry API, as it targets the OpenTelemetry Java Instrumentation implementation. It's outside the current scope of clj-otel, but I'm considering if there is a case to expand the scope to include this additional API.

1

Thanks for considering it! If there is anything I can do to support, please tell me. 🙂

Would it help to, instead of placing the namespace in the clj-otel-api artifact, create a new artifact, e.g. clj-otel-instrumentation-api?

I need to investigate how to best enable this additional API. It is potentially confusing for clj-otel users, as the intended audience for the instrumentation API are library authors and not application authors.

We use this code in our application, since there is no instrumentation for the Compojure library included in the official OTel Java agent distribution.