Skip to content

Commit 613347f

Browse files
committed
keep-alive tracing
* new tracing system: moved instances to NodeToNode module, where other mini-protocol tracers are defined. * make the output of the legacy tracing system for keep alive measurements, the same as the new one.
1 parent e078e3d commit 613347f

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

@@ -2114,41 +2111,6 @@ instance MetaTrace (TraceBlockchainTimeEvent t) where
21142111
, Namespace [] ["SystemClockMovedBack"]
21152112
]
21162113

2117-
--------------------------------------------------------------------------------
2118-
-- KeepAliveClient Tracer
2119-
--------------------------------------------------------------------------------
2120-
2121-
instance Show remotePeer => LogFormatting (TraceKeepAliveClient remotePeer) where
2122-
forMachine _dtal (AddSample peer rtt pgsv) =
2123-
mconcat
2124-
[ "kind" .= String "AddSample"
2125-
, "address" .= show peer
2126-
, "rtt" .= rtt
2127-
, "sampleTime" .= show (dTime $ sampleTime pgsv)
2128-
, "outboundG" .= (realToFrac $ gGSV (outboundGSV pgsv) :: Double)
2129-
, "inboundG" .= (realToFrac $ gGSV (inboundGSV pgsv) :: Double)
2130-
]
2131-
where
2132-
gGSV :: GSV -> DiffTime
2133-
gGSV (GSV g _ _) = g
2134-
2135-
dTime :: Time -> Double
2136-
dTime (Time d) = realToFrac d
2137-
2138-
forHuman = showT
2139-
2140-
instance MetaTrace (TraceKeepAliveClient remotePeer) where
2141-
namespaceFor AddSample {} = Namespace [] ["KeepAliveClient"]
2142-
2143-
severityFor (Namespace _ ["KeepAliveClient"]) Nothing = Just Info
2144-
severityFor _ _ = Nothing
2145-
2146-
documentFor (Namespace _ ["KeepAliveClient"]) = Just
2147-
"A server read has occurred, either for an add block or a rollback"
2148-
documentFor _ = Just ""
2149-
2150-
allNamespaces = [Namespace [] ["KeepAliveClient"]]
2151-
21522114
--------------------------------------------------------------------------------
21532115
-- Gsm Tracer
21542116
--------------------------------------------------------------------------------

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)