Skip to content

Commit

Permalink
Adding traceId to audit.
Browse files Browse the repository at this point in the history
  • Loading branch information
flexable777 committed Feb 13, 2025
1 parent c7415f1 commit db3d7b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/no/nav/klage/oppgave/domain/OurRevision.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ class OurRevision(
var timestamp: LocalDateTime?,
var actor: String,
var request: String?,
@Column(name = "trace_id")
var traceId: String?,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.klage.oppgave.eventlisteners

import io.opentelemetry.api.trace.Span
import no.nav.klage.oppgave.domain.OurRevision
import no.nav.klage.oppgave.util.TokenUtil
import no.nav.klage.oppgave.util.getLogger
Expand Down Expand Up @@ -34,6 +35,7 @@ class OurRevisionListener(
} else {
revisionEntity.actor = systembrukerIdent
}
revisionEntity.traceId = Span.current().spanContext.traceId
} catch (e: Exception) {
logger.warn("Failed to set correct actor and/or request on revision entity. Setting 'unknown'.", e)
revisionEntity.actor = "unknown"
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/db/migration/V189__add_audit_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ create table klage.revision
id bigint not null,
actor text,
request text,
trace_id text,
timestamp timestamp,
primary key (id)
);
Expand Down

0 comments on commit db3d7b8

Please sign in to comment.