Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jutaro committed Sep 23, 2024
1 parent 0a9e3e8 commit 4a29a5d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 59 deletions.
102 changes: 44 additions & 58 deletions cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,9 @@ instance MetaTrace (TraceBlockFetchServerEvent blk) where
severityFor _ _ = Nothing

metricsDocFor (Namespace [] ["SendBlock"]) =
[("served.block", "")]
[("served.block", "")
,("served.block.latest", "")]

metricsDocFor _ = []

documentFor (Namespace [] ["SendBlock"]) = Just
Expand All @@ -873,6 +875,47 @@ instance MetaTrace (TraceBlockFetchServerEvent blk) where

allNamespaces = [Namespace [] ["SendBlock"]]

--------------------------------------------------------------------------------
-- Metric for server block latest
--------------------------------------------------------------------------------

data ServedBlock = ServedBlock {
maxSlotNo :: SlotNo
, localUp :: Word64
, servedBlocksLatest :: Word64
}

instance LogFormatting ServedBlock where
forMachine _mDtal ServedBlock {} = mempty

asMetrics ServedBlock {..} =
[IntM "served.block.latest" (fromIntegral servedBlocksLatest)]

emptyServedBlocks :: ServedBlock
emptyServedBlocks = ServedBlock 0 0 0

servedBlockLatest ::
Maybe (Trace IO FormattedMessage)
-> IO (Trace IO (TraceLabelPeer peer (TraceBlockFetchServerEvent blk)))
servedBlockLatest mbTrEKG =
foldTraceM calculateServedBlockLatest emptyServedBlocks
(metricsFormatter
(mkMetricsTracer mbTrEKG))

calculateServedBlockLatest :: ServedBlock
-> LoggingContext
-> TraceLabelPeer peer (TraceBlockFetchServerEvent blk)
-> IO ServedBlock
calculateServedBlockLatest ServedBlock{..} _lc (TraceLabelPeer _ (TraceBlockFetchServerSendBlock p)) =
case pointSlot p of
Origin -> return $ ServedBlock maxSlotNo localUp servedBlocksLatest
At slotNo ->
case compare maxSlotNo slotNo of
LT -> return $ ServedBlock slotNo (localUp + 1) (localUp + 1)
GT -> return $ ServedBlock maxSlotNo localUp servedBlocksLatest
EQ -> return $ ServedBlock maxSlotNo (localUp + 1) (localUp + 1)


--------------------------------------------------------------------------------
-- Gdd Tracer
--------------------------------------------------------------------------------
Expand Down Expand Up @@ -976,63 +1019,6 @@ instance LogFormatting SanityCheckIssue where
"Configuration contains multiple security parameters: " <> Text.pack (show e)


--------------------------------------------------------------------------------
-- Metric for server block latest
--------------------------------------------------------------------------------

data ServedBlock = ServedBlock {
maxSlotNo :: SlotNo
, localUp :: Word64
, servedBlocksLatest :: Word64
}

instance MetaTrace ServedBlock where
namespaceFor ServedBlock {} =
Namespace [] ["ServedBlockLatest"]

severityFor (Namespace [] ["ServedBlockLatest"]) _ = Just
Debug
severityFor _ _ = Nothing

documentFor _ = Nothing

metricsDocFor (Namespace [] ["ServedBlockLatest"]) =
[("served.block.latest", "")]
metricsDocFor _ = []

allNamespaces = [Namespace [] ["ServedBlockLatest"]]


instance LogFormatting ServedBlock where
forMachine _mDtal ServedBlock {} = mempty

asMetrics ServedBlock {..} =
[IntM "served.block.latest" (fromIntegral servedBlocksLatest)]


emptyServedBlocks :: ServedBlock
emptyServedBlocks = ServedBlock 0 0 0

servedBlockLatest ::
Maybe (Trace IO FormattedMessage)
-> IO (Trace IO (TraceLabelPeer peer (TraceBlockFetchServerEvent blk)))
servedBlockLatest mbTrEKG =
foldTraceM calculateServedBlockLatest emptyServedBlocks
(metricsFormatter
(mkMetricsTracer mbTrEKG))

calculateServedBlockLatest :: ServedBlock
-> LoggingContext
-> TraceLabelPeer peer (TraceBlockFetchServerEvent blk)
-> IO ServedBlock
calculateServedBlockLatest ServedBlock{..} _lc (TraceLabelPeer _ (TraceBlockFetchServerSendBlock p)) =
case pointSlot p of
Origin -> return $ ServedBlock maxSlotNo localUp servedBlocksLatest
At slotNo ->
case compare maxSlotNo slotNo of
LT -> return $ ServedBlock slotNo (localUp + 1) (localUp + 1)
GT -> return $ ServedBlock maxSlotNo localUp servedBlocksLatest
EQ -> return $ ServedBlock maxSlotNo (localUp + 1) (localUp + 1)

--------------------------------------------------------------------------------
-- TxInbound Tracer
Expand Down
3 changes: 2 additions & 1 deletion cardano-node/src/Cardano/Node/Tracing/Tracers/Startup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,8 @@ instance MetaTrace (StartupTrace blk) where
metricsDocFor (Namespace _ ["BlockForgingUpdate"]) =
[("forging_enabled","Can this node forge blocks? (Is it provided with block forging credentials) 0 = no, 1 = yes")]
metricsDocFor (Namespace _ ["Common"]) =
[("systemStartTime","The UTC time this node was started.")]
[("systemStartTime","The UTC time this node was started."),
("node.start.time","The UTC time this node was started represented in POSIX seconds.")]


metricsDocFor _ = []
Expand Down

0 comments on commit 4a29a5d

Please sign in to comment.