Skip to content

Commit 5debb0f

Browse files
authored
Merge pull request #5905 from IntersectMBO/jutaro/metrics_renaming
Names of metrics in the new tracing system
2 parents 51fa20e + e731543 commit 5debb0f

File tree

29 files changed

+461
-356
lines changed

29 files changed

+461
-356
lines changed

bench/tx-generator/src/Cardano/Benchmarking/Tracer.hs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,31 @@ module Cardano.Benchmarking.Tracer
2525
)
2626
where
2727

28-
import GHC.Generics
28+
import Cardano.Api
29+
30+
import Cardano.Benchmarking.LogTypes
31+
import Cardano.Benchmarking.Types
32+
import Cardano.Benchmarking.Version as Version
33+
import Cardano.Logging
34+
import Cardano.Node.Startup
35+
import Ouroboros.Network.IOManager (IOManager)
2936

37+
import Control.Monad (forM, guard)
3038
import Data.Aeson as A
3139
import qualified Data.Aeson.KeyMap as KeyMap
3240
import Data.Kind
33-
import qualified Data.Map.Strict as Map
34-
35-
import Control.Monad (forM, guard)
3641
import Data.List (find)
42+
import qualified Data.Map.Strict as Map
3743
import Data.Maybe (fromMaybe)
3844
import Data.Proxy
3945
import Data.Text (Text)
4046
import qualified Data.Text as Text
4147
import Data.Time.Clock
48+
import GHC.Generics
4249

43-
import Ouroboros.Network.IOManager (IOManager)
4450
import Trace.Forward.Utils.DataPoint
4551
import Trace.Forward.Utils.TraceObject
4652

47-
import Cardano.Api
48-
import Cardano.Logging
49-
import Cardano.Node.Startup
50-
51-
import Cardano.Benchmarking.LogTypes
52-
import Cardano.Benchmarking.Types
53-
import Cardano.Benchmarking.Version as Version
54-
5553
pattern TracerNameBench :: Text
5654
pattern TracerNameBench = "Benchmark"
5755
pattern TracerNameSubmit :: Text
@@ -178,6 +176,7 @@ initialTraceConfig = TraceConfig {
178176
, tcNodeName = Nothing
179177
, tcPeerFrequency = Just 2000 -- Every 2 seconds
180178
, tcResourceFrequency = Just 1000 -- Every second
179+
, tcMetricsPrefix = Nothing
181180
}
182181
where
183182
setMaxDetail :: Text -> ([Text], [ConfigOption])

cardano-node/ChangeLog.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
## Next version
44

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

13+
- Use metric names of old-tracing in new-tracing as well, and fix some metrics in new tracing.
14+
1315
## 8.2.1 -- August 2023
1416

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

19-
2021
## 8.2.0 -- July 2023
2122

2223
### node changes

cardano-node/cardano-node.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ library
206206
, strict-sop-core
207207
, strict-stm
208208
, time
209-
, trace-dispatcher ^>= 2.5.8
209+
, trace-dispatcher ^>= 2.6.0
210210
, trace-forward ^>= 2.2.6
211211
, trace-resources ^>= 0.2.2
212212
, tracer-transformers

cardano-node/src/Cardano/Node/Tracing/API.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ initTraceDispatcher nc p networkMagic nodeKernel p2pMode = do
8282
mkTracers trConfig = do
8383
ekgStore <- EKG.newStore
8484
EKG.registerGcMetrics ekgStore
85-
ekgTrace <- ekgTracer (Left ekgStore)
85+
ekgTrace <- ekgTracer trConfig (Left ekgStore)
8686

8787
stdoutTrace <- standardTracer
8888

@@ -113,7 +113,7 @@ initTraceDispatcher nc p networkMagic nodeKernel p2pMode = do
113113
p
114114
where
115115
forwarderBackendEnabled =
116-
any checkForwarder . concat . Map.elems $ tcOptions trConfig
116+
(any (any checkForwarder) . Map.elems) $ tcOptions trConfig
117117

118118
checkForwarder (ConfBackend backends') = Forwarder `elem` backends'
119119
checkForwarder _ = False

cardano-node/src/Cardano/Node/Tracing/Documentation.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import Cardano.Node.Tracing.Tracers.KESInfo ()
3636
import Cardano.Node.Tracing.Tracers.NodeToClient ()
3737
import Cardano.Node.Tracing.Tracers.NodeToNode ()
3838
import Cardano.Node.Tracing.Tracers.NodeVersion (NodeVersionTrace)
39-
4039
import Cardano.Node.Tracing.Tracers.NonP2P ()
4140
import Cardano.Node.Tracing.Tracers.P2P ()
4241
import Cardano.Node.Tracing.Tracers.Peer
@@ -104,6 +103,8 @@ import GHC.Generics (Generic)
104103
import Network.Mux (MuxTrace (..), WithMuxBearer (..))
105104
import qualified Network.Socket as Socket
106105
import qualified Options.Applicative as Opt
106+
import System.IO
107+
107108

108109
data TraceDocumentationCmd
109110
= TraceDocumentationCmd
@@ -764,6 +765,8 @@ docTracersSecondPhase ::
764765
-> DocTracer
765766
-> IO ()
766767
docTracersSecondPhase outputFileName trConfig bl = do
767-
res <- docuResultsToText bl trConfig
768-
T.writeFile outputFileName res
769-
pure ()
768+
content <- docuResultsToText bl trConfig
769+
handle <- openFile outputFileName WriteMode
770+
hSetEncoding handle utf8
771+
T.hPutStr handle content
772+
hClose handle

cardano-node/src/Cardano/Node/Tracing/Tracers/BlockReplayProgress.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ instance LogFormatting ReplayBlockStats where
3939
]
4040
forHuman ReplayBlockStats {..} = "Block replay progress " <> textShow rpsProgress <> "%"
4141
asMetrics ReplayBlockStats {..} =
42-
[DoubleM "ChainDB.BlockReplayProgress" rpsProgress]
42+
[DoubleM "blockReplayProgress" rpsProgress]
4343

