-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Får metrikker over konsumenter og typer token som brukes. (#1341)
- Loading branch information
Showing
2 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
felles/oidc/src/main/java/no/nav/vedtak/sikkerhet/oidc/validator/ConsumerMetric.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package no.nav.vedtak.sikkerhet.oidc.validator; | ||
|
||
import static no.nav.vedtak.log.metrics.MetricsUtil.REGISTRY; | ||
|
||
import io.micrometer.core.instrument.Counter; | ||
import no.nav.vedtak.sikkerhet.kontekst.IdentType; | ||
import no.nav.vedtak.sikkerhet.oidc.config.OpenIDProvider; | ||
|
||
public class ConsumerMetric { | ||
|
||
private static final String FORELDREPENGER_KONSUMENTER = "foreldrepenger.konsumenter"; | ||
|
||
private ConsumerMetric() { | ||
} | ||
|
||
public static void registrer(String klientNavn, String konsument, OpenIDProvider tokenType, IdentType identType, String acrLevel) { | ||
counter(klientNavn, konsument, tokenType, identType, acrLevel).increment(); | ||
} | ||
public static void registrer(String klientNavn, String konsument, OpenIDProvider tokenType, IdentType identType) { | ||
counter(klientNavn, konsument, tokenType, identType, null).increment(); | ||
} | ||
|
||
private static Counter counter(String klientNavn, String konsument, OpenIDProvider tokenType, IdentType identType, String acrLevel) { | ||
var counter = Counter.builder(FORELDREPENGER_KONSUMENTER) | ||
.tag("klient", klientNavn) | ||
.tag("tokenType", tokenType.name()) | ||
.tag("identYype", identType.name()) | ||
.tag("konsument", konsument) | ||
.description("Konsument og token brukt."); | ||
|
||
if (acrLevel != null) { | ||
counter.tag("acrLevel", acrLevel); | ||
} | ||
return counter.register(REGISTRY); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters