001package io.prometheus.metrics.config; 002 003import java.util.Map; 004 005/** 006 * Properties starting with io.prometheus.exporter.httpServer 007 */ 008public class ExporterHttpServerProperties { 009 010 // TODO: Not used yet, will be used when we port the simpleclient_httpserver module to the new data model. 011 012 private static final String PORT = "port"; 013 private final Integer port; 014 015 private ExporterHttpServerProperties(Integer port) { 016 this.port = port; 017 } 018 019 public Integer getPort() { 020 return port; 021 } 022 023 /** 024 * Note that this will remove entries from {@code properties}. 025 * This is because we want to know if there are unused properties remaining after all properties have been loaded. 026 */ 027 static ExporterHttpServerProperties load(String prefix, Map<Object, Object> properties) throws PrometheusPropertiesException { 028 Integer port = Util.loadInteger(prefix + "." + PORT, properties); 029 Util.assertValue(port, t -> t > 0, "Expecting value > 0", prefix, PORT); 030 return new ExporterHttpServerProperties(port); 031 } 032 033 public static Builder newBuilder() { 034 return new Builder(); 035 } 036 037 public static class Builder { 038 039 private Integer port; 040 041 public Builder withPort(int port) { 042 this.port = port; 043 return this; 044 } 045 046 public ExporterHttpServerProperties build() { 047 return new ExporterHttpServerProperties(port); 048 } 049 } 050}