Skip to content

Commit

Permalink
Merge pull request #5905 from IntersectMBO/jutaro/metrics_renaming
Browse files Browse the repository at this point in the history
Names of metrics in the new tracing system
  • Loading branch information
mgmeier authored Sep 5, 2024
2 parents 51fa20e + e731543 commit 5debb0f
Show file tree
Hide file tree
Showing 29 changed files with 461 additions and 356 deletions.
25 changes: 12 additions & 13 deletions bench/tx-generator/src/Cardano/Benchmarking/Tracer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,31 @@ module Cardano.Benchmarking.Tracer
)
where

import GHC.Generics
import Cardano.Api

import Cardano.Benchmarking.LogTypes
import Cardano.Benchmarking.Types
import Cardano.Benchmarking.Version as Version
import Cardano.Logging
import Cardano.Node.Startup
import Ouroboros.Network.IOManager (IOManager)

import Control.Monad (forM, guard)
import Data.Aeson as A
import qualified Data.Aeson.KeyMap as KeyMap
import Data.Kind
import qualified Data.Map.Strict as Map

import Control.Monad (forM, guard)
import Data.List (find)
import qualified Data.Map.Strict as Map
import Data.Maybe (fromMaybe)
import Data.Proxy
import Data.Text (Text)
import qualified Data.Text as Text
import Data.Time.Clock
import GHC.Generics

import Ouroboros.Network.IOManager (IOManager)
import Trace.Forward.Utils.DataPoint
import Trace.Forward.Utils.TraceObject

import Cardano.Api
import Cardano.Logging
import Cardano.Node.Startup

import Cardano.Benchmarking.LogTypes
import Cardano.Benchmarking.Types
import Cardano.Benchmarking.Version as Version

pattern TracerNameBench :: Text
pattern TracerNameBench = "Benchmark"
pattern TracerNameSubmit :: Text
Expand Down Expand Up @@ -178,6 +176,7 @@ initialTraceConfig = TraceConfig {
, tcNodeName = Nothing
, tcPeerFrequency = Just 2000 -- Every 2 seconds
, tcResourceFrequency = Just 1000 -- Every second
, tcMetricsPrefix = Nothing
}
where
setMaxDetail :: Text -> ([Text], [ConfigOption])
Expand Down
7 changes: 4 additions & 3 deletions cardano-node/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
## Next version

- Use p2p network stack by default, warn when using the legacy network stack.
- Deprecate some CLI flags corresponding to low-level consensus options. They are
still accepted but a warning is emitted on startup on stderr suggesting to set
- Deprecate some CLI flags corresponding to low-level consensus options. They are
still accepted but a warning is emitted on startup on stderr suggesting to set
them in the configuration file instead:
- `--mempool-capacity-override` and `--no-mempool-capacity-override` can be set in the configuration file via the key `MempoolCapacityBytesOverride`.
- `--snapshot-interval` can be set in the configuration file via the key `SnapshotInterval`.
- `--num-of-disk-snapshots` can be set in the configuration file via the key `NumOfDiskSnapshots`.

- Use metric names of old-tracing in new-tracing as well, and fix some metrics in new tracing.

## 8.2.1 -- August 2023

- prevent SIGHUP from killing node during ledger replay
- upgrade cardano-cli to 8.4.1.0
- upgrade cardano-api to 8.10.2.0


## 8.2.0 -- July 2023

### node changes
Expand Down
2 changes: 1 addition & 1 deletion cardano-node/cardano-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ library
, strict-sop-core
, strict-stm
, time
, trace-dispatcher ^>= 2.5.8
, trace-dispatcher ^>= 2.6.0
, trace-forward ^>= 2.2.6
, trace-resources ^>= 0.2.2
, tracer-transformers
Expand Down
4 changes: 2 additions & 2 deletions cardano-node/src/Cardano/Node/Tracing/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ initTraceDispatcher nc p networkMagic nodeKernel p2pMode = do
mkTracers trConfig = do
ekgStore <- EKG.newStore
EKG.registerGcMetrics ekgStore
ekgTrace <- ekgTracer (Left ekgStore)
ekgTrace <- ekgTracer trConfig (Left ekgStore)

stdoutTrace <- standardTracer

Expand Down Expand Up @@ -113,7 +113,7 @@ initTraceDispatcher nc p networkMagic nodeKernel p2pMode = do
p
where
forwarderBackendEnabled =
any checkForwarder . concat . Map.elems $ tcOptions trConfig
(any (any checkForwarder) . Map.elems) $ tcOptions trConfig

