@@ -36,6 +36,10 @@ public static PrometheusProperties get() throws PrometheusPropertiesException {
3636 return instance ;
3737 }
3838
39+ public static Builder builder () {
40+ return new Builder ();
41+ }
42+
3943 public PrometheusProperties (
4044 MetricsProperties defaultMetricsProperties ,
4145 Map <String , MetricsProperties > metricProperties ,
@@ -95,4 +99,78 @@ public ExporterPushgatewayProperties getExporterPushgatewayProperties() {
9599 public ExporterOpenTelemetryProperties getExporterOpenTelemetryProperties () {
96100 return exporterOpenTelemetryProperties ;
97101 }
102+
103+ public static class Builder {
104+ private MetricsProperties defaultMetricsProperties ;
105+ private Map <String , MetricsProperties > metricProperties = new HashMap <>();
106+ private ExemplarsProperties exemplarProperties ;
107+ private ExporterProperties exporterProperties ;
108+ private ExporterFilterProperties exporterFilterProperties ;
109+ private ExporterHttpServerProperties httpServerConfig ;
110+ private ExporterPushgatewayProperties pushgatewayProperties ;
111+ private ExporterOpenTelemetryProperties otelConfig ;
112+
113+ private Builder () {}
114+
115+ public Builder defaultMetricsProperties (MetricsProperties defaultMetricsProperties ) {
116+ this .defaultMetricsProperties = defaultMetricsProperties ;
117+ return this ;
118+ }
119+
120+ public Builder metricProperties (Map <String , MetricsProperties > metricProperties ) {
121+ this .metricProperties = metricProperties ;
122+ return this ;
123+ }
124+
125+ /** Convenience for adding a single named MetricsProperties */
126+ public Builder putMetricProperty (String name , MetricsProperties props ) {
127+ this .metricProperties .put (name , props );
128+ return this ;
129+ }
130+
131+ public Builder exemplarProperties (ExemplarsProperties exemplarProperties ) {
132+ this .exemplarProperties = exemplarProperties ;
133+ return this ;
134+ }
135+
136+ public Builder exporterProperties (ExporterProperties exporterProperties ) {
137+ this .exporterProperties = exporterProperties ;
138+ return this ;
139+ }
140+
141+ public Builder exporterFilterProperties (ExporterFilterProperties exporterFilterProperties ) {
142+ this .exporterFilterProperties = exporterFilterProperties ;
143+ return this ;
144+ }
145+
146+ public Builder httpServerConfig (ExporterHttpServerProperties httpServerConfig ) {
147+ this .httpServerConfig = httpServerConfig ;
148+ return this ;
149+ }
150+
151+ public Builder pushgatewayProperties (ExporterPushgatewayProperties pushgatewayProperties ) {
152+ this .pushgatewayProperties = pushgatewayProperties ;
153+ return this ;
154+ }
155+
156+ public Builder otelConfig (ExporterOpenTelemetryProperties otelConfig ) {
157+ this .otelConfig = otelConfig ;
158+ return this ;
159+ }
160+
161+ public PrometheusProperties build () {
162+ return new PrometheusProperties (
163+ defaultMetricsProperties ,
164+ metricProperties ,
165+ exemplarProperties ,
166+ exporterProperties ,
167+ exporterFilterProperties ,
168+ httpServerConfig ,
169+ pushgatewayProperties ,
170+ otelConfig
171+ );
172+ }
173+
174+ }
175+
98176}
0 commit comments