kopia lustrzana https://github.com/onthegomap/planetiler
prometheus static factory method
rodzic
b6e0346b62
commit
4af6d1707b
|
@ -1,7 +1,6 @@
|
|||
package com.onthegomap.flatmap.config;
|
||||
|
||||
import com.onthegomap.flatmap.geo.GeoUtils;
|
||||
import com.onthegomap.flatmap.stats.PrometheusStats;
|
||||
import com.onthegomap.flatmap.stats.Stats;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
@ -130,7 +129,7 @@ public class Arguments {
|
|||
LOGGER.info("Using prometheus push gateway stats");
|
||||
String job = get("pushgateway.job", "prometheus pushgateway job ID", "flatmap");
|
||||
Duration interval = duration("pushgateway.interval", "how often to send stats to prometheus push gateway", "15s");
|
||||
return new PrometheusStats(prometheus, job, interval);
|
||||
return Stats.prometheusPushGateway(prometheus, job, interval);
|
||||
} else {
|
||||
LOGGER.info("Using in-memory stats");
|
||||
return Stats.inMemory();
|
||||
|
|
|
@ -47,7 +47,7 @@ public class PrometheusStats implements Stats {
|
|||
private final Map<String, MemoryEstimator.HasEstimate> heapObjectsToMonitor = Collections
|
||||
.synchronizedMap(new LinkedHashMap<>());
|
||||
|
||||
public PrometheusStats(String job) {
|
||||
PrometheusStats(String job) {
|
||||
this.job = job;
|
||||
DefaultExports.register(registry);
|
||||
new ThreadDetailsExports().register(registry);
|
||||
|
@ -57,7 +57,7 @@ public class PrometheusStats implements Stats {
|
|||
new PostGcMemoryCollector().register(registry);
|
||||
}
|
||||
|
||||
public PrometheusStats(String destination, String job, Duration interval) {
|
||||
PrometheusStats(String destination, String job, Duration interval) {
|
||||
this(job);
|
||||
try {
|
||||
URL url = new URL(destination);
|
||||
|
|
|
@ -4,6 +4,7 @@ import static io.prometheus.client.Collector.NANOSECONDS_PER_SECOND;
|
|||
|
||||
import com.onthegomap.flatmap.util.MemoryEstimator;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -55,6 +56,10 @@ public interface Stats extends AutoCloseable {
|
|||
return new InMemory();
|
||||
}
|
||||
|
||||
static Stats prometheusPushGateway(String destination, String job, Duration interval) {
|
||||
return new PrometheusStats(destination, job, interval);
|
||||
}
|
||||
|
||||
class InMemory implements Stats {
|
||||
|
||||
private final Timers timers = new Timers();
|
||||
|
|
Ładowanie…
Reference in New Issue