Как передать @Value из файла yaml в Histogram.build (). Buckets?
Yaml: histogram_buckets: [0,05, 0,1, 0,25, 0,5, 1,0]
Код:
import org.springframework.beans.factory.annotation.value;
import org.springframework.stereotype.Component;
import io.prometheus.client.Histogram;
import io.prometheus.client.spring.boot.EnablePrometheusEndpoint;
import io.prometheus.client.spring.boot.EnableSpringBootMetricsCollector;
@EnablePrometheusEndpoint
@EnableSpringBootMetricsCollector
@Component
public class QueryStats {
@Value("${histogram_buckets}") private static double[] histogram_buckets;
private QueryStats(){}
public static final Histogram requestLatency = Histogram.build().buckets(histogram_buckets).name("request_time").help("time in servicing request").labelNames("service").register();
}
Консоль:
Вызвано: java.lang.NullPointerException: null at io.prometheus.client.Histogram $ Builder.create (Histogram.java:77) ~ [simpleclient-0.4.0.jar: na] at io.prometheus.client.Histogram $ Builder.create (Histogram.java:72) ~ [simpleclient-0.4.0.jar: na]