HTHou commented on code in PR #18562:
URL: https://github.com/apache/iotdb/pull/18562#discussion_r3909999926
##########
iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/prometheus/PrometheusReporter.java:
##########
@@ -104,8 +122,12 @@ public boolean start() {
// authenticate not pass
return Mono.empty();
}
+ String metrics =
+ METRIC_CONFIG.isPrometheusReporterAsyncUpdate()
+ ? metricsSnapshot
Review Comment:
**[P1] Avoid serving an uninitialized Prometheus snapshot**
`metricsSnapshot` starts as an empty string, while the HTTP server is bound
before the updater is scheduled. More importantly,
`AbstractMetricService.startService()` starts all reporters before binding the
metric sets, so the initial scheduled scrape can cache an empty snapshot and
the endpoint will continue returning HTTP 200 with an empty body until the next
refresh 15 seconds later. This is already reproduced by both the standalone
Ubuntu and Simple (17) CI jobs: `IoTDBMetricIT.testPrometheusReporter` and
`testPrometheusReporterWithoutAuth` fail because the response length is 0.
Please use an uninitialized sentinel with a synchronous fallback for the first
request, or ensure that a valid snapshot is generated after metric-set binding
before cached responses are served.
CI: [standalone
Ubuntu](https://github.com/apache/iotdb/actions/runs/33498539648/job/99826238241),
[Simple
(17)](https://github.com/apache/iotdb/actions/runs/33498539750/job/99826238436)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]