eclipse-vertx/vert.x

Http1xServerConnection doesn't set the Vert.x context when recording metrics

ahus1 opened this issue · 4 comments

Version

4.5.10 (relevant code seems to be unchanged in main)

Context

As part of Keycloak 26, I'm running Quarkus 3.15.1 which include Vert.x 4.5.10. When I enable Quarkus Metrics and OpenTelemetry, I expect Exemplars to be recorded. Unfortunately that doesn't happen, as Http1xServerConnection doesn't set the context, and OpentelemetryExemplarSamplerProvider expects it to be set.

See quarkusio/quarkus#43845

Do you have a reproducer?

https://github.com/ahus1/quarkus-otel-missing-examplar-example

Steps to reproduce

See quarkusio/quarkus#43845

  1. Start Keycloak 26.0.0 and enable Metrics and OpenTelementry
  2. Login to issue some HTTP requests
  3. Retrieve metrics from the metrics endpoint using CURL

Extra

Running on JDK 17 on Windows. Seems be independent of JDK version and Windows.

In a locally patched version, I was able to fix it by updating

flushBytesWritten();
if (request.reportMetricsFailed) {
metrics.requestReset(request.metric());
} else {
metrics.responseEnd(request.metric(), request.response(), request.response().bytesWritten());
}

to wrap the calls for metrics in request.context.dispatch().

I'll prepare a draft PR to discuss this. As this is named Http1x, I suspect there might be other code for HTTP/2.0

Thank you @ahus1

I added a comment in quarkusio/quarkus#43845 explaining how to retrieve the context when a tracing or metrics SPI method is invoked. For performance reasons, not all these methods are invoked on a Vert.x context (it would cost too much to reschedule the task).

I'd like to hear from Quarkus experts about Metrics / Tracing integration

Closing as it will be handled on the Quarkus side. Sorry for the noise!

No worries !