From 33e195fe7a7f5534949e84eeed6449baf797b2ca Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Thu, 19 Dec 2024 22:23:55 -0700 Subject: [PATCH] WIP: ChainDB.TraceChainSelStarvationEvent --- cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs | 6 ++++++ .../src/Cardano/Tracing/OrphanInstances/Consensus.hs | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs index 0981776fc21..f7f23ce4f4c 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs @@ -93,6 +93,7 @@ instance ( LogFormatting (Header blk) forHuman (ChainDB.TraceLedgerReplayEvent v) = forHumanOrMachine v forHuman (ChainDB.TraceImmutableDBEvent v) = forHumanOrMachine v forHuman (ChainDB.TraceVolatileDBEvent v) = forHumanOrMachine v + forHuman (ChainDB.TraceChainSelStarvationEvent v)= forHumanOrMachine v forMachine _ ChainDB.TraceLastShutdownUnclean = mconcat [ "kind" .= String "LastShutdownUnclean" ] @@ -118,6 +119,8 @@ instance ( LogFormatting (Header blk) forMachine details v forMachine details (ChainDB.TraceVolatileDBEvent v) = forMachine details v + forMachine details (ChainDB.TraceChainSelStarvationEvent v) = + forMachine details v asMetrics ChainDB.TraceLastShutdownUnclean = [] asMetrics (ChainDB.TraceAddBlockEvent v) = asMetrics v @@ -131,6 +134,7 @@ instance ( LogFormatting (Header blk) asMetrics (ChainDB.TraceLedgerReplayEvent v) = asMetrics v asMetrics (ChainDB.TraceImmutableDBEvent v) = asMetrics v asMetrics (ChainDB.TraceVolatileDBEvent v) = asMetrics v + asMetrics (ChainDB.TraceChainSelStarvationEvent v)= asMetrics v instance MetaTrace (ChainDB.TraceEvent blk) where @@ -158,6 +162,8 @@ instance MetaTrace (ChainDB.TraceEvent blk) where nsPrependInner "ImmDbEvent" (namespaceFor ev) namespaceFor (ChainDB.TraceVolatileDBEvent ev) = nsPrependInner "VolatileDbEvent" (namespaceFor ev) + namespaceFor (ChainDB.TraceChainSelStarvationEvent ev) = + nsPrependInner "ChainSelStarvationEvent" (namespaceFor ev) severityFor (Namespace _ ["LastShutdownUnclean"]) _ = Just Info severityFor (Namespace out ("AddBlockEvent" : tl)) (Just (ChainDB.TraceAddBlockEvent ev')) = diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs index e42672f330d..2f378cbde24 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs @@ -237,6 +237,7 @@ instance HasSeverityAnnotation (ChainDB.TraceEvent blk) where VolDb.InvalidFileNames{} -> Warning VolDb.DBClosed{} -> Info getSeverityAnnotation ChainDB.TraceLastShutdownUnclean = Warning + getSeverityAnnotation (ChainDB.TraceChainSelStarvationEvent _) = Warning -- TODO: review instance HasSeverityAnnotation (LedgerEvent blk) where getSeverityAnnotation (LedgerUpdate _) = Notice @@ -749,6 +750,7 @@ instance ( ConvertRawHash blk VolDb.Truncate e pth offs -> "Truncating the file at " <> showT pth <> " at offset " <> showT offs <> ": " <> showT e VolDb.InvalidFileNames fs -> "Invalid Volatile DB files: " <> showT fs VolDb.DBClosed -> "Closed Volatile DB." + ChainDB.TraceChainSelStarvationEvent _ -> "ChainSelStarvationEvent" -- TODO: review where showProgressT :: Int -> Int -> Text showProgressT chunkNo outOf = pack (showFFloat (Just 2) (100 * fromIntegral chunkNo / fromIntegral outOf :: Float) mempty) @@ -1012,7 +1014,6 @@ instance ( ConvertRawHash blk [ "anchor" .= renderPointForVerbosity verb (AF.anchorPoint frag) , "head" .= renderPointForVerbosity verb (AF.headPoint frag) ] - where addedHdrsNewChain :: AF.AnchoredFragment (Header blk) @@ -1239,6 +1240,10 @@ instance ( ConvertRawHash blk , "files" .= String (Text.pack . show $ map show fsPaths) ] VolDb.DBClosed -> mconcat [ "kind" .= String "TraceVolatileDbEvent.DBClosed"] + toObject _verb (ChainDB.TraceChainSelStarvationEvent _) = + mconcat [ "kind" .= String "ChainSelStarvationEvent" + -- TODO: add fields + ] instance ConvertRawHash blk => ToObject (ImmDB.TraceChunkValidation blk ChunkNo) where toObject verb ev = case ev of