diff --git a/build.gradle.kts b/build.gradle.kts index 532d6aa..86583ce 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,9 +40,6 @@ dependencies { implementation("com.zaxxer:HikariCP") implementation("org.postgresql:postgresql") - implementation("io.micrometer:micrometer-registry-prometheus") - implementation("io.micrometer:micrometer-tracing-bridge-brave") - implementation("ch.qos.logback:logback-classic") implementation("net.logstash.logback:logstash-logback-encoder:$logstashVersion") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.17.1") diff --git a/deploy/nais.yaml b/deploy/nais.yaml index 434ca63..6e22353 100644 --- a/deploy/nais.yaml +++ b/deploy/nais.yaml @@ -48,17 +48,17 @@ spec: timeout: 1 resources: limits: - memory: 1024Mi + memory: 2024Mi requests: - cpu: 40m - memory: 256Mi + cpu: 80m + memory: 1024Mi ingresses: {{#each ingresses as |ingress|}} - {{ingress}} {{/each}} replicas: - min: 2 - max: 4 + min: 1 + max: 3 cpuThresholdPercentage: 80 prometheus: enabled: true diff --git a/src/main/kotlin/no/nav/klage/document/api/DocumentController.kt b/src/main/kotlin/no/nav/klage/document/api/DocumentController.kt index 1681dd0..599a5cf 100644 --- a/src/main/kotlin/no/nav/klage/document/api/DocumentController.kt +++ b/src/main/kotlin/no/nav/klage/document/api/DocumentController.kt @@ -7,6 +7,7 @@ import no.nav.klage.document.api.views.DocumentVersionView import no.nav.klage.document.api.views.DocumentView import no.nav.klage.document.config.SecurityConfiguration.Companion.ISSUER_AAD import no.nav.klage.document.domain.DocumentVersion +import no.nav.klage.document.domain.ShortDocumentVersion import no.nav.klage.document.service.DocumentService import no.nav.klage.document.util.TokenUtil import no.nav.klage.document.util.getLogger @@ -132,7 +133,7 @@ class DocumentController( modified = documentVersion.modified ) - private fun mapToDocumentVersionView(documentVersion: DocumentVersion): DocumentVersionView = + private fun mapToDocumentVersionView(documentVersion: ShortDocumentVersion): DocumentVersionView = DocumentVersionView( documentId = documentVersion.documentId, version = documentVersion.version, diff --git a/src/main/kotlin/no/nav/klage/document/config/CustomTraceFilter.kt b/src/main/kotlin/no/nav/klage/document/config/CustomTraceFilter.kt deleted file mode 100644 index 08ee1c2..0000000 --- a/src/main/kotlin/no/nav/klage/document/config/CustomTraceFilter.kt +++ /dev/null @@ -1,36 +0,0 @@ -package no.nav.klage.document.config - -import io.micrometer.tracing.Tracer -import jakarta.servlet.FilterChain -import jakarta.servlet.ServletRequest -import jakarta.servlet.ServletResponse -import org.springframework.beans.factory.annotation.Value -import org.springframework.context.annotation.Profile -import org.springframework.core.annotation.Order -import org.springframework.stereotype.Component -import org.springframework.web.filter.GenericFilterBean - -/** - * Adding some custom NAV-specific attributes to standard Spring Sleuth/Micrometer - */ -@Component -@Profile("!local") -@Order(-20) -class CustomTraceFilter( - private val tracer: Tracer, - @Value("\${navCallIdName}") private val navCallIdName: String, -) : GenericFilterBean() { - - override fun doFilter( - request: ServletRequest?, response: ServletResponse, - chain: FilterChain - ) { - //Create if not exists - tracer.createBaggageInScope(navCallIdName, tracer.currentTraceContext().context()!!.traceId()) - - //also add this, since some services require that version/spelling - tracer.createBaggageInScope("Nav-Call-Id", tracer.currentTraceContext().context()!!.traceId()) - - chain.doFilter(request, response) - } -} \ No newline at end of file diff --git a/src/main/kotlin/no/nav/klage/document/domain/DocumentVersion.kt b/src/main/kotlin/no/nav/klage/document/domain/DocumentVersion.kt index 997ca57..45f4e8f 100644 --- a/src/main/kotlin/no/nav/klage/document/domain/DocumentVersion.kt +++ b/src/main/kotlin/no/nav/klage/document/domain/DocumentVersion.kt @@ -43,5 +43,16 @@ class DocumentVersion( return "DocumentVersion(documentId=$documentId, version=$version, json='$json', data=$data, created=$created, modified=$modified, authorNavIdent='$authorNavIdent')" } - } + +/** + * Using this when we don't need the full DocumentVersion object, just a subset of the fields. + * Otherwise, we would have to fetch the full object from the database and that's too much data. + */ +data class ShortDocumentVersion( + val documentId: UUID, + val version: Int, + val authorNavIdent: String, + val created: LocalDateTime, + val modified: LocalDateTime, +) diff --git a/src/main/kotlin/no/nav/klage/document/repositories/DocumentVersionRepository.kt b/src/main/kotlin/no/nav/klage/document/repositories/DocumentVersionRepository.kt index 9f423bc..8306064 100644 --- a/src/main/kotlin/no/nav/klage/document/repositories/DocumentVersionRepository.kt +++ b/src/main/kotlin/no/nav/klage/document/repositories/DocumentVersionRepository.kt @@ -2,12 +2,24 @@ package no.nav.klage.document.repositories import no.nav.klage.document.domain.DocumentVersion import no.nav.klage.document.domain.DocumentVersionId +import no.nav.klage.document.domain.ShortDocumentVersion import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.data.jpa.repository.Query import java.util.* interface DocumentVersionRepository : JpaRepository { fun findByDocumentId(documentId: UUID): List + @Query( + """ + SELECT new no.nav.klage.document.domain.ShortDocumentVersion(documentId, version, authorNavIdent, created, modified) + FROM DocumentVersion + WHERE documentId = :documentId + ORDER BY version + """ + ) + fun findVersionsByDocumentId(documentId: UUID): List + fun deleteByDocumentId(documentId: UUID) } \ No newline at end of file diff --git a/src/main/kotlin/no/nav/klage/document/service/DocumentService.kt b/src/main/kotlin/no/nav/klage/document/service/DocumentService.kt index b599aa6..dab71d2 100644 --- a/src/main/kotlin/no/nav/klage/document/service/DocumentService.kt +++ b/src/main/kotlin/no/nav/klage/document/service/DocumentService.kt @@ -3,6 +3,7 @@ package no.nav.klage.document.service import no.nav.klage.document.domain.Document import no.nav.klage.document.domain.DocumentVersion import no.nav.klage.document.domain.DocumentVersionId +import no.nav.klage.document.domain.ShortDocumentVersion import no.nav.klage.document.repositories.CommentRepository import no.nav.klage.document.repositories.DocumentRepository import no.nav.klage.document.repositories.DocumentVersionRepository @@ -113,8 +114,8 @@ class DocumentService( documentRepository.deleteById(documentId) } - fun getDocumentVersions(documentId: UUID): List { - return documentVersionRepository.findByDocumentId(documentId = documentId).sortedBy { it.version } + fun getDocumentVersions(documentId: UUID): List { + return documentVersionRepository.findVersionsByDocumentId(documentId = documentId) } } \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 2068f50..713215d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,14 +3,6 @@ spring: name: kabal-smart-editor-api main: banner-mode: OFF - sleuth: - baggage: - remote-fields: - - Nav-Callid - - Nav-Consumer-Id - correlation-fields: - - Nav-Callid - - Nav-Consumer-Id mvc: throw-exception-if-no-handler-found: true lifecycle: @@ -44,8 +36,6 @@ server: enabled: false shutdown: graceful -navCallIdName: Nav-Callid - management: endpoint: health: @@ -62,12 +52,7 @@ management: export: enabled: true tracing: - baggage: - remote-fields: - - ${navCallIdName} - correlation: - fields: - - ${navCallIdName} + enabled: false no.nav.security.jwt: issuer: