From 525e0914fa391307d00dfdd7301333d651153746 Mon Sep 17 00:00:00 2001 From: Sondre Larsen Ovrid Date: Wed, 11 Oct 2023 14:33:57 +0200 Subject: [PATCH] Revert "Utvid Spring MVC metrics med consumerId-tag" This reverts commit f202cfc10469bc0cf0663f8c22068ecbb8223a03. --- ...tomServerRequestObservationConvention.java | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/main/java/no/nav/veilarbperson/config/CustomServerRequestObservationConvention.java diff --git a/src/main/java/no/nav/veilarbperson/config/CustomServerRequestObservationConvention.java b/src/main/java/no/nav/veilarbperson/config/CustomServerRequestObservationConvention.java deleted file mode 100644 index aee8726a..00000000 --- a/src/main/java/no/nav/veilarbperson/config/CustomServerRequestObservationConvention.java +++ /dev/null @@ -1,32 +0,0 @@ -package no.nav.veilarbperson.config; - -import io.micrometer.common.KeyValue; -import io.micrometer.common.KeyValues; -import jakarta.servlet.http.HttpServletRequest; -import org.jetbrains.annotations.NotNull; -import org.springframework.http.server.observation.DefaultServerRequestObservationConvention; -import org.springframework.http.server.observation.ServerRequestObservationContext; -import org.springframework.stereotype.Component; - -import static java.util.Optional.ofNullable; - -@Component -public class CustomServerRequestObservationConvention extends DefaultServerRequestObservationConvention { - - @NotNull - @Override - public KeyValues getLowCardinalityKeyValues(@NotNull ServerRequestObservationContext context) { - return super - .getLowCardinalityKeyValues(context) - .and(consumerId(context)); - } - - protected KeyValue consumerId(ServerRequestObservationContext context) { - HttpServletRequest httpRequest = context.getCarrier(); - String consumerId = ofNullable(httpRequest.getHeader("Nav-Consumer-Id")) - .filter(v -> !v.isBlank()) - .orElse("unknown"); - - return KeyValue.of("consumerId", consumerId); - } -}