Skip to content

Commit

Permalink
Merge #2281
Browse files Browse the repository at this point in the history
2281: CAD-2477:  clean up metric name space r=deepfire a=deepfire

1. Consolidate all metrics under `cardano.node.metrics`.
2. Update configs.
3. Eliminate mentions of stale namespace references.

Now:
![Screenshot from 2021-01-15 19-27-04](https://user-images.githubusercontent.com/452652/104752479-c5fef300-5767-11eb-981f-c2b233f54205.png)

Before:
![Screenshot from 2021-01-15 01-25-50](https://user-images.githubusercontent.com/452652/104658321-92728900-56d3-11eb-9d68-d098f4d5db4a.png)


Co-authored-by: Kosyrev Serge <serge.kosyrev@iohk.io>
Co-authored-by: Jean-Baptiste Giraudeau <jean-baptiste.giraudeau@iohk.io>
  • Loading branch information
3 people committed Jan 15, 2021
2 parents 9699a56 + d2e37a6 commit 345fe9d
Show file tree
Hide file tree
Showing 20 changed files with 76 additions and 599 deletions.
101 changes: 55 additions & 46 deletions cardano-node/src/Cardano/Tracing/Tracers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ mkTracers tOpts@(TracingOn trSel) tr nodeKern = do

pure Tracers
{ chainDBTracer = tracerOnOff' (traceChainDB trSel) $
annotateSeverity . teeTraceChainTip tOpts elidedChainDB $ appendName "ChainDB" tr
annotateSeverity $ teeTraceChainTip tOpts elidedChainDB
(appendName "ChainDB" tr) (appendName "metrics" tr)
, consensusTracers = consensusTracers
, nodeToClientTracers = nodeToClientTracers' trSel verb tr
, nodeToNodeTracers = nodeToNodeTracers' trSel verb tr
Expand Down Expand Up @@ -353,12 +354,13 @@ teeTraceChainTip
=> TraceOptions
-> MVar (Maybe (WithSeverity (ChainDB.TraceEvent blk)), Integer)
-> Trace IO Text
-> Trace IO Text
-> Tracer IO (WithSeverity (ChainDB.TraceEvent blk))
teeTraceChainTip TracingOff _ _ = nullTracer
teeTraceChainTip (TracingOn trSel) elided tr =
teeTraceChainTip TracingOff _ _ _ = nullTracer
teeTraceChainTip (TracingOn trSel) elided trTrc trMet =
Tracer $ \ev -> do
traceWith (teeTraceChainTip' tr) ev
traceWith (teeTraceChainTipElide (traceVerbosity trSel) elided tr) ev
traceWith (teeTraceChainTipElide (traceVerbosity trSel) elided trTrc) ev
traceWith (ignoringSeverity (traceChainMetrics trMet)) ev

teeTraceChainTipElide
:: ( ConvertRawHash blk
Expand All @@ -372,36 +374,43 @@ teeTraceChainTipElide
-> Trace IO Text
-> Tracer IO (WithSeverity (ChainDB.TraceEvent blk))
teeTraceChainTipElide = elideToLogObject
{-# INLINE teeTraceChainTipElide #-}

traceChainInformation :: Trace IO Text -> ChainInformation -> IO ()
traceChainInformation tr ChainInformation { slots, blocks, density, epoch, slotInEpoch } = do
-- TODO this is executed each time the chain changes. How cheap is it?
meta <- mkLOMeta Critical Confidential
let tr' = appendName "metrics" tr
traceD :: Text -> Double -> IO ()
traceD msg d = traceNamedObject tr' (meta, LogValue msg (PureD d))
traceI :: Integral a => Text -> a -> IO ()
traceI msg i = traceNamedObject tr' (meta, LogValue msg (PureI (fromIntegral i)))

traceD "density" (fromRational density)
traceI "slotNum" slots
traceI "blockNum" blocks
traceI "slotInEpoch" slotInEpoch
traceI "epoch" (unEpochNo epoch)

teeTraceChainTip'
:: HasHeader (Header blk)
=> Trace IO Text -> Tracer IO (WithSeverity (ChainDB.TraceEvent blk))
teeTraceChainTip' tr =
Tracer $ \(WithSeverity _ ev') ->
case ev' of
(ChainDB.TraceAddBlockEvent ev) -> case ev of
ChainDB.SwitchedToAFork _warnings newTipInfo _ newChain ->
traceChainInformation tr (chainInformation newTipInfo newChain)
ChainDB.AddedToCurrentChain _warnings newTipInfo _ newChain ->
traceChainInformation tr (chainInformation newTipInfo newChain)
_ -> pure ()
_ -> pure ()
ignoringSeverity :: Tracer IO a -> Tracer IO (WithSeverity a)
ignoringSeverity tr = Tracer $ \(WithSeverity _ ev) -> traceWith tr ev
{-# INLINE ignoringSeverity #-}

traceChainMetrics
:: forall blk. HasHeader (Header blk)
=> Trace IO Text -> Tracer IO (ChainDB.TraceEvent blk)
traceChainMetrics tr = Tracer $ \ev ->
fromMaybe (pure ()) $
doTrace <$> chainTipInformation ev
where
chainTipInformation :: ChainDB.TraceEvent blk -> Maybe ChainInformation
chainTipInformation = \case
ChainDB.TraceAddBlockEvent ev -> case ev of
ChainDB.SwitchedToAFork _warnings newTipInfo _ newChain ->
Just $ chainInformation newTipInfo newChain
ChainDB.AddedToCurrentChain _warnings newTipInfo _ newChain ->
Just $ chainInformation newTipInfo newChain
_ -> Nothing
_ -> Nothing

doTrace :: ChainInformation -> IO ()
doTrace ChainInformation { slots, blocks, density, epoch, slotInEpoch } = do
-- TODO this is executed each time the chain changes. How cheap is it?
meta <- mkLOMeta Critical Public
let traceD :: Text -> Double -> IO ()
traceD msg d = traceNamedObject tr (meta, LogValue msg (PureD d))
traceI :: Integral a => Text -> a -> IO ()
traceI msg i = traceNamedObject tr (meta, LogValue msg (PureI (fromIntegral i)))

traceD "density" (fromRational density)
traceI "slotNum" slots
traceI "blockNum" blocks
traceI "slotInEpoch" slotInEpoch
traceI "epoch" (unEpochNo epoch)

--------------------------------------------------------------------------------
-- Consensus Tracers
Expand Down Expand Up @@ -440,7 +449,7 @@ mkConsensusTracers trSel verb tr nodeKern fStats = do
, Consensus.chainSyncServerHeaderTracer = tracerOnOff (traceChainSyncHeaderServer trSel) verb "ChainSyncHeaderServer" tr
, Consensus.chainSyncServerBlockTracer = tracerOnOff (traceChainSyncHeaderServer trSel) verb "ChainSyncBlockServer" tr
, Consensus.blockFetchDecisionTracer = tracerOnOff' (traceBlockFetchDecisions trSel) $
annotateSeverity $ teeTraceBlockFetchDecision verb elidedFetchDecision $ appendName "BlockFetchDecision" tr
annotateSeverity $ teeTraceBlockFetchDecision verb elidedFetchDecision tr
, Consensus.blockFetchClientTracer = tracerOnOff (traceBlockFetchClient trSel) verb "BlockFetchClient" tr
, Consensus.blockFetchServerTracer = tracerOnOff (traceBlockFetchServer trSel) verb "BlockFetchServer" tr
, Consensus.forgeStateInfoTracer = tracerOnOff' (traceForgeStateInfo trSel) $
Expand All @@ -452,8 +461,7 @@ mkConsensusTracers trSel verb tr nodeKern fStats = do
, Consensus.forgeTracer = tracerOnOff' (traceForge trSel) $
Tracer $ \tlcev@(Consensus.TraceLabelCreds _ ev) -> do
traceWith (annotateSeverity
$ traceLeadershipChecks forgeTracers nodeKern verb
$ appendName "LeadershipCheck" tr) tlcev
$ traceLeadershipChecks forgeTracers nodeKern verb tr) tlcev
traceWith (forgeTracer verb tr forgeTracers fStats) tlcev
-- Don't track credentials in ForgeTime.
traceWith (blockForgeOutcomeExtractor
Expand Down Expand Up @@ -510,9 +518,9 @@ traceLeadershipChecks _ft nodeKern _tverb tr = Tracer $
fromSMaybe (pure ()) $
query <&>
\(utxoSize, delegMapSize, _) -> do
traceCounter "utxoSize" tr utxoSize
traceCounter "delegMapSize" tr delegMapSize
traceNamedObject tr
traceCounter "utxoSize" tr utxoSize
traceCounter "delegMapSize" tr delegMapSize
traceNamedObject (appendName "LeadershipCheck" tr)
( meta
, LogStructured $ Map.fromList $
[("kind", String "TraceStartLeadershipCheck")
Expand Down Expand Up @@ -803,7 +811,7 @@ forgeStateInfoTracer
-> Tracer IO (Consensus.TraceLabelCreds (ForgeStateInfo blk))
forgeStateInfoTracer p _ts tracer = Tracer $ \ev -> do
let tr = appendName "Forge" tracer
traceWith (forgeStateInfoMetricsTraceTransformer p tr) ev
traceWith (forgeStateInfoMetricsTraceTransformer p tracer) ev
traceWith (fsTracer tr) ev
where
fsTracer :: Trace IO Text -> Tracer IO (Consensus.TraceLabelCreds (ForgeStateInfo blk))
Expand Down Expand Up @@ -870,18 +878,19 @@ teeTraceBlockFetchDecision
-> Tracer IO (WithSeverity [TraceLabelPeer peer (FetchDecision [Point (Header blk)])])
teeTraceBlockFetchDecision verb eliding tr =
Tracer $ \ev -> do
traceWith (teeTraceBlockFetchDecision' tr) ev
traceWith (teeTraceBlockFetchDecisionElide verb eliding tr) ev

traceWith (teeTraceBlockFetchDecision' meTr) ev
traceWith (teeTraceBlockFetchDecisionElide verb eliding bfdTr) ev
where
meTr = appendName "metrics" tr
bfdTr = appendName "BlockFetchDecision" tr

teeTraceBlockFetchDecision'
:: Trace IO Text
-> Tracer IO (WithSeverity [TraceLabelPeer peer (FetchDecision [Point (Header blk)])])
teeTraceBlockFetchDecision' tr =
Tracer $ \(WithSeverity _ peers) -> do
meta <- mkLOMeta Info Confidential
let tr' = appendName "peers" tr
traceNamedObject tr' (meta, LogValue "connectedPeers" . PureI $ fromIntegral $ length peers)
traceNamedObject tr (meta, LogValue "connectedPeers" . PureI $ fromIntegral $ length peers)

teeTraceBlockFetchDecisionElide
:: ( Eq peer
Expand Down
66 changes: 0 additions & 66 deletions configuration/cardano/mainnet-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,77 +57,11 @@
"minSeverity": "Info",
"options": {
"mapBackends": {
"cardano.node-metrics": [
"EKGViewBK"
],
"cardano.node.BlockFetchDecision.peers": [
"EKGViewBK"
],
"cardano.node.ChainDB.metrics": [
"EKGViewBK"
],
"cardano.node.Forge.metrics": [
"EKGViewBK"
],
"cardano.node.metrics": [
"EKGViewBK"
]
},
"mapSubtrace": {
"#ekgview": {
"contents": [
[
{
"contents": "cardano.epoch-validation.benchmark",
"tag": "Contains"
},
[
{
"contents": ".monoclock.basic.",
"tag": "Contains"
}
]
],
[
{
"contents": "cardano.epoch-validation.benchmark",
"tag": "Contains"
},
[
{
"contents": "diff.RTS.cpuNs.timed.",
"tag": "Contains"
}
]
],
[
{
"contents": "#ekgview.#aggregation.cardano.epoch-validation.benchmark",
"tag": "StartsWith"
},
[
{
"contents": "diff.RTS.gcNum.timed.",
"tag": "Contains"
}
]
]
],
"subtrace": "FilterTrace"
},
"benchmark": {
"contents": [
"GhcRtsStats",
"MonotonicClock"
],
"subtrace": "ObservableTrace"
},
"cardano.epoch-validation.utxo-stats": {
"subtrace": "NoTrace"
},
"cardano.node-metrics": {
"subtrace": "Neutral"
},
"cardano.node.metrics": {
"subtrace": "Neutral"
}
Expand Down
66 changes: 0 additions & 66 deletions configuration/cardano/shelley_qa-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,77 +59,11 @@
"minSeverity": "Debug",
"options": {
"mapBackends": {
"cardano.node-metrics": [
"EKGViewBK"
],
"cardano.node.BlockFetchDecision.peers": [
"EKGViewBK"
],
"cardano.node.ChainDB.metrics": [
"EKGViewBK"
],
"cardano.node.Forge.metrics": [
"EKGViewBK"
],
"cardano.node.metrics": [
"EKGViewBK"
]
},
"mapSubtrace": {
"#ekgview": {
"contents": [
[
{
"contents": "cardano.epoch-validation.benchmark",
"tag": "Contains"
},
[
{
"contents": ".monoclock.basic.",
"tag": "Contains"
}
]
],
[
{
"contents": "cardano.epoch-validation.benchmark",
"tag": "Contains"
},
[
{
"contents": "diff.RTS.cpuNs.timed.",
"tag": "Contains"
}
]
],
[
{
"contents": "#ekgview.#aggregation.cardano.epoch-validation.benchmark",
"tag": "StartsWith"
},
[
{
"contents": "diff.RTS.gcNum.timed.",
"tag": "Contains"
}
]
]
],
"subtrace": "FilterTrace"
},
"benchmark": {
"contents": [
"GhcRtsStats",
"MonotonicClock"
],
"subtrace": "ObservableTrace"
},
"cardano.epoch-validation.utxo-stats": {
"subtrace": "NoTrace"
},
"cardano.node-metrics": {
"subtrace": "Neutral"
},
"cardano.node.metrics": {
"subtrace": "Neutral"
}
Expand Down
14 changes: 3 additions & 11 deletions configuration/chairman/byron-shelley/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ApplicationVersion: 1
TurnOnLogging: True

# Enable the collection of various OS metrics such as memory and CPU use.
# These metrics are traced in the context name: 'cardano.node-metrics' and can
# These metrics are traced in the context name: 'cardano.node.metrics' and can
# be directed to the logs or monitoring backends.
TurnOnLogMetrics: True

Expand Down Expand Up @@ -97,7 +97,7 @@ defaultBackends:
# traceForwardTo:
# tag: RemotePipe
# contents: "logs/pipe"
#
#
# Example using Windows named pipes:
# traceForwardTo:
# tag: RemotePipe
Expand Down Expand Up @@ -254,16 +254,8 @@ options:
# an override and not an extension so anything matched here will not
# go to the default backend, only to the explicitly listed backends.
mapBackends:
cardano.node.BlockFetchDecision.peers:
- TraceForwarderBK
- EKGViewBK
cardano.node.ChainDB.metrics:
- TraceForwarderBK
- EKGViewBK
cardano.node.metrics:
- TraceForwarderBK
- EKGViewBK
cardano.node.Forge.metrics:
- EKGViewBK
cardano.node.release:
- TraceForwarderBK
Expand All @@ -278,7 +270,7 @@ options:
# redirects traced values to a specific scribe which is identified by its
# type and its name, separated by "::":
mapScribes:
cardano.node-metrics:
cardano.node.metrics:
- "FileSK::logs/mainnet.log"

# apply a filter on message severity on messages in a specific named context.
Expand Down
Loading

0 comments on commit 345fe9d

Please sign in to comment.