Skip to content

Commit 998a6a6

Browse files
authored
Merge pull request #6306 from IntersectMBO/amesgen/gsm-chores
Better GSM tracing and metrics
2 parents 1df3e19 + 478df21 commit 998a6a6

File tree

2 files changed

+42
-12
lines changed

2 files changed

+42
-12
lines changed

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

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,41 +2095,65 @@ instance ( LogFormatting selection
20952095

20962096
forHuman = showT
20972097

2098+
asMetrics =
2099+
\case
2100+
GsmEventEnterCaughtUp {} -> [caughtUp]
2101+
GsmEventLeaveCaughtUp {} -> [preSyncing]
2102+
GsmEventPreSyncingToSyncing {} -> [syncing]
2103+
GsmEventSyncingToPreSyncing {} -> [preSyncing]
2104+
where
2105+
preSyncing = IntM "GSM.state" 0
2106+
syncing = IntM "GSM.state" 1
2107+
caughtUp = IntM "GSM.state" 2
2108+
20982109
instance MetaTrace (TraceGsmEvent selection) where
20992110
namespaceFor =
21002111
\case
21012112
GsmEventEnterCaughtUp {} -> Namespace [] ["EnterCaughtUp"]
21022113
GsmEventLeaveCaughtUp {} -> Namespace [] ["LeaveCaughtUp"]
2103-
GsmEventPreSyncingToSyncing {} -> Namespace [] ["GsmEventPreSyncingToSyncing"]
2104-
GsmEventSyncingToPreSyncing {} -> Namespace [] ["GsmEventSyncingToPreSyncing"]
2114+
GsmEventPreSyncingToSyncing {} -> Namespace [] ["PreSyncingToSyncing"]
2115+
GsmEventSyncingToPreSyncing {} -> Namespace [] ["SyncingToPreSyncing"]
21052116

21062117
severityFor ns _ =
21072118
case ns of
2108-
Namespace _ ["EnterCaughtUp"] -> Just Info
2109-
Namespace _ ["LeaveCaughtUp"] -> Just Info
2110-
Namespace _ ["GsmEventPreSyncingToSyncing"] -> Just Info
2111-
Namespace _ ["GsmEventSyncingToPreSyncing"] -> Just Info
2112-
Namespace _ _ -> Nothing
2119+
Namespace _ ["EnterCaughtUp"] -> Just Notice
2120+
Namespace _ ["LeaveCaughtUp"] -> Just Warning
2121+
Namespace _ ["PreSyncingToSyncing"] -> Just Notice
2122+
Namespace _ ["SyncingToPreSyncing"] -> Just Notice
2123+
Namespace _ _ -> Nothing
21132124

21142125
documentFor = \case
21152126
Namespace _ ["EnterCaughtUp"] ->
21162127
Just "Node is caught up"
21172128
Namespace _ ["LeaveCaughtUp"] ->
21182129
Just "Node is not caught up"
21192130

2120-
Namespace _ ["GsmEventPreSyncingToSyncing"] ->
2131+
Namespace _ ["PreSyncingToSyncing"] ->
21212132
Just "The Honest Availability Assumption is now satisfied"
2122-
Namespace _ ["GsmEventSyncingToPreSyncing"] ->
2133+
Namespace _ ["SyncingToPreSyncing"] ->
21232134
Just "The Honest Availability Assumption is no longer satisfied"
21242135

21252136
Namespace _ _ ->
21262137
Nothing
21272138

2139+
metricsDocFor = \case
2140+
Namespace _ ["EnterCaughtUp"] -> doc
2141+
Namespace _ ["LeaveCaughtUp"] -> doc
2142+
Namespace _ ["PreSyncingToSyncing"] -> doc
2143+
Namespace _ ["SyncingToPreSyncing"] -> doc
2144+
Namespace _ _ -> []
2145+
where
2146+
doc =
2147+
[ ("GSM.state"
2148+
, "The state of the Genesis State Machine. 0 = PreSyncing, 1 = Syncing, 2 = CaughtUp."
2149+
)
2150+
]
2151+
21282152
allNamespaces =
21292153
[ Namespace [] ["EnterCaughtUp"]
21302154
, Namespace [] ["LeaveCaughtUp"]
2131-
, Namespace [] ["GsmEventPreSyncingToSyncing"]
2132-
, Namespace [] ["GsmEventSyncingToPreSyncing"]
2155+
, Namespace [] ["PreSyncingToSyncing"]
2156+
, Namespace [] ["SyncingToPreSyncing"]
21332157
]
21342158

21352159
--------------------------------------------------------------------------------

cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,8 +1756,14 @@ instance ToObject (TraceLocalTxSubmissionServerEvent blk) where
17561756
mconcat [ "kind" .= String "TraceLocalTxSubmissionServerEvent" ]
17571757

17581758
instance HasPrivacyAnnotation (TraceGsmEvent selection) where
1759+
17591760
instance HasSeverityAnnotation (TraceGsmEvent selection) where
1760-
getSeverityAnnotation _ = Info
1761+
getSeverityAnnotation = \case
1762+
GsmEventEnterCaughtUp{} -> Notice
1763+
GsmEventLeaveCaughtUp{} -> Warning
1764+
GsmEventPreSyncingToSyncing{} -> Notice
1765+
GsmEventSyncingToPreSyncing{} -> Notice
1766+
17611767
instance ToObject selection => Transformable Text IO (TraceGsmEvent selection) where
17621768
trTransformer = trStructured
17631769

0 commit comments

Comments
 (0)