33{-# LANGUAGE FlexibleInstances #-}
44{-# LANGUAGE GADTs #-}
55{-# LANGUAGE LambdaCase #-}
6+ {-# LANGUAGE StandaloneDeriving #-}
67
78{-# OPTIONS_GHC -Wno-orphans #-}
89
@@ -22,6 +23,7 @@ import Cardano.Api (textShow)
2223
2324import Cardano.Logging
2425
26+ import Control.DeepSeq (NFData )
2527import Data.Aeson
2628import Data.Text (Text )
2729import Data.Time.Clock
@@ -41,9 +43,17 @@ import qualified Cardano.Node.Startup as Startup
4143import Cardano.Slotting.Slot (EpochNo , SlotNo (.. ), WithOrigin )
4244import Cardano.Tracing.OrphanInstances.Network ()
4345
44- instance FromJSON ChunkNo
46+ deriving instance FromJSON ChunkNo
4547
46- instance ToJSON ChunkNo
48+ deriving instance ToJSON ChunkNo
49+
50+ deriving instance NFData ChunkNo
51+
52+ deriving instance Generic NPV. NodeToNodeVersion
53+ deriving instance NFData NPV. NodeToNodeVersion
54+
55+ deriving instance Generic NPV. NodeToClientVersion
56+ deriving instance NFData NPV. NodeToClientVersion
4757
4858data OpeningDbs
4959 = StartedOpeningImmutableDB
@@ -54,23 +64,31 @@ data OpeningDbs
5464 | OpenedLgrDB
5565 deriving (Generic , FromJSON , ToJSON )
5666
67+ deriving instance (NFData OpeningDbs )
68+
5769data Replays
5870 = ReplayFromGenesis (WithOrigin SlotNo )
5971 | ReplayFromSnapshot SlotNo (WithOrigin SlotNo ) (WithOrigin SlotNo )
6072 | ReplayedBlock SlotNo (WithOrigin SlotNo ) (WithOrigin SlotNo )
6173 deriving (Generic , FromJSON , ToJSON )
6274
75+ deriving instance (NFData Replays )
76+
6377data InitChainSelection
6478 = InitChainStartedSelection
6579 | InitChainSelected
6680 deriving (Generic , FromJSON , ToJSON )
6781
82+ deriving instance (NFData InitChainSelection )
83+
6884type SyncPercentage = Double
6985
7086data AddedToCurrentChain
7187 = AddedToCurrentChain ! EpochNo ! SlotNo ! SyncPercentage
7288 deriving (Generic , FromJSON , ToJSON )
7389
90+ deriving instance (NFData AddedToCurrentChain )
91+
7492data StartupState
7593 = StartupSocketConfigError Text
7694 | StartupDBValidation
@@ -81,6 +99,8 @@ data StartupState
8199 | WarningDevelopmentNodeToClientVersions [NPV. NodeToClientVersion ]
82100 deriving (Generic , FromJSON , ToJSON )
83101
102+ deriving instance (NFData StartupState )
103+
84104-- | The representation of the current state of node.
85105-- All node states prior to tracing system going online are effectively invisible.
86106data NodeState
@@ -94,22 +114,24 @@ data NodeState
94114 | NodeShutdown ShutdownTrace
95115 deriving (Generic , FromJSON , ToJSON )
96116
117+ deriving instance (NFData NodeState )
118+
97119instance LogFormatting NodeState where
98120 forMachine _ = \ case
99121 NodeOpeningDbs x -> mconcat
100- [" openingDb" .= toJSON x]
122+ [ " kind " .= String " NodeOpeningDbs " , " openingDb" .= toJSON x]
101123 NodeReplays x -> mconcat
102- [" replays" .= toJSON x]
124+ [ " kind " .= String " NodeReplays " , " replays" .= toJSON x]
103125 NodeInitChainSelection x -> mconcat
104- [" chainSel" .= toJSON x]
126+ [ " kind " .= String " NodeInitChainSelection " , " chainSel" .= toJSON x]
105127 NodeKernelOnline -> mconcat
106- []
128+ [ " kind " .= String " NodeInitChainSelection " ]
107129 NodeAddBlock x -> mconcat
108- [" addBlock" .= toJSON x]
130+ [ " kind " .= String " NodeAddBlock " , " addBlock" .= toJSON x]
109131 NodeStartup x -> mconcat
110- [" startup" .= toJSON x]
132+ [ " kind " .= String " NodeStartup " , " startup" .= toJSON x]
111133 NodeShutdown x -> mconcat
112- [" shutdown" .= toJSON x]
134+ [ " kind " .= String " NodeShutdown " , " shutdown" .= toJSON x]
113135 _ -> mempty
114136
115137instance MetaTrace NodeState where
0 commit comments