Skip to content

Commit

Permalink
Various changes
Browse files Browse the repository at this point in the history
Removed kind field from NodeTo{Node,Client}VersionData

  It is not needed, it is obvious from the context that it's either
  node-to-node or node-to-client protocol.

Fixed a typo

Changed IP ToJSON instance

  There's no need to pack the `ip` address inside a record.  It is only
  used by: `ToObject` instances of `TraceLocalRootResult` and
  `TracePublicRootFailure` constructors.

Simplified ToJSON instance of LocalRootPeers

  Switched to using the same data as `LocalRootPeers` in the p2p
  topology file (although the format might be different).

Use Notice severity for NetworkConfigUpdate

Added severityStartupTracer

Fixes #4560
  • Loading branch information
coot committed Oct 26, 2022
1 parent 8832f86 commit a2b5ecf
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 @@ -1360,7 +1361,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 @@ -1385,12 +1386,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 @@ -1652,7 +1652,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 @@ -1741,15 +1741,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 a2b5ecf

Please sign in to comment.