Skip to content

Commit

Permalink
Load PrometheusProperties at registry initialization
Browse files Browse the repository at this point in the history
Previously, the loading would happen when the classloader did static initialization on PrometheusProperties, which means the properties loading could have happened before the construction of the specific PrometheusMeterRegistry instance and not contain any changes between then.
  • Loading branch information
shakuzen committed Apr 1, 2024
1 parent 58d72bd commit b3cc212
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
import io.micrometer.core.instrument.internal.DefaultGauge;
import io.micrometer.core.instrument.internal.DefaultMeter;
import io.micrometer.core.instrument.util.TimeUtils;
import io.prometheus.metrics.config.ExporterProperties;
import io.prometheus.metrics.config.PrometheusProperties;
import io.prometheus.metrics.config.PrometheusPropertiesLoader;
import io.prometheus.metrics.expositionformats.ExpositionFormats;
import io.prometheus.metrics.model.registry.PrometheusRegistry;
import io.prometheus.metrics.model.snapshots.*;
Expand Down Expand Up @@ -67,9 +66,8 @@
*/
public class PrometheusMeterRegistry extends MeterRegistry {

private final ExporterProperties exporterProperties = PrometheusProperties.get().getExporterProperties();

private final ExpositionFormats expositionFormats = ExpositionFormats.init(exporterProperties);
private final ExpositionFormats expositionFormats = ExpositionFormats
.init(PrometheusPropertiesLoader.load().getExporterProperties());

private final PrometheusConfig prometheusConfig;

Expand Down

0 comments on commit b3cc212

Please sign in to comment.