Skip to content

Commit

Permalink
micrometer
Browse files Browse the repository at this point in the history
  • Loading branch information
janolaveide committed May 25, 2021
1 parent c7fcb36 commit 3b7a281
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;

import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.binder.httpcomponents.MicrometerHttpRequestExecutor;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import no.nav.foreldrepenger.konfig.Environment;
Expand Down Expand Up @@ -70,9 +71,11 @@
*/
public abstract class AbstractJerseyRestClient {

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

static {
Metrics.addRegistry(REGISTRY);
LogManager.getLogManager().reset();
SLF4JBridgeHandler.install();
}
Expand All @@ -82,7 +85,6 @@ public abstract class AbstractJerseyRestClient {
public static final String NAV_CONSUMER_TOKEN_HEADER = "Nav-Consumer-Token";
public static final String DEFAULT_NAV_CALLID = "Nav-Callid";
public static final String ALT_NAV_CALL_ID = "nav-call-id";

public static final String HEADER_CORRELATION_ID = "X-Correlation-ID";

private static final Logger LOG = LoggerFactory.getLogger(AbstractJerseyRestClient.class);
Expand All @@ -109,23 +111,21 @@ private AbstractJerseyRestClient(URI proxy, Set<? extends ClientRequestFilter> f
Optional.ofNullable(proxy)
.ifPresent(p -> cfg.property(PROXY_URI, p));
cfg.register(jacksonProvider(MAPPER));

cfg.connectorProvider(new ApacheConnectorProvider());
cfg.register((ApacheHttpClientBuilderConfigurator) (b) -> {
return b.addInterceptorFirst(new StandardHeadersRequestInterceptor())
.setKeepAliveStrategy(createKeepAliveStrategy(30))
.setDefaultRequestConfig(defaultRequestConfig())
.setRetryHandler(new HttpRequestRetryHandler())
.setRequestExecutor(MicrometerHttpRequestExecutor
.builder(new PrometheusMeterRegistry(DEFAULT))
.builder(REGISTRY)
.build())
.setConnectionManager(connectionManager());
});
filters.stream().forEach(f -> {
LOG.info("Registrer filter {}", f.getClass());
cfg.register(f);
});

cfg.register(ErrorResponseHandlingClientResponseFilter.class);
if (ENV.isDev()) {
cfg.register(new HeaderLoggingFilter())
Expand Down

0 comments on commit 3b7a281

Please sign in to comment.