Skip to content

Commit 7e11cb2

Browse files
authored
Merge pull request #6388 from IntersectMBO/coot/new-tracing-system
new tracing system: networking addjustments
2 parents 986d049 + a6a513c commit 7e11cb2

File tree

2 files changed

+57
-38
lines changed

2 files changed

+57
-38
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,11 @@ instance MetaTrace (FetchDecision [Point header]) where
739739
namespaceFor (Left _) = Namespace [] ["Decline"]
740740
namespaceFor (Right _) = Namespace [] ["Accept"]
741741

742+
severityFor (Namespace _ ["Decline"]) (Just (Left FetchDeclineChainIntersectionTooDeep)) = Just Debug
743+
severityFor (Namespace _ ["Decline"]) (Just (Left FetchDeclineChainNotPlausible)) = Just Notice
744+
severityFor (Namespace _ ["Decline"]) (Just (Left FetchDeclineAlreadyFetched)) = Just Debug
745+
severityFor (Namespace _ ["Decline"]) (Just (Left FetchDeclineInFlightThisPeer)) = Just Debug
746+
severityFor (Namespace _ ["Decline"]) (Just (Left FetchDeclineInFlightOtherPeer)) = Just Debug
742747
severityFor (Namespace _ ["Decline"]) _ = Just Info
743748
severityFor (Namespace _ ["Accept"]) _ = Just Info
744749
severityFor _ _ = Nothing

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

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ module Cardano.Node.Tracing.Tracers.P2P
1313
() where
1414