4444
instance MetaTrace ReplayBlockStats where
4545
namespaceFor ReplayBlockStats {} = Namespace [] ["LedgerReplay"]
@@ -52,7 +52,7 @@ instance MetaTrace ReplayBlockStats where
5252
documentFor _ = Nothing
5353

5454
metricsDocFor (Namespace _ ["LedgerReplay"]) =
55-
[("ChainDB.BlockReplayProgress", "Progress in percent")]
55+
[("blockReplayProgress", "Progress in percent")]
5656
metricsDocFor _ = []
5757

5858
allNamespaces =

cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -525,20 +525,20 @@ instance ( LogFormatting (Header blk)
525525
asMetrics (ChainDB.SwitchedToAFork _warnings selChangedInfo _oldChain newChain) =
526526
let ChainInformation { slots, blocks, density, epoch, slotInEpoch } =
527527
chainInformation selChangedInfo newChain 0
528-
in [ DoubleM "ChainDB.Density" (fromRational density)
529-
, IntM "ChainDB.SlotNum" (fromIntegral slots)
530-
, IntM "ChainDB.BlockNum" (fromIntegral blocks)
531-
, IntM "ChainDB.SlotInEpoch" (fromIntegral slotInEpoch)
532-
, IntM "ChainDB.Epoch" (fromIntegral (unEpochNo epoch))
528+
in [ DoubleM "density" (fromRational density)
529+
, IntM "slotNum" (fromIntegral slots)
530+
, IntM "blockNum" (fromIntegral blocks)
531+
, IntM "slotInEpoch" (fromIntegral slotInEpoch)
532+
, IntM "epoch" (fromIntegral (unEpochNo epoch))
533533
]
534534
asMetrics (ChainDB.AddedToCurrentChain _warnings selChangedInfo _oldChain newChain) =
535535
let ChainInformation { slots, blocks, density, epoch, slotInEpoch } =
536536
chainInformation selChangedInfo newChain 0
537-
in [ DoubleM "ChainDB.Density" (fromRational density)
538-
, IntM "ChainDB.SlotNum" (fromIntegral slots)
539-
, IntM "ChainDB.BlockNum" (fromIntegral blocks)
540-
, IntM "ChainDB.SlotInEpoch" (fromIntegral slotInEpoch)
541-
, IntM "ChainDB.Epoch" (fromIntegral (unEpochNo epoch))
537+
in [ DoubleM "density" (fromRational density)
538+
, IntM "slotNum" (fromIntegral slots)
539+
, IntM "blockNum" (fromIntegral blocks)
540+
, IntM "slotInEpoch" (fromIntegral slotInEpoch)
541+
, IntM "epoch" (fromIntegral (unEpochNo epoch))
542542
]
543543
asMetrics _ = []
544544

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

640640
metricsDocFor (Namespace _ ["SwitchedToAFork"]) =
641-
[ ( "ChainDB.Density"
641+
[ ( "density"
642642
, mconcat
643643
[ "The actual number of blocks created over the maximum expected number"
644644
, " of blocks that could be created over the span of the last @k@ blocks."
645645
]
646646
)
647-
, ( "ChainDB.SlotNum"
647+
, ( "slotNum"
648648
, "Number of slots in this chain fragment."
649649
)
650-
, ( "ChainDB.Blocks"
650+
, ( "blockNum"
651651
, "Number of blocks in this chain fragment."
652652
)
653-
, ( "ChainDB.SlotInEpoch"
653+
, ( "slotInEpoch"
654654
, mconcat
655655
[ "Relative slot number of the tip of the current chain within the"
656656
, " epoch.."
657657
]
658658
)
659-
, ( "ChainDB.Epoch"
659+
, ( "epoch"
660660
, "In which epoch is the tip of the current chain."
661661
)
662662
]
663663
metricsDocFor (Namespace _ ["AddedToCurrentChain"]) =
664-
[ ( "ChainDB.Density"
664+
[ ( "density"
665665
, mconcat
666666
[ "The actual number of blocks created over the maximum expected number"
667667
, " of blocks that could be created over the span of the last @k@ blocks."
668668
]
669669
)
670-
, ( "ChainDB.SlotNum"
670+
, ( "slotNum"
671671
, "Number of slots in this chain fragment."
672672
)
673-
, ( "ChainDB.Blocks"
673+
, ( "blockNum"
674674
, "Number of blocks in this chain fragment."
675675
)
676-
, ( "ChainDB.SlotInEpoch"
676+
, ( "slotInEpoch"
677677
, mconcat
678678
[ "Relative slot number of the tip of the current chain within the"
679679
, " epoch.."
680680
]
681681
)
682-
, ( "ChainDB.Epoch"
682+
, ( "epoch"
683683
, "In which epoch is the tip of the current chain."
684684
)
685685
]

0 commit comments

Comments
 (0)