Skip to content

Commit

Permalink
Mulighet til å konfigurere hvilke endepunkt man skal lage metrikker med
Browse files Browse the repository at this point in the history
  • Loading branch information
stigebil committed Apr 18, 2024
1 parent e60e612 commit 308f86d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
class TellAPIEndepunkterIBrukInitialiserer(
@Value("\${NAIS_APP_NAME}") private val applicationName: String,
private val applicationContext: ApplicationContext,
@Value("\${familie.tellAPIEndepunkterIBruk.paths:/api}") private val pathStartWidth: List<String>,
) {
init {
metrikker.clear()
Expand All @@ -30,7 +31,7 @@ class TellAPIEndepunkterIBrukInitialiserer(

requestMappings.forEach { (info, handler) ->
info.patternValues.forEach { path ->
if (path.startsWith("/api")) {
if (pathStartWidth.any { path.startsWith(it) }) {
val metrikknavn = "$applicationName.${info.methodsCondition}$path".tilMetrikknavn()
val key = "${info.methodsCondition}$path"
metrikker.put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import org.springframework.web.servlet.HandlerMapping
/**
* Sett property familie.tellAPIEndepunkterIBruk: true i application.yaml for å skru
* på metrikker for hvor mange ganger et endepunkt har blitt kalt
*
* For å konfigurere andre endepunkter enn de som starter på /api så kan man bruke
* familie.tellAPIEndepunkterIBruk.paths: /foo,/bar
*
*/
@Component
@ConditionalOnProperty("familie.tellAPIEndepunkterIBruk")
Expand Down

0 comments on commit 308f86d

Please sign in to comment.