HTHou commented on code in PR #18708:
URL: https://github.com/apache/iotdb/pull/18708#discussion_r4085354504
##########
iotdb-core/metrics/interface/src/main/java/org/apache/iotdb/metrics/reporter/prometheus/PrometheusReporter.java:
##########
@@ -189,9 +154,68 @@ public synchronized boolean start() {
return true;
}
+ private HttpServer createHttpServer() throws Exception {
+ InetSocketAddress address = new
InetSocketAddress(METRIC_CONFIG.getPrometheusReporterPort());
+ if (!METRIC_CONFIG.isEnableSSL()) {
+ return HttpServer.create(address, 0);
+ }
+
+ SSLContext sslContext =
+ createSslContext(
+ METRIC_CONFIG.getKeyStorePath(),
+ METRIC_CONFIG.getKeyStorePassword(),
+ METRIC_CONFIG.getTrustStorePath(),
+ METRIC_CONFIG.getTrustStorePassword());
+ HttpsServer httpsServer = HttpsServer.create(address, 0);
+ httpsServer.setHttpsConfigurator(
+ new HttpsConfigurator(sslContext) {
+ @Override
+ public void configure(HttpsParameters parameters) {
+ SSLParameters sslParameters = sslContext.getDefaultSSLParameters();
+ sslParameters.setNeedClientAuth(true);
+ parameters.setSSLParameters(sslParameters);
+ }
+ });
+ return httpsServer;
+ }
+
+ private ExecutorService newHttpExecutor() {
+ return Executors.newFixedThreadPool(
+ PROMETHEUS_HTTP_SERVER_WORKER_THREADS,
Review Comment:
Addressed in 1198beaf5c: the executor now scales from 2 to 8 workers and
uses a bounded queue of 16 with AbortPolicy, so two slow clients no longer
starve later scrapes and requests cannot accumulate in an unbounded queue. JDK
HttpServer does not expose a supported per-response socket timeout; the bounded
executor limits the remaining exposure.
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/concurrent/ThreadName.java:
##########
@@ -192,9 +192,7 @@ public enum ThreadName {
SYSTEM_SCHEDULE_METRICS("SystemScheduleMetrics"),
RESOURCE_CONTROL_DISK_STATISTIC("ResourceControl-DataRegionDiskStatistics"),
PROMETHEUS_REPORTER_SNAPSHOT_UPDATER("PrometheusReporter-Snapshot-Updater"),
- PROMETHEUS_REACTOR_HTTP_EPOLL("reactor-http-epoll"),
- PROMETHEUS_REACTOR_HTTP_NIO("reactor-http-nio"),
- PROMETHEUS_BOUNDED_ELASTIC("boundedElastic-evictor"),
+ PROMETHEUS_REPORTER_HTTP("prometheus-reporter-http"),
Review Comment:
Addressed in 1198beaf5c by classifying the JDK HttpServer HTTP-Dispatcher
thread under the metrics module in addition to the configured worker threads.
##########
iotdb-core/metrics/interface/src/test/java/org/apache/iotdb/metrics/reporter/prometheus/PrometheusReporterTest.java:
##########
@@ -36,6 +38,31 @@
public class PrometheusReporterTest {
+ @Test
+ public void testMetricsEndpoint() throws Exception {
+ MetricConfig metricConfig =
MetricConfigDescriptor.getInstance().getMetricConfig();
+ boolean originalAsyncUpdate =
metricConfig.isPrometheusReporterAsyncUpdate();
+ Integer originalPort = metricConfig.getPrometheusReporterPort();
+ metricConfig.setPrometheusReporterAsyncUpdate(false);
+ metricConfig.setPrometheusReporterPort(0);
+
+ PrometheusReporter reporter = new PrometheusReporter(new
DoNothingMetricManager());
+ try {
+ assertTrue(reporter.start());
+ HttpURLConnection connection =
+ (HttpURLConnection)
+ new URL("http://127.0.0.1:" + reporter.getListeningPort() +
"/metrics")
+ .openConnection();
+ connection.setRequestMethod("GET");
+ assertEquals(200, connection.getResponseCode());
+ assertEquals("text/plain", connection.getHeaderField("Content-Type"));
Review Comment:
Added endpoint coverage for both unauthorized and authorized Basic-auth
requests in 1198beaf5c. TLS/mTLS setup still lacks a focused endpoint test
because the metrics-interface module currently has no certificate fixtures; the
JDK SSLContext path is exercised by compilation but not a handshake test in
this change.
--
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]