Skip to content

Commit

Permalink
Rename metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
naviktthomas committed Aug 13, 2024
1 parent d9eca8a commit b83fbc8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import java.util.concurrent.atomic.AtomicLong

fun MeterRegistry.tellMottatteOpplysninger() {
counter(
"paw_antall_mottatte_events_total",
"paw_antall_mottatte_meldinger_total",
Tags.of(
Tag.of("event", "opplysninger-om-arbeidssoeker")
Tag.of("meldingstype", "opplysninger-om-arbeidssoeker")
)
).increment()
}

fun MeterRegistry.antallLagredeOpplysningerTotal(antallReference: AtomicLong) {
gauge(
"paw_antall_lagrede_events",
"paw_antall_lagrede_meldinger",
Tags.of(
Tag.of("event", "opplysninger-om-arbeidssoeker")
Tag.of("meldingstype", "opplysninger-om-arbeidssoeker")
),
antallReference
) {
Expand All @@ -31,10 +31,10 @@ fun MeterRegistry.antallLagredeOpplysningerTotal(antallReference: AtomicLong) {
fun MeterRegistry.antallLagredeOpplysningerSumPerPeriode(timestamp: Instant, antallReference: AtomicLong) {
val zonedDateTime = timestamp.atZone(ZoneId.systemDefault())
gauge(
"paw_antall_lagrede_events_sum_per_tidsperiode",
"paw_antall_lagrede_meldinger_sum_per_tidsperiode",
Tags.of(
Tag.of("event", "opplysninger-om-arbeidssoeker"),
Tag.of("minute", "${zonedDateTime.minute}")
Tag.of("meldingstype", "opplysninger-om-arbeidssoeker"),
Tag.of("minutt", "${zonedDateTime.minute}")
),
antallReference
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ private fun buildPunctuation(meterRegistry: MeterRegistry): Punctuation<Long, Op
histogram.tellAntall(opplysninger.periodeId)
}

histogram.forEach { (_, antall) -> meterRegistry.antallLagredeOpplysningerSumPerPeriode(timestamp, antall) }
meterRegistry.antallLagredeOpplysningerTotal(antallTotalt)
histogram.forEach { (_, antall) -> meterRegistry.antallLagredeOpplysningerSumPerPeriode(timestamp, antall) }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ class OpplysningerKStreamTest : FreeSpec({
valueAndTimestamp.value().sendtInnAv.utfoertAv.id shouldBe opplysninger.sendtInnAv.utfoertAv.id
}

"Skal slette opplysninger etter 60 minutter" {
testDriver.advanceWallClockTime(Duration.ofMinutes(65)) // 60 min++
"Skal ikke slette opplysninger etter 50 minutter" {
testDriver.advanceWallClockTime(Duration.ofMinutes(50))

stateStore.size() shouldBe 1
}

"Skal slette opplysninger etter 61 minutter" {
testDriver.advanceWallClockTime(Duration.ofMinutes(11))

stateStore.size() shouldBe 0
}
Expand Down

0 comments on commit b83fbc8

Please sign in to comment.