Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start Prometheus HTTP server on the provided executor #955

Merged
merged 4 commits into from
May 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import com.sun.net.httpserver.HttpServer;
import com.sun.net.httpserver.HttpsConfigurator;
import com.sun.net.httpserver.HttpsServer;
import io.prometheus.metrics.config.ExporterHttpServerProperties;
import io.prometheus.metrics.config.PrometheusProperties;
import io.prometheus.metrics.model.registry.PrometheusRegistry;

import java.io.Closeable;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.SynchronousQueue;
Expand Down Expand Up @@ -55,7 +55,13 @@ private HTTPServer(PrometheusProperties config, ExecutorService executorService,
registerHandler("/", defaultHandler == null ? new DefaultHandler() : defaultHandler, authenticator);
registerHandler("/metrics", new MetricsHandler(config, registry), authenticator);
registerHandler("/-/healthy", new HealthyHandler(), authenticator);
this.server.start();
try {
executorService.submit(() -> this.server.start()).get();
mberndt123 marked this conversation as resolved.
Show resolved Hide resolved
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e.getCause());
mberndt123 marked this conversation as resolved.
Show resolved Hide resolved
}
}

private void registerHandler(String path, HttpHandler handler, Authenticator authenticator) {
Expand Down