diff --git a/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt b/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt index 7520eae9ce..b2826a1027 100644 --- a/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt +++ b/core/src/main/kotlin/net/corda/core/flows/FlowLogic.kt @@ -310,12 +310,14 @@ abstract class FlowLogic { @Suspendable @JvmOverloads open fun receiveAllMap(sessions: Map>, maySkipCheckpoint: Boolean = false): Map> { - enforceNoPrimitiveInReceive(sessions.values) - val replies = stateMachine.suspend( - ioRequest = FlowIORequest.Receive(sessions.keys.toNonEmptySet()), - maySkipCheckpoint = maySkipCheckpoint - ) - return replies.mapValues { (session, payload) -> payload.checkPayloadIs(sessions[session]!!) } + serviceHub.telemetryServiceInternal.span("${this::class.java.name}#receiveAllMap") { + enforceNoPrimitiveInReceive(sessions.values) + val replies = stateMachine.suspend( + ioRequest = FlowIORequest.Receive(sessions.keys.toNonEmptySet()), + maySkipCheckpoint = maySkipCheckpoint + ) + return replies.mapValues { (session, payload) -> payload.checkPayloadIs(sessions[session]!!) } + } } /** @@ -332,9 +334,11 @@ abstract class FlowLogic { @Suspendable @JvmOverloads open fun receiveAll(receiveType: Class, sessions: List, maySkipCheckpoint: Boolean = false): List> { - enforceNoPrimitiveInReceive(listOf(receiveType)) - enforceNoDuplicates(sessions) - return castMapValuesToKnownType(receiveAllMap(associateSessionsToReceiveType(receiveType, sessions))) + serviceHub.telemetryServiceInternal.span("${this::class.java.name}#receiveAll") { + enforceNoPrimitiveInReceive(listOf(receiveType)) + enforceNoDuplicates(sessions) + return castMapValuesToKnownType(receiveAllMap(associateSessionsToReceiveType(receiveType, sessions))) + } } /** @@ -351,8 +355,10 @@ abstract class FlowLogic { @Suspendable @JvmOverloads fun sendAll(payload: Any, sessions: Set, maySkipCheckpoint: Boolean = false) { - val sessionToPayload = sessions.map { it to payload }.toMap() - return sendAllMap(sessionToPayload, maySkipCheckpoint) + serviceHub.telemetryServiceInternal.span("${this::class.java.name}#sendAll") { + val sessionToPayload = sessions.map { it to payload }.toMap() + return sendAllMap(sessionToPayload, maySkipCheckpoint) + } } /** @@ -368,10 +374,12 @@ abstract class FlowLogic { @Suspendable @JvmOverloads fun sendAllMap(payloadsPerSession: Map, maySkipCheckpoint: Boolean = false) { - val request = FlowIORequest.Send( - sessionToMessage = stateMachine.serialize(payloadsPerSession) - ) - stateMachine.suspend(request, maySkipCheckpoint) + serviceHub.telemetryServiceInternal.span("${this::class.java.name}#sendAllMap") { + val request = FlowIORequest.Send( + sessionToMessage = stateMachine.serialize(payloadsPerSession) + ) + stateMachine.suspend(request, maySkipCheckpoint) + } } /** diff --git a/core/src/main/kotlin/net/corda/core/internal/telemetry/TelemetryServiceImpl.kt b/core/src/main/kotlin/net/corda/core/internal/telemetry/TelemetryServiceImpl.kt index 54bc1249f7..95b4f22595 100644 --- a/core/src/main/kotlin/net/corda/core/internal/telemetry/TelemetryServiceImpl.kt +++ b/core/src/main/kotlin/net/corda/core/internal/telemetry/TelemetryServiceImpl.kt @@ -1,6 +1,7 @@ package net.corda.core.internal.telemetry import net.corda.core.CordaInternal +import net.corda.core.DeleteForDJVM import net.corda.core.flows.FlowLogic import net.corda.core.internal.uncheckedCast import net.corda.core.node.ServiceHub @@ -34,6 +35,7 @@ enum class TelemetryStatusCode { ERROR } +@DeleteForDJVM @CordaSerializable data class TelemetryId(private val telemetryService: TelemetryServiceImpl) { val id: UUID = UUID.randomUUID() @@ -57,12 +59,14 @@ data class ComponentTelemetryIds(val componentTelemetryIds: Map) interface TelemetryEvent - +@DeleteForDJVM class StartSpanForFlowEvent(val name: String, val attributes: Map, val telemetryId: UUID, val flowLogic: FlowLogic<*>?, val telemetryDataItem: TelemetryDataItem?): TelemetryEvent +@DeleteForDJVM class EndSpanForFlowEvent(val telemetryId: UUID): TelemetryEvent +@DeleteForDJVM class StartSpanEvent(val name: String, val attributes: Map, val telemetryId: UUID, val flowLogic: FlowLogic<*>?): TelemetryEvent class EndSpanEvent(val telemetryId: UUID): TelemetryEvent class SetStatusEvent(val telemetryId: UUID, val telemetryStatusCode: TelemetryStatusCode, val message: String): TelemetryEvent @@ -88,6 +92,7 @@ interface TelemetryComponentId { } @Suppress("TooManyFunctions") +@DeleteForDJVM class TelemetryServiceImpl : SingletonSerializeAsToken(), TelemetryService { companion object {