Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/timestamp #397

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package no.nav.syfo.application
import io.opentelemetry.api.trace.Span
import io.opentelemetry.instrumentation.annotations.WithSpan
import java.io.StringReader
import java.time.Instant
import java.time.LocalDateTime
import java.time.OffsetTime
import java.time.ZoneOffset
import java.util.*
import javax.jms.Message
Expand Down Expand Up @@ -40,6 +42,7 @@ import no.nav.syfo.handlestatus.handleVirksomhetssykmeldingOgFnrManglerIHPR
import no.nav.syfo.handlestatus.handleVirksomhetssykmeldingOgHprMangler
import no.nav.syfo.logger
import no.nav.syfo.metrics.INCOMING_MESSAGE_COUNTER
import no.nav.syfo.metrics.INCOMING_MESSAGE_DELAY
import no.nav.syfo.metrics.REQUEST_TIME
import no.nav.syfo.metrics.SYKMELDING_MISSNG_ORG_NUMBER_COUNTER
import no.nav.syfo.metrics.SYKMELDING_VEDLEGG_COUNTER
Expand Down Expand Up @@ -116,7 +119,10 @@ class BlockingApplicationRunner(
delay(100)
continue
}
val messageTimestamp =
OffsetTime.ofInstant(Instant.ofEpochMilli(message.jmsTimestamp), ZoneOffset.UTC)

logger.info("Received message with timestamp {}", messageTimestamp)
processMqMessage(message)
}
}
Expand All @@ -135,6 +141,10 @@ class BlockingApplicationRunner(
)
}
INCOMING_MESSAGE_COUNTER.inc()
val now = Instant.now().toEpochMilli()
val delay = now - message.jmsTimestamp
INCOMING_MESSAGE_DELAY.observe(delay / 1000.0)

val requestLatency = REQUEST_TIME.startTimer()
val fellesformat = safeUnmarshal(inputMessageText)

Expand Down
8 changes: 8 additions & 0 deletions src/main/kotlin/no/nav/syfo/metrics/MetricRegistry.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package no.nav.syfo.metrics

import io.prometheus.client.Counter
import io.prometheus.client.Histogram
import io.prometheus.client.Summary

const val METRICS_NS = "syfosmmottak"

val INCOMING_MESSAGE_DELAY: Histogram =
Histogram.build()
.namespace(METRICS_NS)
.name("incoming_message_delay")
.help("Delay in incoming messages.")
.register()

val REQUEST_TIME: Summary =
Summary.build()
.namespace(METRICS_NS)
Expand Down
Loading