Skip to content

Commit a8730d1

Browse files
authored
Merge pull request #6187 from IntersectMBO/new-tracing/fix-metrics
New Tracing metrics hotfixes; nix LMDB config
2 parents e28cbf5 + b63c369 commit a8730d1

File tree

5 files changed

+52
-43
lines changed

5 files changed

+52
-43
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ mkDiffusionTracersExtra configReflection trBase trForward mbTrEKG _trDataPoint t
654654
configureTracers configReflection trConfig [inboundGovernorTransitionsTr]
655655

656656
!localConnectionManagerTr <- mkCardanoTracer
657-
trBase trForward mbTrEKG
657+
trBase trForward Nothing -- never conflate metrics of the same name with those originating from `connectionManagerTr`
658658
["Net", "ConnectionManager", "Local"]
659659
configureTracers configReflection trConfig [localConnectionManagerTr]
660660

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

+11-10
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ data ForgingStats
2929
fsNodeCannotForgeNum :: !Int
3030
, fsNodeIsLeaderNum :: !Int
3131
, fsBlocksForgedNum :: !Int
32-
, fsLastSlot :: !Int
32+
, fsLastSlot :: !Int -- Internal value, to track last slot.
3333
, fsSlotsMissedNum :: !Int
3434
}
3535

@@ -73,8 +73,6 @@ instance MetaTrace ForgingStats where
7373
"How many blocks did this node forge?")
7474
,("slotsMissed",
7575
"How many slots did this node miss?")
76-
,("lastSlot",
77-
"")
7876
]
7977

8078
allNamespaces = [Namespace [] ["ForgingStats"]]
@@ -102,21 +100,24 @@ calculateForgingStats :: MonadIO m
102100
-> m ForgingStats
103101
calculateForgingStats stats _context
104102
(Left TraceNodeCannotForge {}) =
105-
pure $ stats { fsNodeCannotForgeNum = fsNodeCannotForgeNum stats + 1 }
103+
pure $ stats { fsNodeCannotForgeNum = fsNodeCannotForgeNum stats + 1 }
106104
calculateForgingStats stats _context
107-
(Left TraceNodeIsLeader {}) =
108-
pure $ stats { fsNodeIsLeaderNum = fsNodeIsLeaderNum stats + 1 }
105+
(Left (TraceNodeIsLeader (SlotNo slot))) =
106+
pure $ stats
107+
{ fsNodeIsLeaderNum = fsNodeIsLeaderNum stats + 1, fsLastSlot = fromIntegral slot }
109108
calculateForgingStats stats _context
110109
(Left TraceForgedBlock {}) =
111-
pure $ stats { fsBlocksForgedNum = fsBlocksForgedNum stats + 1 }
110+
pure $ stats { fsBlocksForgedNum = fsBlocksForgedNum stats + 1 }
112111
calculateForgingStats stats _context
113112
(Left (TraceNodeNotLeader (SlotNo slot'))) =
113+
-- Node is not a leader again: The number of blocks forged by
114+
-- this node should now be equal to the number of slots when
115+
-- this node was a leader.
114116
let slot = fromIntegral slot'
115117
in if fsLastSlot stats == 0 || succ (fsLastSlot stats) == slot
116118
then pure $ stats { fsLastSlot = slot }
117119
else
118-
let missed = (slot - fsLastSlot stats)
120+
let missed = slot - fsLastSlot stats
119121
in pure $ stats { fsLastSlot = slot
120-
, fsSlotsMissedNum = fsSlotsMissedNum stats + missed}
121-
122+
, fsSlotsMissedNum = fsSlotsMissedNum stats + missed }
122123
calculateForgingStats stats _context _message = pure stats

nix/nixos/cardano-node-service.nix

+28-26
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,33 @@ let
8080
})) cfg.extraNodeConfig;
8181
baseInstanceConfig =
8282
i:
83-
if !cfg.useLegacyTracing
84-
then baseConfig //
85-
{ ## XXX: remove once legacy tracing is dropped
86-
minSeverity = "Critical";
87-
setupScribes = [];
88-
setupBackends = [];
89-
defaultScribes = [];
90-
defaultBackends = [];
91-
options = {};
92-
}
93-
else baseConfig //
94-
{
95-
UseTraceDispatcher = false;
96-
} //
97-
(optionalAttrs (baseConfig ? hasEKG) {
98-
hasEKG = baseConfig.hasEKG + i;
99-
}) //
100-
(optionalAttrs (baseConfig ? hasPrometheus) {
101-
hasPrometheus = map (n: if isInt n then n + i else n) baseConfig.hasPrometheus;
102-
});
83+
( if !cfg.useLegacyTracing
84+
then baseConfig //
85+
{ ## XXX: remove once legacy tracing is dropped
86+
minSeverity = "Critical";
87+
setupScribes = [];
88+
setupBackends = [];
89+
defaultScribes = [];
90+
defaultBackends = [];
91+
options = {};
92+
}
93+
else baseConfig //
94+
{
95+
UseTraceDispatcher = false;
96+
} //
97+
(optionalAttrs (baseConfig ? hasEKG) {
98+
hasEKG = baseConfig.hasEKG + i;
99+
}) //
100+
(optionalAttrs (baseConfig ? hasPrometheus) {
101+
hasPrometheus = map (n: if isInt n then n + i else n) baseConfig.hasPrometheus;
102+
})
103+
)
104+
// optionalAttrs (cfg.withUtxoHdLmdb i){
105+
LedgerDB = {
106+
Backend = "V1LMDB";
107+
LiveTablesPath = cfg.lmdbDatabasePath i;
108+
};
109+
};
103110
in i: let
104111
instanceConfig = recursiveUpdate (baseInstanceConfig i) (cfg.extraNodeInstanceConfig i);
105112
nodeConfigFile = if (cfg.nodeConfigFile != null) then cfg.nodeConfigFile
@@ -133,10 +140,6 @@ let
133140
];
134141
};
135142
instanceDbPath = cfg.databasePath i;
136-
utxoLmdbParams = ["--utxos-on-disk"]
137-
++ lib.optionals (cfg.lmdbDatabasePath i != null)
138-
[ "--utxos-database-path ${cfg.lmdbDatabasePath i}"
139-
];
140143
cmd = builtins.filter (x: x != "") [
141144
"${cfg.executable} run"
142145
"--config ${nodeConfigFile}"
@@ -152,8 +155,7 @@ let
152155
"--tracer-socket-path-accept ${cfg.tracerSocketPathAccept i}"
153156
] ++ lib.optionals (cfg.tracerSocketPathConnect i != null) [
154157
"--tracer-socket-path-connect ${cfg.tracerSocketPathConnect i}"
155-
] ++ lib.optionals (cfg.withUtxoHdLmdb i) utxoLmdbParams
156-
++ consensusParams.${cfg.nodeConfig.Protocol} ++ cfg.extraArgs ++ cfg.rtsArgs;
158+
] ++ consensusParams.${cfg.nodeConfig.Protocol} ++ cfg.extraArgs ++ cfg.rtsArgs;
157159
in ''
158160
echo "Starting: ${concatStringsSep "\"\n echo \"" cmd}"
159161
echo "..or, once again, in a single line:"

