Skip to content

Commit

Permalink
Prøver å bevare spans i korutiner (#2555)
Browse files Browse the repository at this point in the history
  • Loading branch information
tendestad authored Aug 27, 2024
1 parent 2f7bac3 commit 2d1a6b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/main/kotlin/no/nav/k9/los/eventhandler/RefreshK9.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package no.nav.k9.los.eventhandler

import io.opentelemetry.api.trace.Span
import io.opentelemetry.extension.kotlin.asContextElement
import io.opentelemetry.instrumentation.annotations.WithSpan
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import no.nav.k9.los.domene.lager.oppgave.v2.TransactionalManager
import no.nav.k9.los.integrasjon.k9.IK9SakService
import no.nav.k9.los.nyoppgavestyring.visningoguttrekk.OppgaveRepository
import org.slf4j.LoggerFactory
import java.util.*
import java.util.concurrent.Executors
import kotlin.coroutines.coroutineContext

class RefreshK9(
val k9SakService: IK9SakService,
Expand Down Expand Up @@ -67,6 +71,8 @@ class RefreshK9(
}

private suspend fun refreshK9(oppgaveListe: List<UUID>) {
k9SakService.refreshBehandlinger(oppgaveListe)
withContext(coroutineContext + Span.current().asContextElement()) {
k9SakService.refreshBehandlinger(oppgaveListe)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package no.nav.k9.los.eventhandler

import io.opentelemetry.api.trace.Span
import io.opentelemetry.extension.kotlin.asContextElement
import io.opentelemetry.instrumentation.annotations.WithSpan
import kotlinx.coroutines.runBlocking
import kotliquery.TransactionalSession
Expand All @@ -14,7 +16,6 @@ import no.nav.k9.los.nyoppgavestyring.mottak.oppgave.AktivOppgaveRepository
import no.nav.k9.los.nyoppgavestyring.query.Avgrensning
import no.nav.k9.los.nyoppgavestyring.query.OppgaveQueryService
import no.nav.k9.los.nyoppgavestyring.query.QueryRequest
import no.nav.k9.los.utils.OpentelemetrySpanUtil
import org.slf4j.LoggerFactory
import java.util.*

Expand Down Expand Up @@ -66,7 +67,7 @@ class RefreshK9v3Tjeneste(
}

DetaljerMetrikker.time("RefreshK9V3", "refreshForKøer", "k9SakService") {
runBlocking {
runBlocking (Span.current().asContextElement()) {
k9SakService.refreshBehandlinger(behandlinger)
}
}
Expand Down

0 comments on commit 2d1a6b2

Please sign in to comment.