Package io.prometheus.client.exporter
Class HTTPServer.Builder
java.lang.Object
io.prometheus.client.exporter.HTTPServer.Builder
- Enclosing class:
HTTPServer
We keep the original constructors of
HTTPServer
for compatibility, but new configuration
parameters like sampleNameFilter
must be configured using the Builder.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Authenticator
private boolean
private ExecutorService
private String
private HttpsConfigurator
private HttpServer
private InetAddress
private InetSocketAddress
private int
private CollectorRegistry
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
assertNull
(Object o, String msg) private void
assertZero
(int i, String msg) build()
Build the HTTPServerwithAuthenticator
(Authenticator authenticator) Optional:Authenticator
to use to support authentication.withDaemonThreads
(boolean daemon) By default, theHTTPServer
uses non-daemon threads.withExecutorService
(ExecutorService executorService) Optional: ExecutorService used by thehttpServer
.withHostname
(String hostname) Use this hostname to resolve the IP address to bind to.withHttpsConfigurator
(HttpsConfigurator configurator) Optional:HttpsConfigurator
to use to support TLS/SSLwithHttpServer
(HttpServer httpServer) Use this httpServer.withInetAddress
(InetAddress address) Bind to this IP address.withInetSocketAddress
(InetSocketAddress address) Listen on this address.withPort
(int port) Port to bind to.withRegistry
(CollectorRegistry registry) Optional: Default isCollectorRegistry.defaultRegistry
.withSampleNameFilter
(Predicate<String> sampleNameFilter) Optional: Only export time series wheresampleNameFilter.test(name)
returns true.withSampleNameFilterSupplier
(Supplier<Predicate<String>> sampleNameFilterSupplier) Optional: Only export time series wheresampleNameFilter.test(name)
returns true.
-
Field Details
-
port
private int port -
hostname
-
inetAddress
-
inetSocketAddress
-
httpServer
-
executorService
-
registry
-
daemon
private boolean daemon -
sampleNameFilter
-
sampleNameFilterSupplier
-
authenticator
-
httpsConfigurator
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
withPort
Port to bind to. Must not be called together withwithInetSocketAddress(InetSocketAddress)
orwithHttpServer(HttpServer)
. Default is 0, indicating that a random port will be selected. -
withHostname
Use this hostname to resolve the IP address to bind to. Must not be called together withwithInetAddress(InetAddress)
orwithInetSocketAddress(InetSocketAddress)
orwithHttpServer(HttpServer)
. Default is empty, indicating that the HTTPServer binds to the wildcard address. -
withInetAddress
Bind to this IP address. Must not be called together withwithHostname(String)
orwithInetSocketAddress(InetSocketAddress)
orwithHttpServer(HttpServer)
. Default is empty, indicating that the HTTPServer binds to the wildcard address. -
withInetSocketAddress
Listen on this address. Must not be called together withwithPort(int)
,withHostname(String)
,withInetAddress(InetAddress)
, orwithHttpServer(HttpServer)
. -
withHttpServer
Use this httpServer. ThehttpServer
is expected to already be bound to an address. Must not be called together withwithPort(int)
, orwithHostname(String)
, orwithInetAddress(InetAddress)
, orwithInetSocketAddress(InetSocketAddress)
, orwithExecutorService(ExecutorService)
. -
withExecutorService
Optional: ExecutorService used by thehttpServer
. Must not be called together with thewithHttpServer(HttpServer)
.- Parameters:
executorService
-- Returns:
-
withDaemonThreads
By default, theHTTPServer
uses non-daemon threads. Set this totrue
to run theHTTPServer
with daemon threads. -
withSampleNameFilter
Optional: Only export time series wheresampleNameFilter.test(name)
returns true.Use this if the sampleNameFilter remains the same throughout the lifetime of the HTTPServer. If the sampleNameFilter changes during runtime, use
withSampleNameFilterSupplier(Supplier)
. -
withSampleNameFilterSupplier
public HTTPServer.Builder withSampleNameFilterSupplier(Supplier<Predicate<String>> sampleNameFilterSupplier) Optional: Only export time series wheresampleNameFilter.test(name)
returns true.Use this if the sampleNameFilter may change during runtime, like for example if you have a hot reload mechanism for your filter config. If the sampleNameFilter remains the same throughout the lifetime of the HTTPServer, use
withSampleNameFilter(Predicate)
instead. -
withRegistry
Optional: Default isCollectorRegistry.defaultRegistry
. -
withAuthenticator
Optional:Authenticator
to use to support authentication. -
withHttpsConfigurator
Optional:HttpsConfigurator
to use to support TLS/SSL -
build
Build the HTTPServer- Throws:
IOException
-
assertNull
-
assertZero
-