Skip to content

Commit e33308a

Browse files
committed
Review changes
Fixes for KES metrics and adoption of node version of trace-dispatcher cardano-node: calculate currentKESPeriod differently
1 parent 4ba83d6 commit e33308a

File tree

9 files changed

+55
-35
lines changed

9 files changed

+55
-35
lines changed

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/Tracers/ForgingThreadStats.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ instance MetaTrace ForgeThreadStats where
7979
"How many times was this node slot leader?")
8080
,("blocksForged",
8181
"How many blocks did this node forge?")
82-
,("lotsMissed",
82+
,("slotsMissed",
8383
"How many slots did this node miss?")
8484
]
8585

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

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,23 @@ deriving newtype instance ToJSON KESPeriod
5959

6060
instance LogFormatting HotKey.KESInfo where
6161
forMachine _dtal forgeStateInfo =
62-
let maxKesEvos = endKesPeriod - startKesPeriod
63-
oCertExpiryKesPeriod = startKesPeriod + maxKesEvos
64-
kesPeriodsUntilExpiry = max 0 (oCertExpiryKesPeriod - currKesPeriod)
62+
let currKesPeriod' = currKesPeriod + startKesPeriod
63+
maxKesEvos = endKesPeriod - startKesPeriod
64+
expiryKesPeriod = startKesPeriod + maxKesEvos
65+
kesPeriodsUntilExpiry = max 0 (expiryKesPeriod - currKesPeriod')
6566
in
6667
if kesPeriodsUntilExpiry > 7
6768
then mconcat
6869
[ "kind" .= String "KESInfo"
6970
, "startPeriod" .= startKesPeriod
70-
, "endPeriod" .= currKesPeriod
71+
, "endPeriod" .= currKesPeriod'
7172
, "evolution" .= endKesPeriod
7273
]
7374
else mconcat
7475
[ "kind" .= String "ExpiryLogMessage"
7576
, "keyExpiresIn" .= kesPeriodsUntilExpiry
7677
, "startPeriod" .= startKesPeriod
77-
, "endPeriod" .= currKesPeriod
78+
, "endPeriod" .= currKesPeriod'
7879
, "evolution" .= endKesPeriod
7980
]
8081
where
@@ -85,15 +86,17 @@ instance LogFormatting HotKey.KESInfo where
8586
} = forgeStateInfo
8687

8788
forHuman forgeStateInfo =
88-
let maxKesEvos = endKesPeriod - startKesPeriod
89-
oCertExpiryKesPeriod = startKesPeriod + maxKesEvos
90-
kesPeriodsUntilExpiry = max 0 (oCertExpiryKesPeriod - currKesPeriod)
89+
let currKesPeriod' = currKesPeriod + startKesPeriod
90+
maxKesEvos = endKesPeriod - startKesPeriod
91+
expiryKesPeriod = startKesPeriod + maxKesEvos
92+
kesPeriodsUntilExpiry = max 0 (expiryKesPeriod - currKesPeriod')
9193
in if kesPeriodsUntilExpiry > 7
9294
then "KES info startPeriod " <> (Text.pack . show) startKesPeriod
93-
<> " currPeriod " <> (Text.pack . show) currKesPeriod
95+
<> " currPeriod " <> (Text.pack . show) currKesPeriod'
9496
<> " endPeriod " <> (Text.pack . show) endKesPeriod
95-
<> (Text.pack . show) kesPeriodsUntilExpiry
96-
<> " KES periods."
97+
<> ", "
98+
<> (Text.pack . show) kesPeriodsUntilExpiry
99+
<> " KES periods until expiry."
97100
else "Operational key will expire in "
98101
<> (Text.pack . show) kesPeriodsUntilExpiry
99102
<> " KES periods."
@@ -105,17 +108,15 @@ instance LogFormatting HotKey.KESInfo where
105108
} = forgeStateInfo
106109

