Skip to content

Commit

Permalink
flyttet metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
janolaveide committed May 28, 2021
1 parent 724e1eb commit 2c4304d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
5 changes: 5 additions & 0 deletions felles/log/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@
<groupId>no.nav.foreldrepenger.felles</groupId>
<artifactId>felles-util</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.6.6</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package no.nav.vedtak.log.metrics;

import static io.micrometer.core.instrument.Metrics.globalRegistry;
import static io.micrometer.prometheus.PrometheusConfig.DEFAULT;

import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
import io.micrometer.prometheus.PrometheusMeterRegistry;

public class MetricsUtil {
public static final PrometheusMeterRegistry REGISTRY = new PrometheusMeterRegistry(DEFAULT);

static {
Metrics.addRegistry(REGISTRY);
new ClassLoaderMetrics().bindTo(globalRegistry);
new JvmMemoryMetrics().bindTo(globalRegistry);
new JvmGcMetrics().bindTo(globalRegistry);
new ProcessorMetrics().bindTo(globalRegistry);
new JvmThreadMetrics().bindTo(globalRegistry);
}

public static String scrape() {
return REGISTRY.scrape();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package no.nav.vedtak.felles.integrasjon.rest.jersey;

import static io.micrometer.core.instrument.Metrics.globalRegistry;
import static io.micrometer.prometheus.PrometheusConfig.DEFAULT;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.logging.Level.FINE;
Expand Down Expand Up @@ -44,10 +43,8 @@

import com.fasterxml.jackson.databind.ObjectMapper;

import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.httpcomponents.MicrometerHttpRequestExecutor;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import no.nav.foreldrepenger.konfig.Environment;
import no.nav.vedtak.exception.TekniskException;
import no.nav.vedtak.felles.integrasjon.rest.HttpRequestRetryHandler;
Expand Down Expand Up @@ -77,7 +74,6 @@ public abstract class AbstractJerseyRestClient {
private static final Environment ENV = Environment.current();

static {
Metrics.addRegistry(new PrometheusMeterRegistry(DEFAULT));
LogManager.getLogManager().reset();
SLF4JBridgeHandler.install();
}
Expand Down

0 comments on commit 2c4304d

Please sign in to comment.