[feat][monitor] PIP-223: Add metrics for all rest endpoints.#21772
[feat][monitor] PIP-223: Add metrics for all rest endpoints.#21772dao-jun wants to merge 17 commits into
Conversation
|
refers to: #18836 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21772 +/- ##
============================================
+ Coverage 73.57% 73.59% +0.01%
+ Complexity 32624 32153 -471
============================================
Files 1877 1878 +1
Lines 139502 139603 +101
Branches 15299 15321 +22
============================================
+ Hits 102638 102737 +99
+ Misses 28908 28878 -30
- Partials 7956 7988 +32
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Thanks for implementing this.
Please note that we have already started implementing PIP-264, which is Open Telemetry. We have added the infrastructure needed to define metrics, and we are underway of adding the first metrics.
Once we finish the first PR, can we ping you to add those metrics using OTel? Once that PR we fill finally know the naming conventions to use.
| admin.namespaces().deleteNamespace("test/test"); | ||
| admin.tenants().deleteTenant("test"); | ||
|
|
||
| ByteArrayOutputStream output = new ByteArrayOutputStream(); |
There was a problem hiding this comment.
Save yourself this code and the intimate knowledge of how it is implemented:
Create a client like this against the local broker.
prometheusMetricsClient = new PrometheusMetricsClient("127.0.0.1", pulsar.getListenPortHTTP().get());
Get the Metrics:
Metrics metrics = prometheusMetricsClient.getMetrics();
and assert example:
Metric backlogAgeMetric =
metrics.findSingleMetricByNameAndLabels("pulsar_storage_backlog_age_seconds",
Pair.of("topic", topic1));
assertThat(backlogAgeMetric.tags).containsExactly(
entry("cluster", CLUSTER_NAME),
entry("namespace", namespace),
entry("topic", topic1));
assertThat((long) backlogAgeMetric.value).isCloseTo(expectedMessageAgeSeconds, within(2L));
Add the method you lack at Metrics
| private RestEndpointMetricsFilter(PulsarService pulsar) { | ||
| PulsarBrokerOpenTelemetry telemetry = pulsar.getOpenTelemetry(); | ||
| Meter meter = telemetry.getMeter(); | ||
| latency = meter.histogramBuilder("pulsar_broker_rest_endpoint_latency") |
There was a problem hiding this comment.
Please look at #22058 to understand how to do:
Instrument name, description, unit.
PIP: #18560
Motivation
#18560
Modifications
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: dao-jun#6