Skip to content

Commit

Permalink
Merge #4561
Browse files Browse the repository at this point in the history
4561: Trace changes r=Jimbo4350 a=coot

This PR contains various small changes to traces.

- Removed kind field from NodeTo{Node,Client}VersionData
- Fixed a typo
- Changed IP ToJSON instance
- Simplified ToJSON instance of LocalRootPeers
- Use Notice severity for NetworkConfigUpdate
- Added severityStartupTracer

Fixes #4560


Co-authored-by: Marcin Szamotulski <[email protected]>
  • Loading branch information
iohk-bors[bot] and coot authored Oct 29, 2022
2 parents d533317 + a2b5ecf commit 521b64a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
10 changes: 10 additions & 0 deletions cardano-node/src/Cardano/Node/Startup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ data StartupTrace blk =
| BIByron BasicInfoByron
| BINetwork BasicInfoNetwork

severityStartupTracer :: StartupTrace blk -> SeverityS
severityStartupTracer (StartupSocketConfigError _) = Error
severityStartupTracer NetworkConfigUpdate = Notice
severityStartupTracer (NetworkConfigUpdateError _) = Error
severityStartupTracer NetworkConfigUpdateUnsupported = Warning
severityStartupTracer P2PWarning = Warning
severityStartupTracer P2PWarningDevelopementNetworkProtocols = Warning
severityStartupTracer WarningDevelopmentNetworkProtocols {} = Warning
severityStartupTracer _ = Info

data BasicInfoCommon = BasicInfoCommon {
biConfigPath :: FilePath
, biNetworkMagic :: NetworkMagic
Expand Down
2 changes: 1 addition & 1 deletion cardano-node/src/Cardano/Node/Tracing/Tracers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ mkDispatchTracers nodeKernel trBase trForward mbTrEKG trDataPoint trConfig enabl
trBase trForward mbTrEKG
["Startup"]
namesStartupInfo
(const Notice)
severityStartupTracer
allPublic
configureTracers trConfig docStartupInfo [startupTr]

Expand Down
2 changes: 1 addition & 1 deletion cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ instance LogFormatting (PeerSelectionActionsTrace SockAddr) where
, "reason" .= show f
]
forMachine _dtal (PeerMonitoringError connId s) =
mconcat [ "kind" .= String "PeerMonitoridngError"
mconcat [ "kind" .= String "PeerMonitoringError"
, "connectionId" .= toJSON connId
, "reason" .= show s
]
Expand Down
18 changes: 8 additions & 10 deletions cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ import Ouroboros.Network.PeerSelection.Governor (DebugPeerSelection (.
TracePeerSelection (..))
import qualified Ouroboros.Network.PeerSelection.KnownPeers as KnownPeers
import Ouroboros.Network.PeerSelection.LedgerPeers
import Ouroboros.Network.PeerSelection.LocalRootPeers (LocalRootPeers, toGroupSets, toMap)
import Ouroboros.Network.PeerSelection.LocalRootPeers (LocalRootPeers)
import qualified Ouroboros.Network.PeerSelection.LocalRootPeers as LocalRootPeers
import Ouroboros.Network.PeerSelection.PeerStateActions (PeerSelectionActionsTrace (..))
import Ouroboros.Network.PeerSelection.RootPeersDNS (TraceLocalRootPeers (..),
TracePublicRootPeers (..))
Expand Down Expand Up @@ -1361,7 +1362,7 @@ instance Show exception => ToObject (TraceLocalRootPeers RemoteAddress exception
]

instance ToJSON IP where
toJSON ip = Aeson.object ["ip" .= String (pack . show $ ip)]
toJSON ip = String (pack . show $ ip)

instance ToObject TracePublicRootPeers where
toObject _verb (TracePublicRootRelayAccessPoint relays) =
Expand All @@ -1386,12 +1387,11 @@ instance ToObject TracePublicRootPeers where
instance ToJSON PeerStatus where
toJSON = String . pack . show

instance (Aeson.ToJSONKey peerAddr, ToJSON peerAddr, Show peerAddr)
instance (Aeson.ToJSONKey peerAddr, ToJSON peerAddr, Ord peerAddr, Show peerAddr)
=> ToJSON (LocalRootPeers peerAddr) where
toJSON lrp =
Aeson.object [ "kind" .= String "LocalRootPeers"
, "state" .= toJSON (toMap lrp)
, "groups" .= Aeson.toJSONList (toGroupSets lrp)
, "groups" .= Aeson.toJSONList (LocalRootPeers.toGroups lrp)
]

instance ToJSON PeerSelectionTargets where
Expand Down Expand Up @@ -1653,7 +1653,7 @@ instance ToObject (PeerSelectionActionsTrace SockAddr) where
, "reason" .= show f
]
toObject _verb (PeerMonitoringError connId s) =
mconcat [ "kind" .= String "PeerMonitoridngError"
mconcat [ "kind" .= String "PeerMonitoringError"
, "connectionId" .= toJSON connId
, "reason" .= show s
]
Expand Down Expand Up @@ -1742,15 +1742,13 @@ instance ToJSON NodeToClientVersion where

instance ToJSON NodeToNodeVersionData where
toJSON (NodeToNodeVersionData (NetworkMagic m) dm) =
Aeson.object [ "kind" .= String "NodeToNodeVersionData"
, "networkMagic" .= toJSON m
Aeson.object [ "networkMagic" .= toJSON m
, "diffusionMode" .= show dm
]

instance ToJSON NodeToClientVersionData where
toJSON (NodeToClientVersionData (NetworkMagic m)) =
Aeson.object [ "kind" .= String "NodeToClientVersionData"
, "networkMagic" .= toJSON m
Aeson.object [ "networkMagic" .= toJSON m
]

instance (Show versionNumber, ToJSON versionNumber, ToJSON agreedOptions)
Expand Down
1 change: 1 addition & 0 deletions cardano-node/src/Cardano/Tracing/Startup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Ouroboros.Consensus.Node.NetworkProtocolVersion

instance HasSeverityAnnotation (StartupTrace blk) where
getSeverityAnnotation (StartupSocketConfigError _) = Error
getSeverityAnnotation NetworkConfigUpdate = Notice
getSeverityAnnotation (NetworkConfigUpdateError _) = Error
getSeverityAnnotation NetworkConfigUpdateUnsupported = Warning
getSeverityAnnotation P2PWarning = Warning
Expand Down

0 comments on commit 521b64a

Please sign in to comment.