From e7f5f3ac9e031b8ea12a16aee0bb37d94b5e1d11 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Wed, 8 May 2024 15:26:51 +0200 Subject: [PATCH] outbound governor counters output for new tracing system --- .../src/Cardano/Node/Tracing/Tracers/P2P.hs | 99 +++++++++++-------- 1 file changed, 57 insertions(+), 42 deletions(-) diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs index 4b536288e3f..1fb576a506f 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs @@ -869,48 +869,59 @@ instance MetaTrace (DebugPeerSelection SockAddr) where -------------------------------------------------------------------------------- instance LogFormatting PeerSelectionCounters where - forMachine _dtal PeerSelectionCounters {..} = - mconcat [ "kind" .= String "PeerSelectionCounters" - - , "knownPeers" .= numberOfKnownPeers - , "rootPeers" .= numberOfRootPeers - , "coldPeersPromotions" .= numberOfColdPeersPromotions - , "establishedPeers" .= numberOfEstablishedPeers - , "warmPeersDemotions" .= numberOfWarmPeersDemotions - , "warmPeersPromotions" .= numberOfWarmPeersPromotions - , "activePeers" .= numberOfActivePeers - , "activePeersDemotions" .= numberOfActivePeersDemotions - - , "knownBigLedgerPeers" .= numberOfKnownBigLedgerPeers - , "coldBigLedgerPeersPromotions" .= numberOfColdBigLedgerPeersPromotions - , "establishedBigLedgerPeers" .= numberOfEstablishedBigLedgerPeers - , "warmBigLedgerPeersDemotions" .= numberOfWarmBigLedgerPeersDemotions - , "warmBigLedgerPeersPromotions" .= numberOfWarmBigLedgerPeersPromotions - , "activeBigLedgerPeers" .= numberOfActiveBigLedgerPeers - , "activeBigLedgerPeersDemotions" .= numberOfActiveBigLedgerPeersDemotions - - , "knownLocalRootPeers" .= numberOfKnownLocalRootPeers - , "establishedLocalRootPeers" .= numberOfEstablishedLocalRootPeers - , "warmLocalRootPeersPromotions" .= numberOfWarmLocalRootPeersPromotions - , "activeLocalRootPeers" .= numberOfActiveLocalRootPeers - , "activeLocalRootPeersDemotions" .= numberOfActiveLocalRootPeersDemotions - - , "knownNonRootPeers" .= numberOfKnownNonRootPeers - , "coldNonRootPeersPromotions" .= numberOfColdNonRootPeersPromotions - , "establishedNonRootPeers" .= numberOfEstablishedNonRootPeers - , "warmNonRootPeersDemotions" .= numberOfWarmNonRootPeersDemotions - , "warmNonRootPeersPromotions" .= numberOfWarmNonRootPeersPromotions - , "activeNonRootPeers" .= numberOfActiveNonRootPeers - , "activeNonRootPeersDemotions" .= numberOfActiveNonRootPeersDemotions - - , "knownBootstrapPeers" .= numberOfKnownBootstrapPeers - , "coldBootstrapPeersPromotions" .= numberOfColdBootstrapPeersPromotions - , "establishedBootstrapPeers" .= numberOfEstablishedBootstrapPeers - , "warmBootstrapPeersDemotions" .= numberOfWarmBootstrapPeersDemotions - , "warmBootstrapPeersPromotions" .= numberOfWarmBootstrapPeersPromotions - , "activeBootstrapPeers" .= numberOfActiveBootstrapPeers - , "ActiveBootstrapPeersDemotions" .= numberOfActiveBootstrapPeersDemotions - ] + forMachine dtal PeerSelectionCounters {..} = + mconcat $ + [ "kind" .= String "PeerSelectionCounters" + + , "knownPeers" .= numberOfKnownPeers + , "rootPeers" .= numberOfRootPeers + , "establishedPeers" .= numberOfEstablishedPeers + , "activePeers" .= numberOfActivePeers + , "activePeersDemotions" .= numberOfActivePeersDemotions + + , "knownBigLedgerPeers" .= numberOfKnownBigLedgerPeers + , "establishedBigLedgerPeers" .= numberOfEstablishedBigLedgerPeers + , "activeBigLedgerPeers" .= numberOfActiveBigLedgerPeers + , "activeBigLedgerPeersDemotions" .= numberOfActiveBigLedgerPeersDemotions + + , "knownLocalRootPeers" .= numberOfKnownLocalRootPeers + , "establishedLocalRootPeers" .= numberOfEstablishedLocalRootPeers + , "activeLocalRootPeers" .= numberOfActiveLocalRootPeers + ] + <> + whenM (dtal > DMinimal) + [ "knownNonRootPeers" .= numberOfKnownNonRootPeers + , "establishedNonRootPeers" .= numberOfEstablishedNonRootPeers + , "activeNonRootPeers" .= numberOfActiveNonRootPeers + , "activeNonRootPeersDemotions" .= numberOfActiveNonRootPeersDemotions + + , "knownBootstrapPeers" .= numberOfKnownBootstrapPeers + , "establishedBootstrapPeers" .= numberOfEstablishedBootstrapPeers + , "activeBootstrapPeers" .= numberOfActiveBootstrapPeers + ] + <> + whenM (dtal > DNormal) + [ "coldPeersPromotions" .= numberOfColdPeersPromotions + , "warmPeersDemotions" .= numberOfWarmPeersDemotions + , "warmPeersPromotions" .= numberOfWarmPeersPromotions + + , "coldBigLedgerPeersPromotions" .= numberOfColdBigLedgerPeersPromotions + , "warmBigLedgerPeersDemotions" .= numberOfWarmBigLedgerPeersDemotions + , "warmBigLedgerPeersPromotions" .= numberOfWarmBigLedgerPeersPromotions + + , "warmLocalRootPeersPromotions" .= numberOfWarmLocalRootPeersPromotions + , "activeLocalRootPeersDemotions" .= numberOfActiveLocalRootPeersDemotions + + , "coldNonRootPeersPromotions" .= numberOfColdNonRootPeersPromotions + , "warmNonRootPeersDemotions" .= numberOfWarmNonRootPeersDemotions + , "warmNonRootPeersPromotions" .= numberOfWarmNonRootPeersPromotions + + , "coldBootstrapPeersPromotions" .= numberOfColdBootstrapPeersPromotions + , "warmBootstrapPeersDemotions" .= numberOfWarmBootstrapPeersDemotions + , "warmBootstrapPeersPromotions" .= numberOfWarmBootstrapPeersPromotions + + , "activeBootstrapPeersDemotions" .= numberOfActiveBootstrapPeersDemotions + ] forHuman = pack . show asMetrics psc = case psc of @@ -987,6 +998,10 @@ instance LogFormatting PeerSelectionCounters where , IntM "Net.PeerSelection.ActiveBootstrapPeersDemotions" (fromIntegral numberOfActiveBootstrapPeersDemotions) ] +whenM :: Monoid m => Bool -> m -> m +whenM False _ = mempty +whenM True m = m + instance MetaTrace PeerSelectionCounters where namespaceFor PeerSelectionCounters {} = Namespace [] ["Counters"]