Skip to content

Commit

Permalink
Fixes for KES metrics and adoption of node version of trace-dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
jutaro committed Aug 2, 2024
1 parent 846fdf7 commit 7bf005f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cardano-node/cardano-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,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
27 changes: 12 additions & 15 deletions cardano-node/src/Cardano/Node/Tracing/Tracers/KESInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ deriving newtype instance ToJSON KESPeriod
instance LogFormatting HotKey.KESInfo where
forMachine _dtal forgeStateInfo =
let maxKesEvos = endKesPeriod - startKesPeriod
oCertExpiryKesPeriod = startKesPeriod + maxKesEvos
kesPeriodsUntilExpiry = max 0 (oCertExpiryKesPeriod - currKesPeriod)
expiryKesPeriod = startKesPeriod + maxKesEvos
kesPeriodsUntilExpiry = max 0 (expiryKesPeriod - currKesPeriod)
in
if kesPeriodsUntilExpiry > 7
then mconcat
Expand All @@ -86,8 +86,8 @@ instance LogFormatting HotKey.KESInfo where

forHuman forgeStateInfo =
let maxKesEvos = endKesPeriod - startKesPeriod
oCertExpiryKesPeriod = startKesPeriod + maxKesEvos
kesPeriodsUntilExpiry = max 0 (oCertExpiryKesPeriod - currKesPeriod)
expiryKesPeriod = startKesPeriod + maxKesEvos
kesPeriodsUntilExpiry = max 0 (expiryKesPeriod - currKesPeriod)
in if kesPeriodsUntilExpiry > 7
then "KES info startPeriod " <> (Text.pack . show) startKesPeriod
<> " currPeriod " <> (Text.pack . show) currKesPeriod
Expand All @@ -106,16 +106,13 @@ instance LogFormatting HotKey.KESInfo where

asMetrics forgeStateInfo =
let maxKesEvos = endKesPeriod - startKesPeriod
oCertExpiryKesPeriod = startKesPeriod + maxKesEvos
expiryKesPeriod = startKesPeriod + maxKesEvos
kesPeriodsUntilExpiry = max 0 (expiryKesPeriod - currKesPeriod)
in [
IntM "operationalCertificateStartKESPeriod"
(fromIntegral startKesPeriod)
, IntM "operationalCertificateExpiryKESPeriod"
(fromIntegral (startKesPeriod + maxKesEvos))
, IntM "currentKESPeriod"
(fromIntegral currKesPeriod)
, IntM "remainingKESPeriods"
(fromIntegral (max 0 (oCertExpiryKesPeriod - currKesPeriod)))
IntM "operationalCertificateStartKESPeriod" (fromIntegral startKesPeriod)
, IntM "operationalCertificateExpiryKESPeriod" (fromIntegral expiryKesPeriod)
, IntM "currentKESPeriod" (fromIntegral currKesPeriod)
, IntM "remainingKESPeriods" (fromIntegral kesPeriodsUntilExpiry)
]
where
HotKey.KESInfo
Expand All @@ -130,8 +127,8 @@ instance MetaTrace HotKey.KESInfo where

severityFor (Namespace _ _) (Just forgeStateInfo) = Just $
let maxKesEvos = endKesPeriod - startKesPeriod
oCertExpiryKesPeriod = startKesPeriod + maxKesEvos
kesPeriodsUntilExpiry = max 0 (oCertExpiryKesPeriod - currKesPeriod)
expiryKesPeriod = startKesPeriod + maxKesEvos
kesPeriodsUntilExpiry = max 0 (expiryKesPeriod - currKesPeriod)
in if kesPeriodsUntilExpiry > 7
then Info
else if kesPeriodsUntilExpiry <= 1
Expand Down

0 comments on commit 7bf005f

Please sign in to comment.