1515
import Cardano.Logging
16-
import Cardano.Network.Diffusion (TraceChurnMode (..))
16+
import Cardano.Network.Diffusion.Types
1717
import qualified Cardano.Network.PeerSelection.ExtraRootPeers as Cardano.PublicRootPeers
18-
import qualified Cardano.Network.PeerSelection.Governor.PeerSelectionState as Cardano
1918
import qualified Cardano.Network.PeerSelection.Governor.Types as Cardano
20-
import Cardano.Network.PeerSelection.PeerTrustable (PeerTrustable)
2119
import Cardano.Node.Configuration.TopologyP2P ()
2220
import Cardano.Node.Tracing.Tracers.NodeToNode ()
2321
import Cardano.Tracing.OrphanInstances.Network ()
@@ -39,7 +37,6 @@ import Ouroboros.Network.PeerSelection.Governor (DebugPeerSelection (.
3937
peerSelectionStateToCounters)
4038
import Ouroboros.Network.PeerSelection.Governor.Types (DemotionTimeoutException)
4139
import Ouroboros.Network.PeerSelection.PeerStateActions (PeerSelectionActionsTrace (..))
42-
import Ouroboros.Network.PeerSelection.RelayAccessPoint (RelayAccessPoint)
4340
import Ouroboros.Network.PeerSelection.RootPeersDNS.DNSActions (DNSTrace (..))
4441
import Ouroboros.Network.PeerSelection.RootPeersDNS.LocalRootPeers
4542
(TraceLocalRootPeers (..))
@@ -91,12 +88,7 @@ instance LogFormatting NtN.RemoteAddress where
9188
-- LocalRootPeers Tracer
9289
--------------------------------------------------------------------------------
9390

94-
instance
95-
( ToJSONKey ntnAddr
96-
, ToJSON ntnAddr
97-
, ToJSONKey RelayAccessPoint
98-
, Show ntnAddr
99-
) => LogFormatting (TraceLocalRootPeers PeerTrustable ntnAddr) where
91+
instance LogFormatting CardanoTraceLocalRootPeers where
10092
forMachine _dtal (TraceLocalRootDomains groups) =
10193
mconcat [ "kind" .= String "LocalRootDomains"
10294
, "localRootDomains" .= toJSON groups
@@ -215,7 +207,7 @@ instance MetaTrace TracePublicRootPeers where
215207
-- PeerSelection Tracer
216208
--------------------------------------------------------------------------------
217209

218-
instance LogFormatting (TracePeerSelection Cardano.DebugPeerSelectionState PeerTrustable (Cardano.PublicRootPeers.ExtraPeers SockAddr) SockAddr) where
210+
instance LogFormatting CardanoTracePeerSelection where
219211
forMachine _dtal (TraceLocalRootPeersChanged lrp lrp') =
220212
mconcat [ "kind" .= String "LocalRootPeersChanged"
221213
, "previous" .= toJSON lrp
@@ -889,7 +881,7 @@ instance MetaTrace (TracePeerSelection extraDebugState extraFlags extraPeers Soc
889881
-- DebugPeerSelection Tracer
890882
--------------------------------------------------------------------------------
891883

892-
instance LogFormatting (DebugPeerSelection Cardano.ExtraState PeerTrustable (Cardano.PublicRootPeers.ExtraPeers SockAddr) SockAddr) where
884+
instance LogFormatting CardanoDebugPeerSelection where
893885
forMachine dtal@DNormal (TraceGovernorState blockedAt wakeupAfter
894886
st@PeerSelectionState { targets }) =
895887
mconcat [ "kind" .= String "DebugPeerSelection"
@@ -1256,9 +1248,8 @@ instance MetaTrace (PeerSelectionActionsTrace SockAddr lAddr) where
12561248
-- Connection Manager Tracer
12571249
--------------------------------------------------------------------------------
12581250

1259-
instance (Show addr, Show versionNumber, Show agreedOptions, LogFormatting addr,
1260-
ToJSON addr, ToJSON versionNumber, ToJSON agreedOptions)
1261-
=> LogFormatting (ConnectionManager.Trace addr (ConnectionHandlerTrace versionNumber agreedOptions)) where
1251+
instance (Show addr, LogFormatting addr, ToJSON addr, LogFormatting handler, Show handler)
1252+
=> LogFormatting (ConnectionManager.Trace addr handler) where
12621253
forMachine dtal (TrIncludeConnection prov peerAddr) =
12631254
mconcat $ reverse
12641255
[ "kind" .= String "IncludeConnection"
@@ -1307,11 +1298,11 @@ instance (Show addr, Show versionNumber, Show agreedOptions, LogFormatting addr,
13071298
, "provenance" .= String (pack . show $ prov)
13081299
, "remoteAddress" .= forMachine dtal remoteAddress
13091300
]
1310-
forMachine dtal (TrConnectionHandler connId a) =
1301+
forMachine dtal (TrConnectionHandler connId handler) =
13111302
mconcat
13121303
[ "kind" .= String "ConnectionHandler"
13131304
, "connectionId" .= toJSON connId
1314-
, "connectionHandler" .= forMachine dtal a
1305+
, "connectionHandler" .= forMachine dtal handler
13151306
]
13161307
forMachine _dtal TrShutdown =
13171308
mconcat
@@ -1450,15 +1441,15 @@ instance (Show versionNumber, ToJSON versionNumber, ToJSON agreedOptions)
14501441
, "command" .= show cerr
14511442
]
14521443

1453-
instance MetaTrace (ConnectionManager.Trace addr
1454-
(ConnectionHandlerTrace versionNumber agreedOptions)) where
1444+
instance MetaTrace handler => MetaTrace (ConnectionManager.Trace addr handler) where
14551445
namespaceFor TrIncludeConnection {} = Namespace [] ["IncludeConnection"]
14561446
namespaceFor TrReleaseConnection {} = Namespace [] ["UnregisterConnection"]
14571447
namespaceFor TrConnect {} = Namespace [] ["Connect"]
14581448
namespaceFor TrConnectError {} = Namespace [] ["ConnectError"]
14591449
namespaceFor TrTerminatingConnection {} = Namespace [] ["TerminatingConnection"]
14601450
namespaceFor TrTerminatedConnection {} = Namespace [] ["TerminatedConnection"]
1461-
namespaceFor TrConnectionHandler {} = Namespace [] ["ConnectionHandler"]
1451+
namespaceFor (TrConnectionHandler _ hdl) =
1452+
nsPrependInner "ConnectionHandler" (namespaceFor hdl)
14621453
namespaceFor TrShutdown {} = Namespace [] ["Shutdown"]
14631454
namespaceFor TrConnectionExists {} = Namespace [] ["ConnectionExists"]
14641455
namespaceFor TrForbiddenConnection {} = Namespace [] ["ForbiddenConnection"]
@@ -1480,28 +1471,20 @@ instance MetaTrace (ConnectionManager.Trace addr
14801471
severityFor (Namespace _ ["ConnectError"]) _ = Just Info
14811472
severityFor (Namespace _ ["TerminatingConnection"]) _ = Just Debug
14821473
severityFor (Namespace _ ["TerminatedConnection"]) _ = Just Debug
1483-
severityFor (Namespace _ ["ConnectionHandler"])
1484-
(Just (TrConnectionHandler _ ev')) = Just $
1485-
case ev' of
1486-
TrHandshakeSuccess {} -> Info
1487-
TrHandshakeQuery {} -> Info
1488-
TrHandshakeClientError {} -> Notice
1489-
TrHandshakeServerError {} -> Info
1490-
TrConnectionHandlerError _ _ ShutdownNode -> Critical
1491-
TrConnectionHandlerError _ _ ShutdownPeer -> Info
1492-
severityFor (Namespace _ ["ConnectionHandler"]) _ = Just Info
1474+
severityFor (Namespace out ("ConnectionHandler" : tl)) (Just (TrConnectionHandler _ hdl)) =
1475+
severityFor (Namespace out tl) (Just hdl)
1476+
severityFor (Namespace _ ("ConnectionHandler" : _)) Nothing = Just Info
14931477
severityFor (Namespace _ ["Shutdown"]) _ = Just Info
14941478
severityFor (Namespace _ ["ConnectionExists"]) _ = Just Info
14951479
severityFor (Namespace _ ["ForbiddenConnection"]) _ = Just Info
1496-
severityFor (Namespace _ ["ImpossibleConnection"]) _ = Just Info
14971480
severityFor (Namespace _ ["ConnectionFailure"]) _ = Just Info
14981481
severityFor (Namespace _ ["ConnectionNotFound"]) _ = Just Debug
14991482
severityFor (Namespace _ ["ForbiddenOperation"]) _ = Just Info
15001483
severityFor (Namespace _ ["PruneConnections"]) _ = Just Notice
15011484
severityFor (Namespace _ ["ConnectionCleanup"]) _ = Just Debug
15021485
severityFor (Namespace _ ["ConnectionTimeWait"]) _ = Just Debug
15031486
severityFor (Namespace _ ["ConnectionTimeWaitDone"]) _ = Just Info
1504-
severityFor (Namespace _ ["ConnectionManagerCounters"]) _ = Just Debug
1487+
severityFor (Namespace _ ["ConnectionManagerCounters"]) _ = Just Info
15051488
severityFor (Namespace _ ["State"]) _ = Just Info
15061489
severityFor (Namespace _ ["UnexpectedlyFalseAssertion"]) _ = Just Error
15071490
severityFor _ _ = Nothing
@@ -1512,11 +1495,11 @@ instance MetaTrace (ConnectionManager.Trace addr
15121495
documentFor (Namespace _ ["ConnectError"]) = Just ""
15131496
documentFor (Namespace _ ["TerminatingConnection"]) = Just ""
15141497
documentFor (Namespace _ ["TerminatedConnection"]) = Just ""
1515-
documentFor (Namespace _ ["ConnectionHandler"]) = Just ""
1498+
documentFor (Namespace out ("ConnectionHandler" : tl)) =
1499+
documentFor (Namespace out tl :: Namespace handler)
15161500
documentFor (Namespace _ ["Shutdown"]) = Just ""
15171501
documentFor (Namespace _ ["ConnectionExists"]) = Just ""
15181502
documentFor (Namespace _ ["ForbiddenConnection"]) = Just ""
1519-
documentFor (Namespace _ ["ImpossibleConnection"]) = Just ""
15201503
documentFor (Namespace _ ["ConnectionFailure"]) = Just ""
15211504
documentFor (Namespace _ ["ConnectionNotFound"]) = Just ""
15221505
documentFor (Namespace _ ["ForbiddenOperation"]) = Just ""
@@ -1546,11 +1529,9 @@ instance MetaTrace (ConnectionManager.Trace addr
15461529
, Namespace [] ["ConnectError"]
15471530
, Namespace [] ["TerminatingConnection"]
15481531
, Namespace [] ["TerminatedConnection"]
1549-
, Namespace [] ["ConnectionHandler"]
15501532
, Namespace [] ["Shutdown"]
15511533
, Namespace [] ["ConnectionExists"]
15521534
, Namespace [] ["ForbiddenConnection"]
1553-
, Namespace [] ["ImpossibleConnection"]
15541535
, Namespace [] ["ConnectionFailure"]
15551536
, Namespace [] ["ConnectionNotFound"]
15561537
, Namespace [] ["ForbiddenOperation"]
@@ -1560,8 +1541,41 @@ instance MetaTrace (ConnectionManager.Trace addr
15601541
, Namespace [] ["ConnectionTimeWaitDone"]
15611542
, Namespace [] ["ConnectionManagerCounters"]
15621543
, Namespace [] ["State"]
1563-
, Namespace [] ["UnexpectedlyFalseAssertion"]
1564-
]
1544+
, Namespace [] ["UnexpectedlyFalseAssertion"]]
1545+
++ map (nsPrependInner "ConnectionHandler")
1546+
(allNamespaces :: [Namespace handler])
1547+
1548+
1549+
instance MetaTrace (ConnectionHandlerTrace versionNumber agreedOptions) where
1550+
namespaceFor TrHandshakeSuccess {} = Namespace [] ["HandshakeSuccess"]
1551+
namespaceFor TrHandshakeQuery {} = Namespace [] ["HandshakeQuery"]
1552+
namespaceFor TrHandshakeClientError {} = Namespace [] ["HandshakeClientError"]
1553+
namespaceFor TrHandshakeServerError {} = Namespace [] ["HandshakeServerError"]
1554+
namespaceFor TrConnectionHandlerError {} = Namespace [] ["Error"]
1555+
1556+
severityFor (Namespace _ ["HandshakeSuccess"]) _ = Just Info
1557+
severityFor (Namespace _ ["HandshakeQuery"]) _ = Just Info
1558+
severityFor (Namespace _ ["HandshakeClientError"]) _ = Just Notice
1559+
severityFor (Namespace _ ["HandshakeServerError"]) _ = Just Info
1560+
severityFor (Namespace _ ["Error"]) (Just (TrConnectionHandlerError _ _ ShutdownNode)) = Just Critical
1561+
severityFor (Namespace _ ["Error"]) (Just (TrConnectionHandlerError _ _ ShutdownPeer)) = Just Info
1562+
severityFor (Namespace _ ["Error"]) Nothing = Just Info
1563+
severityFor _ _ = Nothing
1564+
1565+
documentFor (Namespace _ ["HandshakeSuccess"]) = Just ""
1566+
documentFor (Namespace _ ["HandshakeQuery"]) = Just ""
1567+
documentFor (Namespace _ ["HandshakeClientError"]) = Just ""
1568+
documentFor (Namespace _ ["HandshakeServerError"]) = Just ""
1569+
documentFor (Namespace _ ["Error"]) = Just ""
1570+
documentFor _ = Nothing
1571+
1572+
allNamespaces = [
1573+
Namespace [] ["HandshakeSuccess"]
1574+
, Namespace [] ["HandshakeQuery"]
1575+
, Namespace [] ["HandshakeClientError"]
1576+
, Namespace [] ["HandshakeServerError"]
1577+
, Namespace [] ["Error"]
1578+
]
15651579

15661580
--------------------------------------------------------------------------------
15671581
-- Connection Manager Transition Tracer

0 commit comments

Comments
 (0)