Skip to content

Commit

Permalink
metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
janolaveide committed May 26, 2021
1 parent 6bb9988 commit 337af5d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpContext;

import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.binder.httpcomponents.PoolingHttpClientConnectionManagerMetricsBinder;
import no.nav.vedtak.felles.integrasjon.rest.jersey.AbstractJerseyRestClient;
import no.nav.vedtak.felles.integrasjon.rest.jersey.HeaderLoggingRequestInterceptor;
import no.nav.vedtak.felles.integrasjon.rest.jersey.HeaderLoggingResponseInterceptor;

Expand Down Expand Up @@ -130,7 +130,7 @@ public static PoolingHttpClientConnectionManager connectionManager() {
connManager.setMaxTotal(100);
connManager.setDefaultConnectionConfig(defaultConnectionConfig);
connManager.setValidateAfterInactivity(100);
new PoolingHttpClientConnectionManagerMetricsBinder(connManager, "jersey-pool").bindTo(AbstractJerseyRestClient.REGISTRY);
new PoolingHttpClientConnectionManagerMetricsBinder(connManager, "jersey-pool").bindTo(Metrics.globalRegistry);
return connManager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@
*/
public abstract class AbstractJerseyRestClient {

public static final PrometheusMeterRegistry REGISTRY = new PrometheusMeterRegistry(DEFAULT);
private static final Environment ENV = Environment.current();

static {
Metrics.addRegistry(REGISTRY);
Metrics.addRegistry(new PrometheusMeterRegistry(DEFAULT));
LogManager.getLogManager().reset();
SLF4JBridgeHandler.install();
}
Expand Down Expand Up @@ -119,7 +118,7 @@ private AbstractJerseyRestClient(URI proxy, Set<? extends ClientRequestFilter> f
.setDefaultRequestConfig(defaultRequestConfig())
.setRetryHandler(new HttpRequestRetryHandler())
.setRequestExecutor(MicrometerHttpRequestExecutor
.builder(REGISTRY)
.builder(Metrics.globalRegistry)
.build())
.setConnectionManager(connectionManager());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.Tags;
import io.micrometer.core.instrument.binder.jvm.ExecutorServiceMetrics;
import no.nav.security.token.support.core.context.TokenValidationContext;
Expand All @@ -44,7 +45,7 @@ static class PropagatingThreadPoolExecutor extends ThreadPoolExecutor {
PropagatingThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory, RejectedExecutionHandler handler) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
new ExecutorServiceMetrics(this, getClass().getSimpleName(), Tags.empty()).bindTo(AbstractJerseyRestClient.REGISTRY);
new ExecutorServiceMetrics(this, getClass().getSimpleName(), Tags.empty()).bindTo(Metrics.globalRegistry);
}

@Override
Expand Down

0 comments on commit 337af5d

Please sign in to comment.