Skip to content

Commit

Permalink
Merge pull request #5991 from IntersectMBO/jutaro/metrics_fixes
Browse files Browse the repository at this point in the history
Enhance Tracing with New Metrics, Renames, and Fixes
  • Loading branch information
mgmeier authored Nov 9, 2024
2 parents 6fac0b4 + 5ac5a95 commit 85e3898
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 167 deletions.
3 changes: 3 additions & 0 deletions cardano-node/src/Cardano/Node/Tracing/Tracers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ mkConsensusTracers configReflection trBase trForward mbTrEKG _trDataPoint trConf
["BlockFetch", "Server"]
configureTracers configReflection trConfig [blockFetchServerTr]

!servedBlockLatestTr <- servedBlockLatest mbTrEKG

!forgeKESInfoTr <- mkCardanoTracer
trBase trForward mbTrEKG
["Forge", "StateInfo"]
Expand Down Expand Up @@ -350,6 +352,7 @@ mkConsensusTracers configReflection trBase trForward mbTrEKG _trDataPoint trConf
<> traceWith blockFetchClientMetricsTr
, Consensus.blockFetchServerTracer = Tracer $
traceWith blockFetchServerTr
<> traceWith servedBlockLatestTr
, Consensus.forgeStateInfoTracer = Tracer $
traceWith (traceAsKESInfo (Proxy @blk) forgeKESInfoTr)
, Consensus.gddTracer = Tracer $
Expand Down
17 changes: 9 additions & 8 deletions cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
Expand Down Expand Up @@ -32,7 +32,8 @@ import qualified Ouroboros.Consensus.Storage.ChainDB as ChainDB
import qualified Ouroboros.Consensus.Storage.ImmutableDB as ImmDB
import Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal (chunkNoToInt)
import qualified Ouroboros.Consensus.Storage.ImmutableDB.Impl.Types as ImmDB
import Ouroboros.Consensus.Storage.LedgerDB (UpdateLedgerDbTraceEvent (..), ReplayStart (..))
import Ouroboros.Consensus.Storage.LedgerDB (ReplayStart (..),
UpdateLedgerDbTraceEvent (..))
import qualified Ouroboros.Consensus.Storage.LedgerDB as LedgerDB
import qualified Ouroboros.Consensus.Storage.VolatileDB as VolDB
import Ouroboros.Consensus.Util.Condense (condense)
Expand Down Expand Up @@ -540,17 +541,19 @@ instance ( LogFormatting (Header blk)
]


asMetrics (ChainDB.SwitchedToAFork _warnings selChangedInfo _oldChain newChain) =
let ChainInformation { slots, blocks, density, epoch, slotInEpoch } =
chainInformation selChangedInfo newChain 0
asMetrics (ChainDB.SwitchedToAFork _warnings selChangedInfo oldChain newChain) =
let forkIt = not $ AF.withinFragmentBounds (AF.headPoint oldChain)
newChain
ChainInformation { .. } = chainInformation selChangedInfo newChain 0
in [ DoubleM "density" (fromRational density)
, IntM "slotNum" (fromIntegral slots)
, IntM "blockNum" (fromIntegral blocks)
, IntM "slotInEpoch" (fromIntegral slotInEpoch)
, IntM "epoch" (fromIntegral (unEpochNo epoch))
, CounterM "forks" (Just (if forkIt then 1 else 0))
]
asMetrics (ChainDB.AddedToCurrentChain _warnings selChangedInfo _oldChain newChain) =
let ChainInformation { slots, blocks, density, epoch, slotInEpoch } =
let ChainInformation { .. } =
chainInformation selChangedInfo newChain 0
in [ DoubleM "density" (fromRational density)
, IntM "slotNum" (fromIntegral slots)
Expand Down Expand Up @@ -2094,8 +2097,6 @@ data ChainInformation = ChainInformation
-- ^ Relative slot number of the tip of the current chain within the
-- epoch.
, blocksUncoupledDelta :: Int64
-- ^ The net change in number of blocks forged since last restart not on the
-- current chain.
}

chainInformation
Expand Down
Loading

0 comments on commit 85e3898

Please sign in to comment.