nix/workbench/service/nodes.nix

+12-4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ let
5353
then go {} (__head eras) (__tail eras)
5454
else throw "configHardforksIntoEra: unknown era '${era}'";
5555

56+
liveTablesPath = i:
57+
if (profile.cluster ? "ssd_directory" && profile.cluster.ssd_directory != null)
58+
then "${profile.cluster.ssd_directory}/lmdb-node-${toString i}"
59+
else null;
60+
5661
##
5762
## nodeServiceConfig :: NodeSpec -> ServiceConfig
5863
##
@@ -70,10 +75,7 @@ let
7075

7176
# Allow for local clusters to have multiple LMDB directories in the same physical ssd_directory
7277
withUtxoHdLmdb = profile.node.utxo_lmdb;
73-
lmdbDatabasePath =
74-
if (profile.cluster ? "ssd_directory" && profile.cluster.ssd_directory != null)
75-
then "${profile.cluster.ssd_directory}/lmdb-node-${toString i}"
76-
else null;
78+
lmdbDatabasePath = liveTablesPath i;
7779

7880
## Combine:
7981
## 0. baseNodeConfig (coming cardanoLib's testnet environ)
@@ -115,6 +117,12 @@ let
115117
ShelleyGenesisFile = "../genesis/genesis-shelley.json";
116118
AlonzoGenesisFile = "../genesis/genesis.alonzo.json";
117119
ConwayGenesisFile = "../genesis/genesis.conway.json";
120+
} // optionalAttrs profile.node.utxo_lmdb
121+
{
122+
LedgerDB = {
123+
Backend = "V1LMDB";
124+
LiveTablesPath = liveTablesPath i;
125+
};
118126
})
119127
(if __hasAttr "preset" profile && profile.preset != null
120128
## It's either an undisturbed preset,

nix/workbench/service/tracing.nix

-2
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ let
9797
## Silencing the tracers below aims at having a comparable log line rates (msgs per second) on UTxO-HD and regular nodes.
9898
"ChainDB.LedgerEvent.Forker".severity = "Silence";
9999
"Mempool.AttemptAdd".severity = "Silence";
100-
"Mempool.AttemptingSync".severity = "Silence";
101100
"Mempool.LedgerFound".severity = "Silence";
102101
"Mempool.LedgerNotFound".severity = "Silence";
103-
"Mempool.SyncDone".severity = "Silence";
104102
"Mempool.SyncNotNeeded".severity = "Silence";
105103

106104
## enable this to investigate tx validation errors, e.g. fee to small for Plutus script txns

0 commit comments

Comments
 (0)