107110
asMetrics forgeStateInfo =
108-
let maxKesEvos = endKesPeriod - startKesPeriod
109-
oCertExpiryKesPeriod = startKesPeriod + maxKesEvos
111+
let currKesPeriod' = currKesPeriod + startKesPeriod
112+
maxKesEvos = endKesPeriod - startKesPeriod
113+
expiryKesPeriod = startKesPeriod + maxKesEvos
114+
kesPeriodsUntilExpiry = max 0 (expiryKesPeriod - currKesPeriod')
110115
in [
111-
IntM "operationalCertificateStartKESPeriod"
112-
(fromIntegral startKesPeriod)
113-
, IntM "operationalCertificateExpiryKESPeriod"
114-
(fromIntegral (startKesPeriod + maxKesEvos))
115-
, IntM "currentKESPeriod"
116-
(fromIntegral currKesPeriod)
117-
, IntM "remainingKESPeriods"
118-
(fromIntegral (max 0 (oCertExpiryKesPeriod - currKesPeriod)))
116+
IntM "operationalCertificateStartKESPeriod" (fromIntegral startKesPeriod)
117+
, IntM "operationalCertificateExpiryKESPeriod" (fromIntegral expiryKesPeriod)
118+
, IntM "currentKESPeriod" (fromIntegral currKesPeriod')
119+
, IntM "remainingKESPeriods" (fromIntegral kesPeriodsUntilExpiry)
119120
]
120121
where
121122
HotKey.KESInfo
@@ -129,9 +130,10 @@ instance MetaTrace HotKey.KESInfo where
129130
namespaceFor HotKey.KESInfo {} = Namespace [] ["StateInfo"]
130131

131132
severityFor (Namespace _ _) (Just forgeStateInfo) = Just $
132-
let maxKesEvos = endKesPeriod - startKesPeriod
133-
oCertExpiryKesPeriod = startKesPeriod + maxKesEvos
134-
kesPeriodsUntilExpiry = max 0 (oCertExpiryKesPeriod - currKesPeriod)
133+
let currKesPeriod' = currKesPeriod + startKesPeriod
134+
maxKesEvos = endKesPeriod - startKesPeriod
135+
expiryKesPeriod = startKesPeriod + maxKesEvos
136+
kesPeriodsUntilExpiry = max 0 (expiryKesPeriod - currKesPeriod')
135137
in if kesPeriodsUntilExpiry > 7
136138
then Info
137139
else if kesPeriodsUntilExpiry <= 1

trace-dispatcher/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Revision history for trace-dispatcher
22

3+
## 2.6.0
4+
5+
* With a metrics prefix that can be set in the configuration (tcMetricsPrefix)
6+
Metrics gets a type postfix (_int,_real, _counter)
7+
38
## 2.5.7
49

510
* With a prometheus metric with key label pairs. The value will always be "1"

trace-dispatcher/doc/trace-dispatcher.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ class MetaTrace a where
263263

264264
Metrics are seamlessly incorporated into the system through regular trace messages implementing the `asMetrics` function within the `LogFormatting` typeclass. Unlike other trace components, metrics are not subjected to filtering and are consistently provided. This occurs as long as the `EKGBackend` is configured for the message. The `EKGBackend` then forwards these metrics to `cardano-tracer` for additional processing. Subsequently, they are dispatched as Prometheus metrics, extending their utility and visibility.
265265

266+
It is essential to implement the metricsDoc function of the MetaTrace typeclass, as this information is utilized to optimize system performance.
267+
268+
The configuration option TraceOptionMetricsPrefix can be used to prepend a prefix to any trace message. For example, the prefix could be "cardano.node".
269+
266270
## Frequency Limiting in Trace Filtering
267271

268272
Frequency filtering is an integral aspect of trace filtering, offering an optional mechanism to limit the observable frequency of individual trace messages.
@@ -331,6 +335,9 @@ TraceOptionForwarder: # Configure the forwarder
331335

332336
# Frequency of Peer messages set to two seconds
333337
TraceOptionPeerFrequency: 2000
338+
339+
# Any metrics emittted will get this prefix
340+
TraceOptionMetricsPrefix: "cardano.node"
334341
```
335342

336343
The same in JSON looks like this:
@@ -362,7 +369,8 @@ The same in JSON looks like this:
362369
},
363370
"mode": "Initiator"
364371
},
365-
"TraceOptionPeerFrequency": 2000
372+
"TraceOptionPeerFrequency": 2000,
373+
"TraceOptionMetricsPrefix": "cardano.node"
366374
}
367375
```
368376

@@ -383,11 +391,11 @@ implement some advanced functionality.
383391

384392
Presently, the process of adding a new tracer involves making changes in three specific modules. However, we anticipate that this requirement will be simplified once the old tracing system is phased out. The current modules where modifications are needed to add a new tracer are:
385393

386-
- **Cardano.Node.Tracing.Tracers**
394+
- __Cardano.Node.Tracing.Tracers__
387395

388-
- **Cardano.Node.Tracing.Documentation**
396+
- __Cardano.Node.Tracing.Documentation__
389397

390-
- **Cardano.Node.Tracing.Consistency**
398+
- __Cardano.Node.Tracing.Consistency__
391399

392400
## Message Filtering based on Severity
393401

trace-dispatcher/trace-dispatcher.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.0
22

33
name: trace-dispatcher
4-
version: 2.5.8
4+
version: 2.6.0
55
synopsis: Tracers for Cardano
66
description: Package for development of simple and efficient tracers
77
based on the arrow based contra-tracer package

trace-resources/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Revision history for trace-resources
22

3+
## 0,2,3
4+
5+
* New names for metrics
6+
37
## 0.2.1.0 -- Nov 2023
48

59
* Optimized resource record creation on Linux

trace-resources/trace-resources.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.0
22

33
name: trace-resources
4-
version: 0.2.2.0
4+
version: 0.2.3
55
synopsis: Package for tracing resources for linux, mac and windows
66
description: Package for tracing resources for linux, mac and windows.
77
category: Cardano,

0 commit comments

Comments
 (0)