Skip to content

Commit

Permalink
outbound governor counters output for new tracing system
Browse files Browse the repository at this point in the history
  • Loading branch information
coot committed May 8, 2024
1 parent a1f098f commit e7f5f3a
Showing 1 changed file with 57 additions and 42 deletions.
99 changes: 57 additions & 42 deletions cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]

Expand Down

0 comments on commit e7f5f3a

Please sign in to comment.