From d06c1dbcc1ee402da42517fdfd856cc81b4d8d68 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 07:57:55 +0000 Subject: [PATCH 1/3] Bump the all-minor-patch group with 14 updates Bumps the all-minor-patch group with 14 updates: | Package | From | To | | --- | --- | --- | | [org.springframework.boot:spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) | `3.2.5` | `3.3.0` | | [org.apache.maven.plugins:maven-enforcer-plugin](https://github.com/apache/maven-enforcer) | `3.4.1` | `3.5.0` | | [org.springframework:spring-web](https://github.com/spring-projects/spring-framework) | `6.1.6` | `6.1.8` | | [jakarta.validation:jakarta.validation-api](https://github.com/jakartaee/validation) | `3.0.2` | `3.1.0` | | io.swagger.core.v3:swagger-annotations | `2.2.21` | `2.2.22` | | [com.fasterxml.jackson.module:jackson-module-kotlin](https://github.com/FasterXML/jackson-module-kotlin) | `2.17.0` | `2.17.1` | | org.openapitools:openapi-generator-maven-plugin | `7.5.0` | `7.6.0` | | [com.google.code.gson:gson](https://github.com/google/gson) | `2.10.1` | `2.11.0` | | [org.jetbrains.kotlinx:kotlinx-coroutines-slf4j](https://github.com/Kotlin/kotlinx.coroutines) | `1.8.0` | `1.8.1` | | [no.nav.security:token-validation-spring](https://github.com/navikt/token-support) | `4.1.4` | `4.1.8` | | [org.springframework.boot:spring-boot-starter-test](https://github.com/spring-projects/spring-boot) | `3.2.5` | `3.3.0` | | [org.springframework.boot:spring-boot-maven-plugin](https://github.com/spring-projects/spring-boot) | `3.2.5` | `3.3.0` | | [io.mockk:mockk](https://github.com/mockk/mockk) | `1.13.10` | `1.13.11` | | [io.mockk:mockk-jvm](https://github.com/mockk/mockk) | `1.13.10` | `1.13.11` | Updates `org.springframework.boot:spring-boot-starter-parent` from 3.2.5 to 3.3.0 - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.2.5...v3.3.0) Updates `org.apache.maven.plugins:maven-enforcer-plugin` from 3.4.1 to 3.5.0 - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.4.1...enforcer-3.5.0) Updates `org.springframework:spring-web` from 6.1.6 to 6.1.8 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v6.1.6...v6.1.8) Updates `jakarta.validation:jakarta.validation-api` from 3.0.2 to 3.1.0 - [Release notes](https://github.com/jakartaee/validation/releases) - [Commits](https://github.com/jakartaee/validation/compare/3.0.2...3.1.0) Updates `io.swagger.core.v3:swagger-annotations` from 2.2.21 to 2.2.22 Updates `com.fasterxml.jackson.module:jackson-module-kotlin` from 2.17.0 to 2.17.1 - [Commits](https://github.com/FasterXML/jackson-module-kotlin/compare/jackson-module-kotlin-2.17.0...jackson-module-kotlin-2.17.1) Updates `org.openapitools:openapi-generator-maven-plugin` from 7.5.0 to 7.6.0 Updates `com.google.code.gson:gson` from 2.10.1 to 2.11.0 - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/main/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.10.1...gson-parent-2.11.0) Updates `org.jetbrains.kotlinx:kotlinx-coroutines-slf4j` from 1.8.0 to 1.8.1 - [Release notes](https://github.com/Kotlin/kotlinx.coroutines/releases) - [Changelog](https://github.com/Kotlin/kotlinx.coroutines/blob/master/CHANGES.md) - [Commits](https://github.com/Kotlin/kotlinx.coroutines/compare/1.8.0...1.8.1) Updates `no.nav.security:token-validation-spring` from 4.1.4 to 4.1.8 - [Release notes](https://github.com/navikt/token-support/releases) - [Commits](https://github.com/navikt/token-support/compare/4.1.4...4.1.8) Updates `org.springframework.boot:spring-boot-starter-test` from 3.2.5 to 3.3.0 - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.2.5...v3.3.0) Updates `org.springframework.boot:spring-boot-maven-plugin` from 3.2.5 to 3.3.0 - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.2.5...v3.3.0) Updates `io.mockk:mockk` from 1.13.10 to 1.13.11 - [Release notes](https://github.com/mockk/mockk/releases) - [Commits](https://github.com/mockk/mockk/compare/1.13.10...1.13.11) Updates `io.mockk:mockk-jvm` from 1.13.10 to 1.13.11 - [Release notes](https://github.com/mockk/mockk/releases) - [Commits](https://github.com/mockk/mockk/compare/1.13.10...1.13.11) Updates `io.mockk:mockk-jvm` from 1.13.10 to 1.13.11 - [Release notes](https://github.com/mockk/mockk/releases) - [Commits](https://github.com/mockk/mockk/compare/1.13.10...1.13.11) Updates `org.springframework.boot:spring-boot-maven-plugin` from 3.2.5 to 3.3.0 - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.2.5...v3.3.0) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-starter-parent dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all-minor-patch - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all-minor-patch - dependency-name: org.springframework:spring-web dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all-minor-patch - dependency-name: jakarta.validation:jakarta.validation-api dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all-minor-patch - dependency-name: io.swagger.core.v3:swagger-annotations dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all-minor-patch - dependency-name: com.fasterxml.jackson.module:jackson-module-kotlin dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all-minor-patch - dependency-name: org.openapitools:openapi-generator-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all-minor-patch - dependency-name: com.google.code.gson:gson dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all-minor-patch - dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-slf4j dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all-minor-patch - dependency-name: no.nav.security:token-validation-spring dependency-type: direct:production update-type: version-update:semver-patch dependency-group: all-minor-patch - dependency-name: org.springframework.boot:spring-boot-starter-test dependency-type: direct:development update-type: version-update:semver-minor dependency-group: all-minor-patch - dependency-name: org.springframework.boot:spring-boot-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all-minor-patch - dependency-name: io.mockk:mockk dependency-type: direct:development update-type: version-update:semver-patch dependency-group: all-minor-patch - dependency-name: io.mockk:mockk-jvm dependency-type: direct:development update-type: version-update:semver-patch dependency-group: all-minor-patch - dependency-name: io.mockk:mockk-jvm dependency-type: direct:development update-type: version-update:semver-patch dependency-group: all-minor-patch - dependency-name: org.springframework.boot:spring-boot-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor dependency-group: all-minor-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 8d9a1c8..e81068f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.2.5 + 3.3.0 @@ -17,26 +17,26 @@ Receives benefit applications - 3.2.5 + 3.3.0 21 2.0.0 3.8.8 1.6.3 - 1.8.0 + 1.8.1 2.5.0 - 6.1.6 + 6.1.8 - 2.17.0 + 2.17.1 0.2.6 - 2.10.1 + 2.11.0 - 4.1.4 + 4.1.8 7.6.1 @@ -51,21 +51,21 @@ 6.0.0 - 3.0.2 + 3.1.0 3.0.0 4.12.0 - 2.2.21 + 2.2.22 - 1.13.10 + 1.13.11 2.16.2 2.8.0 - 3.4.1 - 7.5.0 + 3.5.0 + 7.6.0 From d8f1dbd4c74a22420755c845026de785979cd234 Mon Sep 17 00:00:00 2001 From: Morten Stulen Date: Wed, 5 Jun 2024 16:03:34 +0200 Subject: [PATCH 2/3] Update prometheus java client --- .github/workflows/main.yml | 2 +- .github/workflows/manual-deploy.yml | 2 +- mottaker/pom.xml | 15 +++--------- .../supervision/InnsendtMetrics.kt | 23 +++++++++---------- pom.xml | 2 +- 5 files changed, 17 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3ccec1b..bbe5b7a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,7 +39,7 @@ jobs: identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} image_suffix: prod - byosbom: target/bom.json + byosbom: target/classes/META-INF/sbom/application.cdx.json outputs: image: ${{ steps.docker-build-push.outputs.image }} diff --git a/.github/workflows/manual-deploy.yml b/.github/workflows/manual-deploy.yml index 5f319db..d16e756 100644 --- a/.github/workflows/manual-deploy.yml +++ b/.github/workflows/manual-deploy.yml @@ -40,7 +40,7 @@ jobs: identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} image_suffix: ${{ github.event.inputs.environment }} - byosbom: target/bom.json + byosbom: target/classes/META-INF/sbom/application.cdx.json outputs: image: ${{ steps.docker-build-push.outputs.image }} diff --git a/mottaker/pom.xml b/mottaker/pom.xml index accb19d..c43911f 100644 --- a/mottaker/pom.xml +++ b/mottaker/pom.xml @@ -39,19 +39,10 @@ io.prometheus - simpleclient_common - ${prometheus-simpleclient.version} - - - io.prometheus - simpleclient - ${prometheus-simpleclient.version} - - - io.prometheus - simpleclient_hotspot - ${prometheus-simpleclient.version} + prometheus-metrics-instrumentation-jvm + ${prometheus.version} + org.springframework.boot spring-boot-starter-security diff --git a/mottaker/src/main/kotlin/no/nav/soknad/arkivering/soknadsmottaker/supervision/InnsendtMetrics.kt b/mottaker/src/main/kotlin/no/nav/soknad/arkivering/soknadsmottaker/supervision/InnsendtMetrics.kt index 00bc6eb..43bac5d 100644 --- a/mottaker/src/main/kotlin/no/nav/soknad/arkivering/soknadsmottaker/supervision/InnsendtMetrics.kt +++ b/mottaker/src/main/kotlin/no/nav/soknad/arkivering/soknadsmottaker/supervision/InnsendtMetrics.kt @@ -1,7 +1,7 @@ package no.nav.soknad.arkivering.soknadsmottaker.supervision -import io.prometheus.client.CollectorRegistry -import io.prometheus.client.Counter +import io.prometheus.metrics.core.metrics.Counter +import io.prometheus.metrics.model.registry.PrometheusRegistry import org.slf4j.LoggerFactory import org.springframework.beans.factory.config.ConfigurableBeanFactory import org.springframework.context.annotation.Scope @@ -9,7 +9,7 @@ import org.springframework.stereotype.Component @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) @Component -class InnsendtMetrics(private val registry: CollectorRegistry) { +class InnsendtMetrics(private val registry: PrometheusRegistry) { private val logger = LoggerFactory.getLogger(javaClass) @@ -37,9 +37,8 @@ class InnsendtMetrics(private val registry: CollectorRegistry) { } private fun registerCounter(name: String, help: String): Counter { - return Counter.build() - .namespace(soknadNamespace) - .name(name) + return Counter.builder() + .name("${soknadNamespace}_${name}") .help(help) .labelNames(labelName, appName) .register(registry) @@ -48,24 +47,24 @@ class InnsendtMetrics(private val registry: CollectorRegistry) { fun mottattSoknadInc(tema: String) { val counter = innsendtCounter[ok] - counter?.labels(tema, app)?.inc() - counter?.labels(all, app)?.inc() + counter?.labelValues(tema, app)?.inc() + counter?.labelValues(all, app)?.inc() } fun mottattSoknadGet(tema: String): Double? { val counter = innsendtCounter[ok] - return counter?.labels(tema, app)?.get() + return counter?.labelValues(tema, app)?.get() } fun mottattErrorInc(tema: String) { val counter = innsendtCounter[error] - counter?.labels(tema, app)?.inc() - counter?.labels(all, app)?.inc() + counter?.labelValues(tema, app)?.inc() + counter?.labelValues(all, app)?.inc() } fun mottattErrorGet(tema: String): Double? { val counter = innsendtCounter[error] - return counter?.labels(tema, app)?.get() + return counter?.labelValues(tema, app)?.get() } fun unregister() { diff --git a/pom.xml b/pom.xml index e81068f..a8fbf7b 100644 --- a/pom.xml +++ b/pom.xml @@ -46,8 +46,8 @@ 1.0.4 - 0.16.0 7.4 + 1.3.1 6.0.0 From 4ba967629b0e5cebd23e1e19114f77d19a92c005 Mon Sep 17 00:00:00 2001 From: Morten Stulen Date: Thu, 6 Jun 2024 08:49:02 +0200 Subject: [PATCH 3/3] Fix tests --- .../supervision/InnsendtMetrics.kt | 1 + .../SoknadsmottakerApplicationTests.kt | 4 +- .../soknadsmottaker/rest/ReceiverTests.kt | 50 +++++++++++++------ .../service/ArchiverServiceTests.kt | 4 +- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/mottaker/src/main/kotlin/no/nav/soknad/arkivering/soknadsmottaker/supervision/InnsendtMetrics.kt b/mottaker/src/main/kotlin/no/nav/soknad/arkivering/soknadsmottaker/supervision/InnsendtMetrics.kt index 43bac5d..3147057 100644 --- a/mottaker/src/main/kotlin/no/nav/soknad/arkivering/soknadsmottaker/supervision/InnsendtMetrics.kt +++ b/mottaker/src/main/kotlin/no/nav/soknad/arkivering/soknadsmottaker/supervision/InnsendtMetrics.kt @@ -41,6 +41,7 @@ class InnsendtMetrics(private val registry: PrometheusRegistry) { .name("${soknadNamespace}_${name}") .help(help) .labelNames(labelName, appName) + .withoutExemplars() .register(registry) } diff --git a/mottaker/src/test/kotlin/no/nav/soknad/arkivering/soknadsmottaker/SoknadsmottakerApplicationTests.kt b/mottaker/src/test/kotlin/no/nav/soknad/arkivering/soknadsmottaker/SoknadsmottakerApplicationTests.kt index 586f403..612005a 100644 --- a/mottaker/src/test/kotlin/no/nav/soknad/arkivering/soknadsmottaker/SoknadsmottakerApplicationTests.kt +++ b/mottaker/src/test/kotlin/no/nav/soknad/arkivering/soknadsmottaker/SoknadsmottakerApplicationTests.kt @@ -1,6 +1,6 @@ package no.nav.soknad.arkivering.soknadsmottaker -import io.prometheus.client.CollectorRegistry +import io.prometheus.metrics.model.registry.PrometheusRegistry import no.nav.soknad.arkivering.soknadsmottaker.config.KafkaConfig import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test @@ -15,7 +15,7 @@ class SoknadsmottakerApplicationTests { private lateinit var kafkaConfig: KafkaConfig @MockBean - lateinit var collectorRegistry: CollectorRegistry + lateinit var prometheusRegistry: PrometheusRegistry @Test fun `Spring context loads`() { diff --git a/mottaker/src/test/kotlin/no/nav/soknad/arkivering/soknadsmottaker/rest/ReceiverTests.kt b/mottaker/src/test/kotlin/no/nav/soknad/arkivering/soknadsmottaker/rest/ReceiverTests.kt index 3fd3a98..ba90124 100644 --- a/mottaker/src/test/kotlin/no/nav/soknad/arkivering/soknadsmottaker/rest/ReceiverTests.kt +++ b/mottaker/src/test/kotlin/no/nav/soknad/arkivering/soknadsmottaker/rest/ReceiverTests.kt @@ -3,7 +3,7 @@ package no.nav.soknad.arkivering.soknadsmottaker.rest import io.mockk.every import io.mockk.mockk import io.mockk.slot -import io.prometheus.client.CollectorRegistry +import io.prometheus.metrics.model.registry.PrometheusRegistry import no.nav.soknad.arkivering.avroschemas.InnsendingMetrics import no.nav.soknad.arkivering.avroschemas.Soknadarkivschema import no.nav.soknad.arkivering.soknadsmottaker.config.KafkaConfig @@ -37,7 +37,7 @@ class ReceiverTests { private val doneKafkaMock = mockk>() private val utkastKafkaMock = mockk>() - private val metrics = InnsendtMetrics(CollectorRegistry(true)) + private val metrics = InnsendtMetrics(PrometheusRegistry.defaultRegistry) private val receiver = mockReceiver(metrics) @Test @@ -50,7 +50,12 @@ class ReceiverTests { val metricRecord = slot>() every { kafkaMock.send(capture(record)) } returns setFuture(makeSendResult(topic, convert(soknad))) - every { metricsKafkaMock.send(capture(metricRecord)) } returns setFuture(makeSendResult(metricsTopic, InnsendingMetrics())) + every { metricsKafkaMock.send(capture(metricRecord)) } returns setFuture( + makeSendResult( + metricsTopic, + InnsendingMetrics() + ) + ) receiver.receive(soknad, null) @@ -62,15 +67,23 @@ class ReceiverTests { assertEquals(sentInBefore!! + 1.0, metrics.mottattSoknadGet("BIL"), "Should increase counter by 1") assertEquals(metricsTopic, metricRecord.captured.topic(), "Should send metrics to the right topic") - assertEquals(1, metricRecord.captured.headers().headers(MESSAGE_ID).count(), - "Metrics should have a MESSAGE_ID header") - assertEquals("soknadsmottaker", metricRecord.captured.value().application, - "Metrics should have correct application name") + assertEquals( + 1, metricRecord.captured.headers().headers(MESSAGE_ID).count(), + "Metrics should have a MESSAGE_ID header" + ) + assertEquals( + "soknadsmottaker", metricRecord.captured.value().application, + "Metrics should have correct application name" + ) assertEquals("publish to kafka", metricRecord.captured.value().action, "Metrics should have correct action") - assertTrue(metricRecord.captured.value().startTime <= System.currentTimeMillis(), - "Metrics should have correct startTime") - assertTrue(metricRecord.captured.value().duration <= metricRecord.captured.value().startTime, - "Metrics should have a duration") + assertTrue( + metricRecord.captured.value().startTime <= System.currentTimeMillis(), + "Metrics should have correct startTime" + ) + assertTrue( + metricRecord.captured.value().duration <= metricRecord.captured.value().startTime, + "Metrics should have a duration" + ) metrics.unregister() } @@ -84,7 +97,12 @@ class ReceiverTests { val metricRecord = slot>() every { kafkaMock.send(capture(record)) } throws KafkaException("Mocked Exception") - every { metricsKafkaMock.send(capture(metricRecord)) } returns setFuture(makeSendResult(metricsTopic, metricMessage)) + every { metricsKafkaMock.send(capture(metricRecord)) } returns setFuture( + makeSendResult( + metricsTopic, + metricMessage + ) + ) assertThrows { receiver.receive(soknad, null) @@ -98,8 +116,9 @@ class ReceiverTests { } private fun makeSendResult(topic: String, melding: T) = SendResult( - ProducerRecord(topic, "123", melding), - RecordMetadata(TopicPartition(topic, 1), 1L, 1, 1L, 1, 1)) + ProducerRecord(topic, "123", melding), + RecordMetadata(TopicPartition(topic, 1), 1L, 1, 1L, 1, 1) + ) private fun setFuture(v: SendResult): CompletableFuture> { return CompletableFuture.completedFuture(v) @@ -123,7 +142,8 @@ class ReceiverTests { it.brukernotifikasjonBeskjedTopic = "min-side.aapen-brukernotifikasjon-beskjed-v1" it.brukernotifikasjonOppgaveTopic = "min-side.aapen-brukernotifikasjon-oppgave-v1" } - val kafkaSender = KafkaSender(conf, kafkaMock, metricsKafkaMock, beskjedKafkaMock, oppgaveKafkaMock, doneKafkaMock, utkastKafkaMock) + val kafkaSender = + KafkaSender(conf, kafkaMock, metricsKafkaMock, beskjedKafkaMock, oppgaveKafkaMock, doneKafkaMock, utkastKafkaMock) val archiverService = ArchiverService(kafkaSender, metrics) return RestApi(archiverService) } diff --git a/mottaker/src/test/kotlin/no/nav/soknad/arkivering/soknadsmottaker/service/ArchiverServiceTests.kt b/mottaker/src/test/kotlin/no/nav/soknad/arkivering/soknadsmottaker/service/ArchiverServiceTests.kt index e2c2dd0..14eb489 100644 --- a/mottaker/src/test/kotlin/no/nav/soknad/arkivering/soknadsmottaker/service/ArchiverServiceTests.kt +++ b/mottaker/src/test/kotlin/no/nav/soknad/arkivering/soknadsmottaker/service/ArchiverServiceTests.kt @@ -3,7 +3,6 @@ package no.nav.soknad.arkivering.soknadsmottaker.service import io.mockk.every import io.mockk.mockk import io.mockk.verify -import io.prometheus.client.CollectorRegistry import no.nav.soknad.arkivering.soknadsmottaker.supervision.InnsendtMetrics import no.nav.soknad.arkivering.soknadsmottaker.utils.createSoknad import org.junit.jupiter.api.Test @@ -12,12 +11,13 @@ import java.util.* class ArchiverServiceTests { private val kafkaSender = mockk() + private val metrics = mockk(relaxed = true) + @Test fun `Calls Kafka sender`() { every { kafkaSender.publishSoknadarkivschema(any(), any()) } returns Unit every { kafkaSender.publishMetric(any(), any()) } returns Unit - val metrics = InnsendtMetrics(CollectorRegistry.defaultRegistry) val archiverService = ArchiverService(kafkaSender, metrics) archiverService.archive(UUID.randomUUID().toString(), createSoknad())