Skip to content

Commit 24bb265

Browse files
authored
Merge pull request #6158 from IntersectMBO/coot/keep-alive-tracing
KeepAlive tracing improvements
2 parents 91e8d93 + 613347f commit 24bb265

File tree

4 files changed

+44
-40
lines changed

4 files changed

+44
-40
lines changed

cardano-node/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
}
2828
```
2929

30+
- KeepAlive client tracing: dropped `KeepAliveClient` from `kind` of
31+
`AddSample` messages in the legacy tracing system.
32+
3033
## 10.2 -- January 2025
3134

3235
- Use p2p network stack by default, warn when using the legacy network stack.

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

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,11 @@ import qualified Ouroboros.Network.BlockFetch.ClientState as BlockFetch
6868
import Ouroboros.Network.BlockFetch.Decision
6969
import Ouroboros.Network.BlockFetch.Decision.Trace (TraceDecisionEvent (..))
7070
import Ouroboros.Network.ConnectionId (ConnectionId (..))
71-
import Ouroboros.Network.DeltaQ (GSV (..), PeerGSV (..))
72-
import Ouroboros.Network.KeepAlive (TraceKeepAliveClient (..))
7371
import Ouroboros.Network.SizeInBytes (SizeInBytes (..))
7472
import Ouroboros.Network.TxSubmission.Inbound hiding (txId)
7573
import Ouroboros.Network.TxSubmission.Outbound
7674

7775
import Control.Monad (guard)
78-
import Control.Monad.Class.MonadTime.SI (Time (..))
7976
import Data.Aeson (ToJSON, Value (Number, String), toJSON, (.=))
8077
import qualified Data.Aeson as Aeson
8178
import Data.Foldable (Foldable (toList))
@@ -84,7 +81,7 @@ import Data.IntPSQ (IntPSQ)
8481
import qualified Data.IntPSQ as Pq
8582
import qualified Data.List as List
8683
import qualified Data.Text as Text
87-
import Data.Time (DiffTime, NominalDiffTime)
84+
import Data.Time (NominalDiffTime)
8885
import Data.Word (Word32, Word64)
8986
import Network.TypedProtocol.Core
9087

@@ -2163,41 +2160,6 @@ instance MetaTrace (TraceBlockchainTimeEvent t) where
21632160
, Namespace [] ["SystemClockMovedBack"]
21642161
]
21652162

2166-
--------------------------------------------------------------------------------
2167-
-- KeepAliveClient Tracer
2168-
--------------------------------------------------------------------------------
2169-
2170-
instance Show remotePeer => LogFormatting (TraceKeepAliveClient remotePeer) where
2171-
forMachine _dtal (AddSample peer rtt pgsv) =
2172-
mconcat
2173-
[ "kind" .= String "AddSample"
2174-
, "address" .= show peer
2175-
, "rtt" .= rtt
2176-
, "sampleTime" .= show (dTime $ sampleTime pgsv)
2177-
, "outboundG" .= (realToFrac $ gGSV (outboundGSV pgsv) :: Double)
2178-
, "inboundG" .= (realToFrac $ gGSV (inboundGSV pgsv) :: Double)
2179-
]
2180-
where
2181-
gGSV :: GSV -> DiffTime
2182-
gGSV (GSV g _ _) = g
2183-
2184-
dTime :: Time -> Double
2185-
dTime (Time d) = realToFrac d
2186-
2187-
forHuman = showT
2188-
2189-
instance MetaTrace (TraceKeepAliveClient remotePeer) where
2190-
namespaceFor AddSample {} = Namespace [] ["KeepAliveClient"]
2191-
2192-
severityFor (Namespace _ ["KeepAliveClient"]) Nothing = Just Info
2193-
severityFor _ _ = Nothing
2194-
2195-
documentFor (Namespace _ ["KeepAliveClient"]) = Just
2196-
"A server read has occurred, either for an add block or a rollback"
2197-
documentFor _ = Just ""
2198-
2199-
allNamespaces = [Namespace [] ["KeepAliveClient"]]
2200-
22012163
--------------------------------------------------------------------------------
22022164
-- Gsm Tracer
22032165
--------------------------------------------------------------------------------

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@ import Ouroboros.Consensus.Ledger.SupportsMempool (GenTx, HasTxId, Has
2020
LedgerSupportsMempool, extractTxs, txId)
2121
import Ouroboros.Consensus.Node.Run (SerialiseNodeToNodeConstraints, estimateBlockSize)
2222
import Ouroboros.Network.Block (Point, Serialised (..), blockHash)
23+
import Ouroboros.Network.DeltaQ (GSV (..), PeerGSV (..))
24+
import Ouroboros.Network.KeepAlive (TraceKeepAliveClient (..))
2325
import Ouroboros.Network.Protocol.BlockFetch.Type (BlockFetch (..), Message (..))
2426
import qualified Ouroboros.Network.Protocol.TxSubmission2.Type as STX
2527
import qualified Ouroboros.Network.Protocol.KeepAlive.Type as KA
2628
import qualified Ouroboros.Network.Protocol.PeerSharing.Type as PS
2729
import Ouroboros.Network.SizeInBytes (SizeInBytes (..))
2830

31+
import Control.Monad.Class.MonadTime.SI (Time (..))
2932
import Data.Aeson (ToJSON (..), Value (String), (.=))
3033
import Data.Proxy (Proxy (..))
34+
import Data.Time (DiffTime)
3135
import Data.Text (pack)
3236
import Network.TypedProtocol.Codec (AnyMessage (AnyMessageAndAgency))
3337

@@ -427,3 +431,38 @@ instance MetaTrace (AnyMessage (PS.PeerSharing addr)) where
427431
, Namespace [] ["PeerShareResult"]
428432
, Namespace [] ["PeerShareDone"]
429433
]
434+
435+
--------------------------------------------------------------------------------
436+
-- KeepAliveClient Tracer
437+
--------------------------------------------------------------------------------
438+
439+
instance Show remotePeer => LogFormatting (TraceKeepAliveClient remotePeer) where
440+
forMachine _dtal (AddSample peer rtt pgsv) =
441+
mconcat
442+
[ "kind" .= String "AddSample"
443+
, "address" .= show peer
444+
, "rtt" .= rtt
445+
, "sampleTime" .= show (dTime $ sampleTime pgsv)
446+
, "outboundG" .= (realToFrac $ gGSV (outboundGSV pgsv) :: Double)
447+
, "inboundG" .= (realToFrac $ gGSV (inboundGSV pgsv) :: Double)
448+
]
449+
where
450+
gGSV :: GSV -> DiffTime
451+
gGSV (GSV g _ _) = g
452+
453+
dTime :: Time -> Double
454+
dTime (Time d) = realToFrac d
455+
456+
forHuman = showT
457+
458+
instance MetaTrace (TraceKeepAliveClient remotePeer) where
459+
namespaceFor AddSample {} = Namespace [] ["KeepAliveClient"]
460+
461+
severityFor (Namespace _ ["KeepAliveClient"]) Nothing = Just Info
462+
severityFor _ _ = Nothing
463+
464+
documentFor (Namespace _ ["KeepAliveClient"]) = Just
465+
"A server read has occurred, either for an add block or a rollback"
466+
documentFor _ = Just ""
467+
468+
allNamespaces = [Namespace [] ["KeepAliveClient"]]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ instance (Show txid, Show tx)
15261526
instance Show remotePeer => ToObject (TraceKeepAliveClient remotePeer) where
15271527
toObject _verb (AddSample peer rtt pgsv) =
15281528
mconcat
1529-
[ "kind" .= String "KeepAliveClient AddSample"
1529+
[ "kind" .= String "AddSample"
15301530
, "address" .= show peer
15311531
, "rtt" .= rtt
15321532
, "sampleTime" .= show (dTime $ sampleTime pgsv)

0 commit comments

Comments
 (0)