jt2594838 commented on code in PR #18562:
URL: https://github.com/apache/iotdb/pull/18562#discussion_r3910440945
##########
iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/prometheus/PrometheusReporter.java:
##########
@@ -135,6 +173,66 @@ public boolean start() {
return true;
}
+ @SuppressWarnings("unsafeThreadSchedule")
+ private void startSnapshotUpdater() {
+ // Keep metric collection off Reactor HTTP threads and avoid overlapping
scrapes.
+ if (snapshotUpdateExecutor == null) {
+ snapshotUpdateExecutor =
+ Executors.newSingleThreadScheduledExecutor(
+ runnable -> {
+ Thread thread = new Thread(runnable,
"prometheus-reporter-snapshot-updater");
+ thread.setDaemon(true);
+ return thread;
+ });
+ }
+ // Delay the first background scrape until metric sets have been bound by
the metric service.
+ snapshotUpdateFuture =
+ snapshotUpdateExecutor.scheduleAtFixedRate(
Review Comment:
The first scheduled scrape is delayed until the normal 15-second refresh
interval. MetricService starts reporters before AbstractMetricService binds
metric sets, so scheduling at delay 0 creates the empty-snapshot race reported
by CI. The delayed initial run preserves the existing cadence while the request
fallback above covers requests arriving sooner.
--
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]