Repository navigation
Conversation
… Prometheus registry
…mbedded bookie Main.buildBookieServer() created a second provider from the same configuration, and that one still landed on the 1.x default registry.
…n Prometheus registry BKCluster and LocalBookkeeperEnsemble let EmbeddedServer build the provider, which lands on the default registry the broker's /metrics reads. They now create and own the provider the same way PulsarBrokerStarter does, through a shared BookieStatsProviders helper.
…ats to the Prometheus Java client 1.x BrokerOperabilityMetrics and DimensionStats now register on PrometheusRegistry.defaultRegistry. Metric and label names are unchanged (apache#27045). PulsarStats.close() now closes BrokerOperabilityMetrics, so a broker restarted in the same JVM re-registers its topic load summary instead of scraping the first broker's stale one.
…ease it on close Tests can pass their own registry to DimensionStats, BrokerOperabilityMetrics and PulsarStats, so the register, duplicate and close paths are checked without the JVM-wide one. A mean over an empty snapshot reads as zero.
lhotari
left a comment
There was a problem hiding this comment.
Thanks for porting these metrics and for the lifecycle fix in PulsarStats.close(); the names, labels and quantiles line up with master and the new tests are a good guard for the registry hand-over. Two small points on behavior parity: the empty-summary mean now reads 0 where master produced NaN (so the "byte for byte" statement is not quite exact), and Summary.observe() can race with clear() in 1.x in a way simpleclient did not. Neither blocks the port; the rest are minor test and lifecycle notes. I only looked at the last two commits of this branch, since the earlier ones belong to #27350.
…nsionStats reset The mean of an empty summary is NaN again, as with simpleclient. reset() now excludes recording and reading, because clearing a 1.x summary can fail a concurrent observe().
lhotari
left a comment
There was a problem hiding this comment.
LGTM. All four threads are addressed in 7a188bf and 6fca2fb. The empty-summary mean is NaN again and pinned through the exported metric, reset() is now serialized against recording and reading, and the unneeded guard is gone. I ran DimensionStatsTest and BrokerOperabilityMetricsTest on this head and they pass.
…erability-prometheus-1x
Main Issue: #27045
#27350 makes the broker
/metricsread the Prometheus Java client 1.x default registry, and the parity test in this PR needs it. It is on master now and this branch has master merged in. This PR does not depend on the otherpulsar-brokerport PRs; they can merge in any order.Motivation
Part of the
pulsar-brokeritem in #27045:BrokerOperabilityMetricsandDimensionStats, the summary wrapper behindpulsar_topic_load_timesthat also feeds the admin broker stats.Modifications
DimensionStatswraps a 1.xSummarywith the same 6 quantiles and the same 60 second window. The admin broker stats entry (brk_topic_load_time_*) is byte for byte what it was. In 1.xSummary.clear()can race withobserve()andcollect(), soreset()takes a write lock and recording andgetSnapshot()share a read lock. A registry scrape reads the summary without the lock, so a scrape that overlapsreset()can see the family without its data point once. An instance that lost the registration to an earlier one is not registered again when that one closes.BrokerOperabilityMetrics: the 3 static counters are 1.x counters. The two*_skipped_totalnames are declared without_totalbecause the 1.x writer adds it.PulsarStats.close()now callsBrokerOperabilityMetrics.close(). Nothing called it before, so the first broker in a JVM keptpulsar_topic_load_timesregistered forever and later brokers in the same JVM, for example in tests, never got their own. With this, a broker started after another one closed registers its own summary. Brokers running at the same time in one JVM behave as before: the first one wins and the others log a warning.pulsar-brokeraddsprometheus-metrics-core(already shipped).Metric and exposition format changes (for the 5.1 release notes)
Names, labels and values are unchanged. The text format differs the same way as in #27350: counter
# TYPElines carry_total,_createdseries are gone, summary and histogram counts are integers, labels are sorted.Verifying this change
This change added tests and can be verified as follows:
PrometheusMetricsTest.testBrokerOperabilityMetricsAreScraped: after a topic load, the broker/metricsshows the 6 quantiles, count and sum ofpulsar_topic_load_times, the 14topic_load_failed_totalseries and the 2 skipped counters, all withcluster.DimensionStatsTest.shouldRecordAndReadWhileResetRuns: recording and reading while another thread resets the summary never fail. It fails without the lock.DimensionStatsTest.shouldReadUnusedStatsAsEmptyandBrokerOperabilityMetricsTest.testTopicLoadMeanIsNaNWhenNothingWasRecordedSinceTheLastReset: an unused or just reset summary reads count 0 and NaN for the mean and the quantiles, also throughbrk_topic_load_time_mean_ms.pulsar_topic_load_timessummary: when another broker in the same JVM registered it first, only the shape is checked. That is the pre-existing first broker wins behaviour.BrokerServiceTest,AdminApiMultiBrokersTest,OpenTelemetryBrokerOperabilityStatsTestandDimensionStatsTestpass. InPrometheusMetricsTest, which starts 37 brokers one after another, the "is already registered" warning forpulsar_topic_load_timesno longer appears.Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Dependencies:
pulsar-brokeraddsio.prometheus:prometheus-metrics-core1.8.0 (already shipped). Metrics: format changes listed above.Documentation
docdoc-requireddoc-not-neededdoc-complete