Skip to content

Commit

Permalink
eksponerer konfigurering av timersConfig/mdcEntries
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsteinsland committed Nov 25, 2024
1 parent 0d9fee2 commit 513dbfb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/kotlin/no/nav/helse/rapids_rivers/RapidApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import io.micrometer.core.instrument.Clock
import io.micrometer.core.instrument.MeterRegistry
import io.micrometer.core.instrument.MultiGauge
import io.micrometer.core.instrument.Tags
import io.micrometer.core.instrument.Timer
import io.micrometer.prometheusmetrics.PrometheusConfig
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
import io.prometheus.metrics.model.registry.PrometheusRegistry
Expand Down Expand Up @@ -196,6 +197,8 @@ class RapidApplication internal constructor(
private var callIdHeader: String = "callId"
private val isAliveChecks = mutableSetOf<() -> Boolean>(rapid::isRunning)
private val isReadyChecks = mutableSetOf<() -> Boolean>(rapid::isReady)
private var timersConfig: Timer.Builder.(ApplicationCall, Throwable?) -> Unit = { _, _ -> }
private var mdcEntries: Map<String, (ApplicationCall) -> String?> = emptyMap()

fun withHttpPort(httpPort: Int) = apply {
this.httpPort = httpPort
Expand All @@ -213,6 +216,14 @@ class RapidApplication internal constructor(
this.statusPagesConfig = statusPagesConfig
}

fun withTimersConfig(timersConfig: Timer.Builder.(ApplicationCall, Throwable?) -> Unit) = apply {
this.timersConfig = timersConfig
}

fun withMdcEntries(mdcEntries: Map<String, (ApplicationCall) -> String?>) = apply {
this.mdcEntries = mdcEntries
}

fun withCallIdHeader(headerName: String) = apply {
callIdHeader = headerName
}
Expand Down Expand Up @@ -263,6 +274,8 @@ class RapidApplication internal constructor(
preStopHook = stopHook::handlePreStopRequest,
cioConfiguration = cioConfiguration,
statusPagesConfig = statusPagesConfig,
timersConfig = timersConfig,
mdcEntries = mdcEntries,
applicationModule = {
modules.forEach { it() }

Expand Down

0 comments on commit 513dbfb

Please sign in to comment.