Add support for per-broker and per-topic partition metrics#213
Open
allait wants to merge 6 commits into
Open
Conversation
Adds broker, topic, partition and consumer-group level properties for parsing `librdkafka` statistics output. This covers most of the fields exported in `librdkafka` statistics events, skipping some internal ones (e.g. internal timestamp) that are unlikely to be useful as metrics. Renames existing properties to have a more consistent naming convention: using `total` as a suffix to closer match the metric names recommended by Prometheus docs and dropping repeated `...KafkaBroker...`.
`KafkaMetrics` is going to replace metrics structs from `KafkaConfiguration`. Instead of expecting users to initialize metric instances it creates them on demand using the provided configuration and label prefix. Note: all metric instances are created on-demand, we're not holding a cache of metric handlers as the list of broker and topic statistics might change between updates. Statistics interval can only be configured in increments of 1 second, but this might still have a performance impact when there are many brokers/partitions involved.
Supporting both old and new implementations at the same time would require an additional public protocol. With the goal of removing old configuration structs before 1.0 we drop the `.metrics` field from them instead.
e0ccbef to
6812522
Compare
Add tests for per-broker and per-partition metrics and make the tests run concurrently by specifying the metrics factory.
6812522 to
ba54a8f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
KafkaMetricsstruct that can export global, per-broker and per-topic/partition statistics fromlibrdkafkaasswift-metrics. New struct replacesKafkaConfiguration.*Metricsstructs that only supported a subset of top-level metrics and required creating aGaugeinstance for each one.Motivation
Most of the useful
librdkafkametrics like consumer lag, latency and round-trip times require a dynamic set ofGauges so weren't supported and don't combine well with the existingKafkaConfiguration.*Metricsinterfaces.Modifications
Add a mapping for most of librdkafka stats in
RDKafkaStatisticsAdds broker, topic, partition and consumer-group level properties for parsing
librdkafkastatistics output.This covers most of the fields exported in
librdkafkastatistics events, skipping some internal ones (e.g. internal timestamp) that are unlikely to be useful as metrics.Renames existing properties to have a more consistent naming convention: using
totalas a suffix to closer match the metric names recommended by Prometheus docs and dropping repeated...KafkaBroker....Add
KafkaMetricsto convert librdkafka statistics to swift-metricsKafkaMetricsis going to replace metrics structs fromKafkaConfiguration.Instead of expecting users to initialize metric instances it creates them on demand using the provided configuration and label prefix.
Note: all metric instances are created on-demand, we're not holding a cache of metric handlers as the list of broker and topic statistics might change between updates. Statistics interval can only be configured in increments of 1 second, but this might still have a performance impact when there are many brokers/partitions involved.
Replace
KafkaConfiguration.*MetricswithKafkaMetricsin configsUpdate clients to use
KafkaMetricsDrop
KafkaConfigurationmetrics property and structsSupporting both old and new implementations at the same time would require an additional public protocol. With the goal of removing old configuration structs before 1.0 we drop the
.metricsfield from them instead.Update
KafkaMetricsTestsAdd tests for per-broker and per-partition metrics and make the tests run concurrently by specifying the metrics factory.
Result
Most of
librdkafkastatistics (excluding some internal ones) are exported asswift-metricsGauges.