ENT-12832: metrics from flows (#7942)

Add ability to register metrics inside flows;
This commit is contained in:
Lucas Siqueira
2025-06-18 14:53:55 +01:00
committed by GitHub
parent b88d22abc3
commit fc61d3d83e
7 changed files with 180 additions and 2 deletions

View File

@ -70,6 +70,8 @@ dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_jupiter_version}"
testImplementation "junit:junit:$junit_version"
testImplementation "io.dropwizard.metrics:metrics-jmx:$metrics_version"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${junit_vintage_version}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit_jupiter_version}"
testRuntimeOnly "org.junit.platform:junit-platform-launcher:${junit_platform_version}"

View File

@ -1,8 +1,11 @@
package net.corda.nodeapi.internal.serialization.kryo
import com.codahale.metrics.MetricRegistry
import com.esotericsoftware.kryo.KryoException
import org.junit.Ignore
import org.junit.Test
import org.junit.jupiter.api.assertDoesNotThrow
import org.junit.jupiter.api.assertThrows
import java.util.LinkedList
import kotlin.test.assertEquals
@ -168,4 +171,15 @@ class KryoCheckpointTest {
}
assertEquals(testSize, result)
}
/**
* This test just ensures that the checkpoints still work in light of [LinkedListItrSerializer].
*/
@Test(timeout=300_000)
fun `MetricRegistry cannot checkpoint without error`() {
val metricRegistry = MetricRegistry()
assertThrows<KryoException>("Class com.codahale.metrics.MetricRegistry is not annotated or on the whitelist, so cannot be used in serialization") {
KryoCheckpointSerializer.deserialize(KryoCheckpointSerializer.serialize(metricRegistry, KRYO_CHECKPOINT_CONTEXT), MetricRegistry::class.java, KRYO_CHECKPOINT_CONTEXT)
}
}
}