Repository navigation
Conversation
…va client 1.x FunctionCollectorRegistry now extends PrometheusRegistry; the instance HTTP server, JMX collector 1.5.0 and JvmMetrics register on it. Metric names and labels are unchanged (apache#27045). The instance endpoint keeps serving metrics on the root path, which the worker scrapes from older instances; the worker now requests /metrics.
2 of 19 tasks
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.
Main Issue: #27045
Motivation
Part of the Functions item in #27045: the metrics of a Java function instance, the HTTP endpoint that serves them, the JMX collector and the instance JVM metrics. These four share one registry, so they move together. This PR does not depend on #27350.
Modifications
FunctionCollectorRegistryImplnow extends the 1.xPrometheusRegistry. It keeps the register once per name behaviour that the stats managers rely on when several instances share one registry in thread mode.FunctionStatsManager,SinkStatsManager,SourceStatsManager: all counters, gauges and latency summaries are 1.x metrics with the same names and labels. Summaries keep their quantiles and the 10 minute window. As before, nothing is unregistered when an instance closes, because the metric objects are shared by every instance on the registry, andreset()still clears the shared metric and recreates this instance's label set.ContextImpl: the user metrics summary is a 1.xSummary. The admin API keysuser_metric_<name>_{sum,count,0.5,0.9,0.99,0.999}and their values are unchanged; a test now pins that.JavaInstanceStarterandLocalRunnerserve the registry with the 1.xHTTPServer. The root path/keeps returning metrics text, because the worker fetches instance metrics from there and splices the text into its own/metrics. The 1.x server would otherwise return an HTML page on/.RuntimeUtils.getPrometheusMetricsnow asks for/metrics, which every instance version serves.RuntimeUtils.registerDefaultCollectors: the JMX collector isio.prometheus.jmx:collector1.5.0 (built on client 1.4.1, no new dependencies, same MBean naming). The JVM metrics are the 1.x collectors, registered one by one instead of throughJvmMetrics, becauseJvmMetricskeeps every registry it saw in a static set andLocalRunnercreates a registry per start.FunctionStatsManagerand the unusedgetProcessLatency*getters, which exposed simpleclient types. Nothing in the repository used them.PrometheusTextFormatstays until the worker PR stops using it.prometheus-jmx0.16.1 to 1.5.0;pulsar-functions-instance,-runtimeand-local-runner-originalmove fromsimpleclientto the 1.x artifacts. The HTTP server dependency excludes the fullexposition-formatsjar and uses theno-protobufone, the same way the OpenTelemetry Prometheus exporter already in the distribution does, so only one copy of those classes is shipped.Metric and exposition format changes (for the 5.1 release notes)
Function, sink and source metrics keep their names, labels and values. The text format differs as in #27350: counter
# TYPElines carry_total,_createdseries are gone, counts are integers, labels are sorted, no trailing comma, and the thread mode text now has# HELPlines.Two changes are visible to anyone scraping a function instance directly, for example a Kubernetes pod:
jvm_memory_bytes_{used,committed,max,init}tojvm_memory_{used,committed,max,init}_bytes,jvm_memory_pool_bytes_{used,committed,max,init}tojvm_memory_pool_{used,committed,max,init}_bytes, andjvm_infotojvm_runtime_info. Two new families appear,jvm_compilation_time_seconds_totalandjvm_memory_pool_allocated_bytes_total. This is the same change the bookie made in [improve][monitor] Restore the BookKeeper Prometheus stats provider on the Prometheus Java client 1.x #26360; the broker, proxy and worker will follow in one PR.jmx_config_reload_success_totalandjmx_config_reload_failure_totalare new.Verifying this change
This change added tests and can be verified as follows:
ContextImplTest.testGetMetricsKeys: the user metric keys and values after tworecordMetriccalls.ComponentStatsManagerTest: names, labels andNaNquantiles of empty summaries on a fresh registry.RuntimeUtilsTest.testRegisterDefaultCollectorsOnFreshRegistries: two fresh registries both get the JVM and JMX families, and the static set inJvmMetricsdoes not grow.pulsar-functions-instance(189 tests) andpulsar-functions-runtime(95 tests) pass. On the broker sidePulsarFunctionE2ETest,PulsarSinkE2ETest,PulsarSourceE2ETest,PulsarBatchSourceE2ETestandPulsarFunctionLocalRunTest(52 tests) pass; they parse the spliced metrics text./and/metricswithtext/plain; version=0.0.4and the same family set as before, apart from the JVM and JMX changes above.Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Dependencies:
io.prometheus.jmx:collector0.16.1 to 1.5.0; the Functions instance, runtime and local runner modules replacesimpleclientwithprometheus-metrics-core,-model,-exposition-textformats,-exporter-httpserver,-instrumentation-jvm1.8.0 (all already shipped). Metrics: format changes and the JVM and JMX changes listed above.Documentation
docdoc-requireddoc-not-neededdoc-complete