Skip to content

Commit

Permalink
WIP: ChainDB.TraceChainSelStarvationEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
neilmayhew committed Dec 20, 2024
1 parent 5e5152d commit 33e195f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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')) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 33e195f

Please sign in to comment.