checkForwarder (ConfBackend backends') = Forwarder `elem` backends'
checkForwarder _ = False
11 changes: 7 additions & 4 deletions cardano-node/src/Cardano/Node/Tracing/Documentation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import Cardano.Node.Tracing.Tracers.KESInfo ()
import Cardano.Node.Tracing.Tracers.NodeToClient ()
import Cardano.Node.Tracing.Tracers.NodeToNode ()
import Cardano.Node.Tracing.Tracers.NodeVersion (NodeVersionTrace)

import Cardano.Node.Tracing.Tracers.NonP2P ()
import Cardano.Node.Tracing.Tracers.P2P ()
import Cardano.Node.Tracing.Tracers.Peer
Expand Down Expand Up @@ -104,6 +103,8 @@ import GHC.Generics (Generic)
import Network.Mux (MuxTrace (..), WithMuxBearer (..))
import qualified Network.Socket as Socket
import qualified Options.Applicative as Opt
import System.IO


data TraceDocumentationCmd
= TraceDocumentationCmd
Expand Down Expand Up @@ -764,6 +765,8 @@ docTracersSecondPhase ::
-> DocTracer
-> IO ()
docTracersSecondPhase outputFileName trConfig bl = do
res <- docuResultsToText bl trConfig
T.writeFile outputFileName res
pure ()
content <- docuResultsToText bl trConfig
handle <- openFile outputFileName WriteMode
hSetEncoding handle utf8
T.hPutStr handle content
hClose handle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ instance LogFormatting ReplayBlockStats where
]
forHuman ReplayBlockStats {..} = "Block replay progress " <> textShow rpsProgress <> "%"
asMetrics ReplayBlockStats {..} =
[DoubleM "ChainDB.BlockReplayProgress" rpsProgress]
[DoubleM "blockReplayProgress" rpsProgress]

instance MetaTrace ReplayBlockStats where
namespaceFor ReplayBlockStats {} = Namespace [] ["LedgerReplay"]
Expand All @@ -52,7 +52,7 @@ instance MetaTrace ReplayBlockStats where
documentFor _ = Nothing

metricsDocFor (Namespace _ ["LedgerReplay"]) =
[("ChainDB.BlockReplayProgress", "Progress in percent")]
[("blockReplayProgress", "Progress in percent")]
metricsDocFor _ = []

allNamespaces =
Expand Down
40 changes: 20 additions & 20 deletions cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -525,20 +525,20 @@ instance ( LogFormatting (Header blk)
asMetrics (ChainDB.SwitchedToAFork _warnings selChangedInfo _oldChain newChain) =
let ChainInformation { slots, blocks, density, epoch, slotInEpoch } =
chainInformation selChangedInfo newChain 0
in [ DoubleM "ChainDB.Density" (fromRational density)
, IntM "ChainDB.SlotNum" (fromIntegral slots)
, IntM "ChainDB.BlockNum" (fromIntegral blocks)
, IntM "ChainDB.SlotInEpoch" (fromIntegral slotInEpoch)
, IntM "ChainDB.Epoch" (fromIntegral (unEpochNo epoch))
in [ DoubleM "density" (fromRational density)
, IntM "slotNum" (fromIntegral slots)
, IntM "blockNum" (fromIntegral blocks)
, IntM "slotInEpoch" (fromIntegral slotInEpoch)
, IntM "epoch" (fromIntegral (unEpochNo epoch))
]
asMetrics (ChainDB.AddedToCurrentChain _warnings selChangedInfo _oldChain newChain) =
let ChainInformation { slots, blocks, density, epoch, slotInEpoch } =
chainInformation selChangedInfo newChain 0
in [ DoubleM "ChainDB.Density" (fromRational density)
, IntM "ChainDB.SlotNum" (fromIntegral slots)
, IntM "ChainDB.BlockNum" (fromIntegral blocks)
, IntM "ChainDB.SlotInEpoch" (fromIntegral slotInEpoch)
, IntM "ChainDB.Epoch" (fromIntegral (unEpochNo epoch))
in [ DoubleM "density" (fromRational density)
, IntM "slotNum" (fromIntegral slots)
, IntM "blockNum" (fromIntegral blocks)
, IntM "slotInEpoch" (fromIntegral slotInEpoch)
, IntM "epoch" (fromIntegral (unEpochNo epoch))
]
asMetrics _ = []

Expand Down Expand Up @@ -638,48 +638,48 @@ instance MetaTrace (ChainDB.TraceAddBlockEvent blk) where
detailsFor _ _ = Just DNormal

metricsDocFor (Namespace _ ["SwitchedToAFork"]) =
[ ( "ChainDB.Density"
[ ( "density"
, mconcat
[ "The actual number of blocks created over the maximum expected number"
, " of blocks that could be created over the span of the last @k@ blocks."
]
)
, ( "ChainDB.SlotNum"
, ( "slotNum"
, "Number of slots in this chain fragment."
)
, ( "ChainDB.Blocks"
, ( "blockNum"
, "Number of blocks in this chain fragment."
)
, ( "ChainDB.SlotInEpoch"
, ( "slotInEpoch"
, mconcat
[ "Relative slot number of the tip of the current chain within the"
, " epoch.."
]
)
, ( "ChainDB.Epoch"
, ( "epoch"
, "In which epoch is the tip of the current chain."
)
]
metricsDocFor (Namespace _ ["AddedToCurrentChain"]) =
[ ( "ChainDB.Density"
[ ( "density"
, mconcat
[ "The actual number of blocks created over the maximum expected number"
, " of blocks that could be created over the span of the last @k@ blocks."
]
)
, ( "ChainDB.SlotNum"
, ( "slotNum"
, "Number of slots in this chain fragment."
)
, ( "ChainDB.Blocks"
, ( "blockNum"
, "Number of blocks in this chain fragment."
)
, ( "ChainDB.SlotInEpoch"
, ( "slotInEpoch"
, mconcat
[ "Relative slot number of the tip of the current chain within the"
, " epoch.."
]
)
, ( "ChainDB.Epoch"
, ( "epoch"
, "In which epoch is the tip of the current chain."
)
]
Expand Down
Loading

0 comments on commit 5debb0f

Please sign in to comment.