Class PrometheusHttpServerBuilder

java.lang.Object
io.opentelemetry.exporter.prometheus.PrometheusHttpServerBuilder

public final class PrometheusHttpServerBuilder extends Object
A builder for PrometheusHttpServer.
  • Method Details

    • setHost

      public PrometheusHttpServerBuilder setHost(String host)
      Sets the host to bind to. If unset, defaults to "0.0.0.0".
    • setPort

      public PrometheusHttpServerBuilder setPort(int port)
      Sets the port to bind to. If unset, defaults to 9464.
    • setExecutor

      public PrometheusHttpServerBuilder setExecutor(ExecutorService executor)
      Sets the ExecutorService to be used for PrometheusHttpServer.
    • setPrometheusRegistry

      public PrometheusHttpServerBuilder setPrometheusRegistry(io.prometheus.metrics.model.registry.PrometheusRegistry prometheusRegistry)
      Sets the PrometheusRegistry to be used for PrometheusHttpServer.
    • setOtelScopeEnabled

      public PrometheusHttpServerBuilder setOtelScopeEnabled(boolean otelScopeEnabled)
      Set if the otel_scope_* attributes are generated. Default is true.
    • setAllowedResourceAttributesFilter

      public PrometheusHttpServerBuilder setAllowedResourceAttributesFilter(Predicate<String> resourceAttributesFilter)
      Set if the resource attributes should be added as labels on each exported metric.

      If set, resource attributes will be added as labels on each exported metric if their key tests positive (true) when passed through resourceAttributesFilter.

      Parameters:
      resourceAttributesFilter - a predicate that returns true if the resource attribute should be added as a label on each exported metric. The predicates input is the resource attribute key.
    • build

      public PrometheusHttpServer build()
      Returns a new PrometheusHttpServer with the configuration of this builder which can be registered with a SdkMeterProvider.