-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Certain Kafka metrics may not be available #3325
Comments
calohmn
added a commit
to bosch-io/hono
that referenced
this issue
Jul 6, 2022
…erRecorder. Combine Kafka metrics in a MeterBinder bean so that binding of the metrics to the MeterRegistry is done implicitly via the Quarkus MicrometerRecorder. This ensures that the binding is done *after* the MeterFilter beans get added to the registry. This in turn ensures that the KafkaMetrics are aware of the commonTags MeterFilters when being bound to the registry. Signed-off-by: Carsten Lohmann <carsten.lohmann@bosch.io>
calohmn
added a commit
that referenced
this issue
Jul 6, 2022
Combine Kafka metrics in a MeterBinder bean so that binding of the metrics to the MeterRegistry is done implicitly via the Quarkus MicrometerRecorder. This ensures that the binding is done *after* the MeterFilter beans get added to the registry. This in turn ensures that the KafkaMetrics are aware of the commonTags MeterFilters when being bound to the registry. Signed-off-by: Carsten Lohmann <carsten.lohmann@bosch.io>
calohmn
added a commit
that referenced
this issue
Jul 6, 2022
Signed-off-by: Carsten Lohmann <carsten.lohmann@bosch.io>
calohmn
added a commit
that referenced
this issue
Jul 6, 2022
Combine Kafka metrics in a MeterBinder bean so that binding of the metrics to the MeterRegistry is done implicitly via the Quarkus MicrometerRecorder. This ensures that the binding is done *after* the MeterFilter beans get added to the registry. This in turn ensures that the KafkaMetrics are aware of the commonTags MeterFilters when being bound to the registry. Signed-off-by: Carsten Lohmann <carsten.lohmann@bosch.io> (cherry picked from commit df05c88)
calohmn
added a commit
that referenced
this issue
Jul 6, 2022
Signed-off-by: Carsten Lohmann <carsten.lohmann@bosch.io>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After the Hono 2.0 update, certain Kafka metrics sometimes don't seem to be available.
This has been observed for Kafka consumer metrics that have a
topic
tag, for examplekafka.consumer.fetch.manager.records.consumed.total
.The issue is, that for this metric, there is only one meter being registered (per client-id). That means that the number of records consumed is only available for one random topic, meaning a chart for that metric is potentially mostly empty.
Analysis:
The Micrometer KafkaMetrics class registers the meters for the Kafka metrics in the metrics registry.
In the
checkAndBindMetrics()
method, there is special logic to skip adding meters that have less tags than an already registered meter with the same name (PrometheusMeterRegistry
only supports an equal number of tags for meters with the same name - see micrometer-metrics/micrometer#877).This logic is needed for example for the
kafka.consumer.fetch.manager.records.consumed.total
metrics. These metrics are observed for each topic (i.e. containing thetopic
tag) and there is also one metric entry for the overall number (without thetopic
tag). The meter for the entry without thetopic
tag shall not be registered (or shall be removed during the next invocation).This logic for checking the number of tags involves also considering the common tags, added via
MeterFilters
to all meters.This list of common tags is only initialized once in
KafkaMetrics
.This issue now is that since Hono has moved to using
quarkus-micrometer
, the initialization of theseMeterFilters
(done by the QuarkusMicrometerRecorder
) is now potentially taking place at a later point in time.Log output:
That means that the Micrometer
KafkaMetrics
instance is using an empty common tags list for deciding whether a meter should be registered - if there is already an existing meter with that name. This leads to such meters not being added because the existing meter tag list (containing the common tags) is always longer than the tag list of the traversed metric with the empty common tags list. (The emptyKafkaMetrics
instance "common tags" list has also been observed in heap dumps here.)Solution:
The fix would be to have
kafkaClientMetrics.bindTo(meterRegistry)
be invoked in Hono after QuarkusMicrometerRecorder
initialization is done. ThatbindTo
method is invoked in the HonoMicrometerKafkaClientMetricsSupport.registerKafkaConsumer()
andregisterKafkaProducer()
methods.The text was updated successfully, but these errors were encountered: