diff --git a/bench/tx-generator/src/Cardano/Benchmarking/Tracer.hs b/bench/tx-generator/src/Cardano/Benchmarking/Tracer.hs index dc5d59f7a8f..a42f430aeb2 100644 --- a/bench/tx-generator/src/Cardano/Benchmarking/Tracer.hs +++ b/bench/tx-generator/src/Cardano/Benchmarking/Tracer.hs @@ -189,8 +189,7 @@ initialTraceConfig = TraceConfig { ] , tcForwarder = Just defaultForwarder {tofQueueSize = 4096} , tcNodeName = Nothing - , tcPeerFrequency = Just 2000 -- Every 2 seconds - , tcResourceFrequency = Just 1000 -- Every second + , tcResourceFrequency = Nothing , tcMetricsPrefix = Nothing , tcLedgerMetricsFrequency = Nothing } diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal index c91a2bfa906..8eac42d6384 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal @@ -97,7 +97,6 @@ library Cardano.Node.Tracing.Formatting Cardano.Node.Tracing.NodeInfo Cardano.Node.Tracing.NodeStartupInfo - Cardano.Node.Tracing.Peers Cardano.Node.Tracing.Render Cardano.Node.Tracing.StateRep Cardano.Node.Tracing.Tracers @@ -113,7 +112,6 @@ library Cardano.Node.Tracing.Tracers.NodeToNode Cardano.Node.Tracing.Tracers.NodeVersion Cardano.Node.Tracing.Tracers.P2P - Cardano.Node.Tracing.Tracers.Peer Cardano.Node.Tracing.Tracers.Resources Cardano.Node.Tracing.Tracers.Shutdown Cardano.Node.Tracing.Tracers.Startup @@ -127,7 +125,6 @@ library Cardano.Tracing.OrphanInstances.HardFork Cardano.Tracing.OrphanInstances.Network Cardano.Tracing.OrphanInstances.Shelley - Cardano.Tracing.Peer Cardano.Tracing.Render Cardano.Tracing.Shutdown Cardano.Tracing.Startup diff --git a/cardano-node/src/Cardano/Node/Tracing.hs b/cardano-node/src/Cardano/Node/Tracing.hs index a79a3620cdf..2a751a58562 100644 --- a/cardano-node/src/Cardano/Node/Tracing.hs +++ b/cardano-node/src/Cardano/Node/Tracing.hs @@ -17,7 +17,6 @@ import Cardano.Node.Tracing.Tracers.ConsensusStartupException (ConsensusStartupException (..)) import Cardano.Node.Tracing.Tracers.LedgerMetrics (LedgerMetrics) import Cardano.Node.Tracing.Tracers.NodeVersion (NodeVersionTrace) -import Cardano.Node.Tracing.Tracers.Peer (PeerT) import qualified Ouroboros.Consensus.Network.NodeToClient as NodeToClient import qualified Ouroboros.Consensus.Network.NodeToNode as NodeToNode import qualified Ouroboros.Consensus.Node.Tracers as Consensus @@ -50,6 +49,5 @@ data Tracers peer localPeer blk m = Tracers , nodeStartupInfoTracer :: !(Tracer IO NodeStartupInfo) , nodeStateTracer :: !(Tracer IO NodeState) , resourcesTracer :: !(Tracer IO ResourceStats) - , peersTracer :: !(Tracer IO [PeerT blk]) , ledgerMetricsTracer :: !(Tracer IO LedgerMetrics) } diff --git a/cardano-node/src/Cardano/Node/Tracing/API.hs b/cardano-node/src/Cardano/Node/Tracing/API.hs index 81e1bd82dfc..43e702b8ff3 100644 --- a/cardano-node/src/Cardano/Node/Tracing/API.hs +++ b/cardano-node/src/Cardano/Node/Tracing/API.hs @@ -23,7 +23,6 @@ import Cardano.Node.Tracing.DefaultTraceConfig (defaultCardanoConfig) import Cardano.Node.Tracing.StateRep (NodeState (..)) import Cardano.Node.Tracing.Tracers import Cardano.Node.Tracing.Tracers.LedgerMetrics -import Cardano.Node.Tracing.Tracers.Peer (startPeerTracer) import Cardano.Node.Tracing.Tracers.Resources (startResourceTracer) import Cardano.Node.Types import Ouroboros.Consensus.Ledger.Inspect (LedgerEvent) @@ -98,11 +97,6 @@ initTraceDispatcher nc p networkMagic nodeKernel noBlockForging = do (fromMaybe ledgerMetricsDefaultFreq (tcLedgerMetricsFrequency trConfig)) nodeKernel - startPeerTracer - (peersTracer tracers) - nodeKernel - (fromMaybe 2000 (tcPeerFrequency trConfig)) - pure tracers where -- this is the backwards compatible default: block producers emit these metrics every second, relays never. diff --git a/cardano-node/src/Cardano/Node/Tracing/Consistency.hs b/cardano-node/src/Cardano/Node/Tracing/Consistency.hs index 81d7a6c2666..8f1a4f3da4c 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Consistency.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Consistency.hs @@ -32,7 +32,6 @@ import Cardano.Node.Tracing.Tracers.NodeToClient () import Cardano.Node.Tracing.Tracers.NodeToNode () import Cardano.Node.Tracing.Tracers.NodeVersion (NodeVersionTrace) import Cardano.Node.Tracing.Tracers.P2P () -import Cardano.Node.Tracing.Tracers.Peer import Cardano.Node.Tracing.Tracers.Shutdown () import Cardano.Node.Tracing.Tracers.Startup () import qualified Cardano.Network.PeerSelection.Governor.PeerSelectionState as Cardano @@ -133,8 +132,6 @@ getAllNamespaces = -- NodeInfo tracer let stateNS = map (nsGetTuple . nsReplacePrefix ["NodeState"]) (allNamespaces :: [Namespace SR.NodeState]) - peersNS = map (nsGetTuple . nsReplacePrefix ["Net", "Peers", "List"]) - (allNamespaces :: [Namespace [PeerT blk]]) resourcesNS = map nsGetTuple (allNamespaces :: [Namespace ResourceStats]) ledgerMetricsNS = map nsGetTuple @@ -385,7 +382,6 @@ getAllNamespaces = allNamespaces' :: [([T.Text],[T.Text])] = stateNS - <> peersNS <> resourcesNS <> ledgerMetricsNS <> startupNS diff --git a/cardano-node/src/Cardano/Node/Tracing/Documentation.hs b/cardano-node/src/Cardano/Node/Tracing/Documentation.hs index aeda67f3f64..1658bed634d 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Documentation.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Documentation.hs @@ -45,7 +45,6 @@ import Cardano.Node.Tracing.Tracers.NodeToClient () import Cardano.Node.Tracing.Tracers.NodeToNode () import Cardano.Node.Tracing.Tracers.NodeVersion (NodeVersionTrace) import Cardano.Node.Tracing.Tracers.P2P () -import Cardano.Node.Tracing.Tracers.Peer import Cardano.Node.Tracing.Tracers.Shutdown () import Cardano.Node.Tracing.Tracers.Startup () import qualified Cardano.Network.PeerSelection.Governor.PeerSelectionState as Cardano @@ -234,13 +233,6 @@ docTracersFirstPhase condConfigFileName = do configureTracers configReflection trConfig [stateTr] stateTrDoc <- documentTracer (stateTr :: Logging.Trace IO SR.NodeState) - -- Peers tracer - peersTr <- mkCardanoTracer - trBase trForward mbTrEKG - ["Net", "Peers", "List"] - configureTracers configReflection trConfig [peersTr] - peersTrDoc <- documentTracer (peersTr :: Logging.Trace IO [PeerT blk]) - -- Resource tracer resourcesTr <- mkCardanoTracer trBase trForward mbTrEKG @@ -716,7 +708,6 @@ docTracersFirstPhase condConfigFileName = do <> startupTrDoc <> shutdownTrDoc <> nodeVersionDoc - <> peersTrDoc <> chainDBTrDoc <> replayBlockTrDoc -- Consensus diff --git a/cardano-node/src/Cardano/Node/Tracing/Peers.hs b/cardano-node/src/Cardano/Node/Tracing/Peers.hs deleted file mode 100644 index 5afe6810fc6..00000000000 --- a/cardano-node/src/Cardano/Node/Tracing/Peers.hs +++ /dev/null @@ -1,29 +0,0 @@ -{-# OPTIONS_GHC -fno-warn-orphans #-} - -module Cardano.Node.Tracing.Peers - ( NodePeers (..) - , traceNodePeers - ) where - -import Cardano.Logging -import Cardano.Node.Tracing.Tracers.Peer (PeerT, ppPeer) -import Cardano.Logging.Types.NodePeers (NodePeers(..)) - -instance MetaTrace NodePeers where - namespaceFor NodePeers {} = - Namespace [] ["NodePeers"] - severityFor (Namespace _ ["NodePeers"]) _ = - Just Info - severityFor _ns _ = - Nothing - documentFor (Namespace _ ["NodePeers"]) = - Just "" - documentFor _ns = - Nothing - allNamespaces = [ Namespace [] ["NodePeers"]] - -traceNodePeers - :: Trace IO NodePeers - -> [PeerT blk] - -> IO () -traceNodePeers tr ev = traceWith tr $ NodePeers (fmap ppPeer ev) diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers.hs index 12736ccda66..485d28e71f0 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers.hs @@ -24,7 +24,6 @@ import Cardano.Node.TraceConstraints import Cardano.Node.Tracing import Cardano.Node.Tracing.Consistency (checkNodeTraceConfiguration') import Cardano.Node.Tracing.Formatting () -import Cardano.Node.Tracing.Peers (traceNodePeers) import qualified Cardano.Node.Tracing.StateRep as SR import Cardano.Node.Tracing.Tracers.BlockReplayProgress import Cardano.Node.Tracing.Tracers.ChainDB @@ -101,13 +100,6 @@ mkDispatchTracers nodeKernel trBase trForward mbTrEKG trDataPoint trConfig p = d !stateTr <- mkCardanoTracer trBase trForward mbTrEKG ["NodeState"] configureTracers configReflection trConfig [stateTr] - !nodePeersDP <- mkDataPointTracer trDataPoint - configureTracers configReflection trConfig [nodePeersDP] - - !peersTr <- mkCardanoTracer trBase trForward mbTrEKG - ["Net", "Peers", "List"] - configureTracers configReflection trConfig [peersTr] - !resourcesTr <- mkCardanoTracer trBase trForward mbTrEKG [] configureTracers configReflection trConfig [resourcesTr] @@ -190,8 +182,6 @@ mkDispatchTracers nodeKernel trBase trForward mbTrEKG trDataPoint trConfig p = d <> Tracer (traceWith nodeStateDP) , nodeVersionTracer = Tracer (traceWith nodeVersionTr) , resourcesTracer = Tracer (traceWith resourcesTr) - , peersTracer = Tracer (traceWith peersTr) - <> Tracer (traceNodePeers nodePeersDP) , ledgerMetricsTracer = Tracer (traceWith ledgerMetricsTr) } diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/Peer.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/Peer.hs deleted file mode 100644 index 4e5905f7454..00000000000 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/Peer.hs +++ /dev/null @@ -1,190 +0,0 @@ -{-# LANGUAGE DerivingVia #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE PackageImports #-} -{-# LANGUAGE ScopedTypeVariables #-} - -module Cardano.Node.Tracing.Tracers.Peer - ( PeerT (..) - , startPeerTracer - , ppPeer - ) where - -import Cardano.Logging hiding (traceWith) -import Cardano.Node.Orphans () -import Cardano.Node.Queries -import Ouroboros.Consensus.Block (Header) -import Ouroboros.Consensus.HeaderValidation (HeaderWithTime (..)) -import Ouroboros.Consensus.MiniProtocol.ChainSync.Client (ChainSyncClientHandle, - csCandidate, cschcMap, viewChainSyncState) -import Ouroboros.Consensus.Util.Orphans () -import qualified Ouroboros.Network.AnchoredFragment as Net -import Ouroboros.Network.Block (unSlotNo) -import qualified Ouroboros.Network.Block as Net -import qualified Ouroboros.Network.BlockFetch.ClientRegistry as Net -import Ouroboros.Network.BlockFetch.ClientState (PeerFetchInFlight (..), - PeerFetchStatus (..), readFetchClientState) -import Ouroboros.Network.ConnectionId (remoteAddress) -import Ouroboros.Network.NodeToNode (RemoteAddress) - -import Control.Concurrent (threadDelay) -import Control.Concurrent.Async -import qualified Control.Concurrent.Class.MonadSTM.Strict as STM -import Control.Monad (forever) -import "contra-tracer" Control.Tracer -import Data.Aeson (ToJSON (..), Value (..), toJSON, (.=)) -import Data.Functor ((<&>)) -import qualified Data.List as List -import Data.Map.Strict (Map) -import qualified Data.Map.Strict as Map -import qualified Data.Set as Set -import Data.Text (Text) -import qualified Data.Text as Text -import GHC.Conc (labelThread, myThreadId) -import Text.Printf (printf) - -{- HLINT ignore "Use =<<" -} -{- HLINT ignore "Use <=<" -} - --- | Starts a background thread to periodically trace the current peer list. --- The thread is linked to the parent thread for proper error propagation --- and labeled for easier debugging and identification. -startPeerTracer - :: forall blk. Net.HasHeader (Header blk) - => Tracer IO [PeerT blk] -- ^ Tracer for the peer list - -> NodeKernelData blk -- ^ Node kernel containing peer data - -> Int -- ^ Delay in milliseconds between traces - -> IO () -startPeerTracer _ _ 0 = pure () -startPeerTracer tracer nodeKernel delayMilliseconds = do - as <- async peersThread - link as - where - -- | The background thread that periodically traces the peer list. - peersThread :: IO () - peersThread = do - -- Label the thread for easier debugging and identification. - myThreadId >>= flip labelThread "Peer Tracer" - forever $ do - peers <- getCurrentPeers nodeKernel - traceWith tracer peers - threadDelay (delayMilliseconds * 1000) - -data PeerT blk = PeerT - RemoteConnectionId - (Net.AnchoredFragment (Header blk)) - (PeerFetchStatus (Header blk)) - (PeerFetchInFlight (Header blk)) - -ppPeer :: PeerT blk -> Text -ppPeer (PeerT cid _af status inflight) = - Text.pack $ printf "%-15s %-8s %s" (ppCid cid) (ppStatus status) (ppInFlight inflight) - - where - ppCid :: RemoteConnectionId -> String - ppCid = takeWhile (/= ':') . show . remoteAddress - - ppInFlight :: PeerFetchInFlight header -> String - ppInFlight f = printf - "%5s %3d %5d %6d" - (ppMaxSlotNo $ peerFetchMaxSlotNo f) - (peerFetchReqsInFlight f) - (Set.size $ peerFetchBlocksInFlight f) - (peerFetchBytesInFlight f) - -ppStatus :: PeerFetchStatus header -> String -ppStatus = \case - PeerFetchStatusStarting -> "starting" - PeerFetchStatusShutdown -> "shutdown" - PeerFetchStatusAberrant -> "aberrant" - PeerFetchStatusBusy -> "fetching" - PeerFetchStatusReady {} -> "ready" - -ppMaxSlotNo :: Net.MaxSlotNo -> String -ppMaxSlotNo Net.NoMaxSlotNo = "???" -ppMaxSlotNo (Net.MaxSlotNo x) = show (unSlotNo x) - -getCurrentPeers - :: forall blk. Net.HasHeader (Header blk) - => NodeKernelData blk - -> IO [PeerT blk] -getCurrentPeers nkd = mapNodeKernelDataIO extractPeers nkd - <&> fromSMaybe mempty - where - tuple3pop :: (a, b, c) -> (a, b) - tuple3pop (a, b, _) = (a, b) - - peerFetchStatusForgetTime :: PeerFetchStatus (HeaderWithTime blk) -> PeerFetchStatus (Header blk) - peerFetchStatusForgetTime = \case - PeerFetchStatusShutdown -> PeerFetchStatusShutdown - PeerFetchStatusStarting -> PeerFetchStatusStarting - PeerFetchStatusAberrant -> PeerFetchStatusAberrant - PeerFetchStatusBusy -> PeerFetchStatusBusy - PeerFetchStatusReady points idle -> PeerFetchStatusReady (Set.mapMonotonic Net.castPoint points) idle - - peerFetchInFlightForgetTime :: PeerFetchInFlight (HeaderWithTime blk) -> PeerFetchInFlight (Header blk) - peerFetchInFlightForgetTime inflight = - inflight {peerFetchBlocksInFlight = Set.mapMonotonic Net.castPoint (peerFetchBlocksInFlight inflight)} - - getCandidates - :: STM.STM IO (Map peer (ChainSyncClientHandle IO blk)) - -> STM.STM IO (Map peer (Net.AnchoredFragment (Header blk))) - getCandidates handle = viewChainSyncState handle (Net.mapAnchoredFragment hwtHeader . csCandidate) - - extractPeers :: NodeKernel IO RemoteAddress LocalConnectionId blk - -> IO [PeerT blk] - extractPeers kernel = do - peerStates <- fmap tuple3pop <$> ( STM.atomically - . (>>= traverse readFetchClientState) - . Net.readFetchClientsStateVars - . getFetchClientRegistry $ kernel - ) - candidates <- STM.atomically . getCandidates . cschcMap . getChainSyncHandles $ kernel - - let peers = flip Map.mapMaybeWithKey candidates $ \cid af -> - maybe Nothing - (\(status, inflight) -> Just $ PeerT cid af (peerFetchStatusForgetTime status) (peerFetchInFlightForgetTime inflight)) - $ Map.lookup cid peerStates - pure . Map.elems $ peers - --- -------------------------------------------------------------------------------- --- -- Peers Tracer --- -------------------------------------------------------------------------------- - -instance LogFormatting [PeerT blk] where - forMachine _ [] = mempty - forMachine dtal xs = mconcat - [ "peers" .= toJSON (List.foldl' (\acc x -> forMachine dtal x : acc) [] xs) - ] - forHuman peers = Text.concat $ List.intersperse ", " (map ppPeer peers) - asMetrics peers = [IntM "peersFromNodeKernel" (fromIntegral (length peers))] - -instance LogFormatting (PeerT blk) where - forMachine _dtal (PeerT cid _af status inflight) = - mconcat [ "peerAddress" .= String (Text.pack . show . remoteAddress $ cid) - , "peerStatus" .= String (Text.pack . ppStatus $ status) - , "peerSlotNo" .= String (Text.pack . ppMaxSlotNo . peerFetchMaxSlotNo $ inflight) - , "peerReqsInF" .= String (Text.pack . show . peerFetchReqsInFlight $ inflight) - , "peerBlocksInF" .= String (Text.pack . show . Set.size . peerFetchBlocksInFlight $ inflight) - , "peerBytesInF" .= String (Text.pack . show . peerFetchBytesInFlight $ inflight) - ] - -instance MetaTrace [PeerT blk] where - namespaceFor _ = - Namespace [] ["PeersFromNodeKernel"] - severityFor (Namespace _ ["PeersFromNodeKernel"]) (Just []) = - Just Debug - severityFor (Namespace _ ["PeersFromNodeKernel"]) _ = - Just Info - severityFor _ns _ = - Nothing - documentFor (Namespace _ ["PeersFromNodeKernel"]) = - Just "" - documentFor _ns = - Nothing - metricsDocFor (Namespace _ ["PeersFromNodeKernel"]) = - [("peersFromNodeKernel","")] - metricsDocFor _ns = [] - allNamespaces = [ Namespace [] ["PeersFromNodeKernel"]] diff --git a/cardano-node/src/Cardano/Tracing/Peer.hs b/cardano-node/src/Cardano/Tracing/Peer.hs deleted file mode 100644 index 833c974885e..00000000000 --- a/cardano-node/src/Cardano/Tracing/Peer.hs +++ /dev/null @@ -1,166 +0,0 @@ -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DerivingVia #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE ScopedTypeVariables #-} - -module Cardano.Tracing.Peer - ( Peer (..) - , getCurrentPeers - , ppPeer - , tracePeers - ) where - -import Cardano.BM.Data.LogItem (LOContent (..)) -import Cardano.BM.Trace (traceNamedObject) -import Cardano.BM.Tracing -import Cardano.Node.Orphans () -import Cardano.Node.Queries -import Ouroboros.Consensus.Block (Header) -import Ouroboros.Consensus.HeaderValidation (HeaderWithTime (..)) -import Ouroboros.Consensus.MiniProtocol.ChainSync.Client (ChainSyncClientHandle, - csCandidate, cschcMap, viewChainSyncState) -import Ouroboros.Consensus.Util.Orphans () -import qualified Ouroboros.Network.AnchoredFragment as Net -import Ouroboros.Network.Block (unSlotNo) -import qualified Ouroboros.Network.Block as Net -import qualified Ouroboros.Network.BlockFetch.ClientRegistry as Net -import Ouroboros.Network.BlockFetch.ClientState (PeerFetchInFlight (..), - PeerFetchStatus (..), readFetchClientState) -import Ouroboros.Network.ConnectionId (remoteAddress) -import Ouroboros.Network.NodeToNode (RemoteAddress) - -import qualified Control.Concurrent.Class.MonadSTM.Strict as STM -import Control.DeepSeq (NFData (..)) -import Data.Aeson (ToJSON (..), Value (..), toJSON, (.=)) -import Data.Functor ((<&>)) -import qualified Data.List as List -import Data.Map.Strict (Map) -import qualified Data.Map.Strict as Map -import qualified Data.Set as Set -import Data.Text (Text) -import qualified Data.Text as Text -import GHC.Generics (Generic) -import Text.Printf (printf) - -import NoThunks.Class (AllowThunk (..), NoThunks) - -{- HLINT ignore "Use =<<" -} -{- HLINT ignore "Use <=<" -} - -data Peer blk = - Peer - !RemoteConnectionId - !(Net.AnchoredFragment (Header blk)) - !(PeerFetchStatus (Header blk)) - !(PeerFetchInFlight (Header blk)) - deriving (Generic) - deriving NoThunks via AllowThunk (Peer blk) - -instance NFData (Peer blk) where - rnf _ = () - -ppPeer :: Peer blk -> Text -ppPeer (Peer cid _af status inflight) = - Text.pack $ printf "%-15s %-8s %s" (ppCid cid) (ppStatus status) (ppInFlight inflight) - -ppCid :: RemoteConnectionId -> String -ppCid = show . remoteAddress - -ppInFlight :: PeerFetchInFlight header -> String -ppInFlight f = printf - "%5s %3d %5d %6d" - (ppMaxSlotNo $ peerFetchMaxSlotNo f) - (peerFetchReqsInFlight f) - (Set.size $ peerFetchBlocksInFlight f) - (peerFetchBytesInFlight f) - -ppMaxSlotNo :: Net.MaxSlotNo -> String -ppMaxSlotNo Net.NoMaxSlotNo = "???" -ppMaxSlotNo (Net.MaxSlotNo x) = show (unSlotNo x) - -ppStatus :: PeerFetchStatus header -> String -ppStatus = \case - PeerFetchStatusShutdown -> "shutdown" - PeerFetchStatusAberrant -> "aberrant" - PeerFetchStatusBusy -> "fetching" - PeerFetchStatusReady {} -> "ready" - PeerFetchStatusStarting -> "starting" - -getCurrentPeers - :: forall blk. Net.HasHeader (Header blk) - => NodeKernelData blk - -> IO [Peer blk] -getCurrentPeers nkd = mapNodeKernelDataIO extractPeers nkd - <&> fromSMaybe mempty - where - tuple3pop :: (a, b, c) -> (a, b) - tuple3pop (a, b, _) = (a, b) - - peerFetchStatusForgetTime :: PeerFetchStatus (HeaderWithTime blk) -> PeerFetchStatus (Header blk) - peerFetchStatusForgetTime = \case - PeerFetchStatusShutdown -> PeerFetchStatusShutdown - PeerFetchStatusStarting -> PeerFetchStatusStarting - PeerFetchStatusAberrant -> PeerFetchStatusAberrant - PeerFetchStatusBusy -> PeerFetchStatusBusy - PeerFetchStatusReady points idle -> PeerFetchStatusReady (Set.mapMonotonic Net.castPoint points) idle - - peerFetchInFlightForgetTime :: PeerFetchInFlight (HeaderWithTime blk) -> PeerFetchInFlight (Header blk) - peerFetchInFlightForgetTime inflight = - inflight {peerFetchBlocksInFlight = Set.mapMonotonic Net.castPoint (peerFetchBlocksInFlight inflight)} - - getCandidates - :: STM.STM IO (Map peer (ChainSyncClientHandle IO blk)) - -> STM.STM IO (Map peer (Net.AnchoredFragment (Header blk))) - getCandidates handle = viewChainSyncState handle (Net.mapAnchoredFragment hwtHeader . csCandidate) - - extractPeers :: NodeKernel IO RemoteAddress LocalConnectionId blk - -> IO [Peer blk] - extractPeers kernel = do - peerStates <- fmap tuple3pop <$> ( STM.atomically - . (>>= traverse readFetchClientState) - . Net.readFetchClientsStateVars - . getFetchClientRegistry $ kernel - ) - candidates <- STM.atomically . getCandidates . cschcMap . getChainSyncHandles $ kernel - - let peers = flip Map.mapMaybeWithKey candidates $ \cid af -> - maybe Nothing - (\(status, inflight) -> Just $ Peer cid af (peerFetchStatusForgetTime status) (peerFetchInFlightForgetTime inflight)) - $ Map.lookup cid peerStates - pure . Map.elems $ peers - --- | Trace peers list, it will be forwarded to an external process --- (for example, to RTView service). -tracePeers - :: Trace IO Text - -> [Peer blk] - -> IO () -tracePeers tr peers = do - let tr' = appendName "metrics" tr - let tr'' = appendName "peersFromNodeKernel" tr' - meta <- mkLOMeta Notice Public - traceNamedObject tr'' (meta, LogStructured $ toObject MaximalVerbosity peers) - --- | Instances for converting [Peer blk] to Object. - -instance ToObject [Peer blk] where - toObject MinimalVerbosity _ = mempty - toObject _ [] = mempty - toObject verb xs = mconcat - [ "kind" .= String "NodeKernelPeers" - , "peers" .= toJSON - (List.foldl' (\acc x -> toObject verb x : acc) [] xs) - ] - -instance ToObject (Peer blk) where - toObject _verb (Peer cid _af status inflight) = - mconcat [ "peerAddress" .= String (Text.pack . show . remoteAddress $ cid) - , "peerStatus" .= String (Text.pack . ppStatus $ status) - , "peerSlotNo" .= String (Text.pack . ppMaxSlotNo . peerFetchMaxSlotNo $ inflight) - , "peerReqsInF" .= String (Text.pack . show . peerFetchReqsInFlight $ inflight) - , "peerBlocksInF" .= String (Text.pack . show . Set.size . peerFetchBlocksInFlight $ inflight) - , "peerBytesInF" .= String (Text.pack . show . peerFetchBytesInFlight $ inflight) - ] diff --git a/cardano-node/src/Cardano/Tracing/Tracers.hs b/cardano-node/src/Cardano/Tracing/Tracers.hs index 3657b3e0c4a..7aaf9b03cb4 100644 --- a/cardano-node/src/Cardano/Tracing/Tracers.hs +++ b/cardano-node/src/Cardano/Tracing/Tracers.hs @@ -359,7 +359,6 @@ mkTracers blockConfig tOpts@(TracingOnLegacy trSel) tr nodeKern ekgDirect = do , nodeStartupInfoTracer = nullTracer , nodeStateTracer = nullTracer , resourcesTracer = nullTracer - , peersTracer = nullTracer , ledgerMetricsTracer = nullTracer } where @@ -535,7 +534,6 @@ mkTracers _ _ _ _ _ = , nodeStateTracer = nullTracer , nodeVersionTracer = nullTracer , resourcesTracer = nullTracer - , peersTracer = nullTracer , ledgerMetricsTracer = nullTracer } diff --git a/cardano-node/test/Test/Cardano/Tracing/NewTracing/data/badConfig.yaml b/cardano-node/test/Test/Cardano/Tracing/NewTracing/data/badConfig.yaml index 0f23a53c33f..9d90ddd25bf 100644 --- a/cardano-node/test/Test/Cardano/Tracing/NewTracing/data/badConfig.yaml +++ b/cardano-node/test/Test/Cardano/Tracing/NewTracing/data/badConfig.yaml @@ -63,6 +63,4 @@ TraceOptions: TxSubmission.Remote: detail: DMinimal -TraceOptionPeerFrequency: 2000 - TraceOptionResourceFrequency: 5000 diff --git a/cardano-node/test/Test/Cardano/Tracing/NewTracing/data/goodConfig.yaml b/cardano-node/test/Test/Cardano/Tracing/NewTracing/data/goodConfig.yaml index bfc9b6be514..ddcdbda8935 100644 --- a/cardano-node/test/Test/Cardano/Tracing/NewTracing/data/goodConfig.yaml +++ b/cardano-node/test/Test/Cardano/Tracing/NewTracing/data/goodConfig.yaml @@ -63,6 +63,4 @@ TraceOptions: TxSubmission.Remote: detail: DMinimal -TraceOptionPeerFrequency: 2000 - TraceOptionResourceFrequency: 5000 diff --git a/cardano-tracer/docs/cardano-rtview.md b/cardano-tracer/docs/cardano-rtview.md index b244d8a1aa8..c3316551b79 100644 --- a/cardano-tracer/docs/cardano-rtview.md +++ b/cardano-tracer/docs/cardano-rtview.md @@ -80,7 +80,6 @@ Now, open your node's configuration file (if you took it from the [Cardano World ] } }, -"TraceOptionPeerFrequency": 2000, "TraceOptionResourceFrequency": 5000, "TurnOnLogMetrics": false, "TraceOptionNodeName": "relay-1" diff --git a/cardano-tracer/docs/cardano-tracer.md b/cardano-tracer/docs/cardano-tracer.md index 51c2876c42c..58e094b9152 100644 --- a/cardano-tracer/docs/cardano-tracer.md +++ b/cardano-tracer/docs/cardano-tracer.md @@ -19,7 +19,7 @@ - [Logging](#logging) - [Logs Rotation](#logs-rotation) - [Prometheus](#prometheus) - - [Prometheus HTTP service discovery](#prometheus-http-sd) + - [Prometheus HTTP service discovery](#prometheus-http-service-discovery) - [EKG Monitoring](#ekg-monitoring) - [Verbosity](#verbosity) - [RTView](#rtview) diff --git a/cardano-tracer/src/Cardano/Tracer/MetaTrace.hs b/cardano-tracer/src/Cardano/Tracer/MetaTrace.hs index ee01fddc8a0..318a2333086 100644 --- a/cardano-tracer/src/Cardano/Tracer/MetaTrace.hs +++ b/cardano-tracer/src/Cardano/Tracer/MetaTrace.hs @@ -287,7 +287,6 @@ configTracerTracer defSeverity tr = do TraceConfig { tcForwarder = Nothing , tcNodeName = Nothing - , tcPeerFrequency = Nothing , tcResourceFrequency = Nothing , tcLedgerMetricsFrequency = Nothing , tcMetricsPrefix = Nothing diff --git a/trace-dispatcher/CHANGELOG.md b/trace-dispatcher/CHANGELOG.md index 9b9e429a928..08a8037431d 100644 --- a/trace-dispatcher/CHANGELOG.md +++ b/trace-dispatcher/CHANGELOG.md @@ -1,5 +1,10 @@ # Revision history for trace-dispatcher +## 2.11.1 -- Dez 2025 + +* Removed `TraceConfig.tcPeerFrequency` and hence `TraceOptionPeerFrequency` from config representation +* Removed unused module `Cardano.Logging.Types.NodePeers` + ## 2.11.0 -- Nov 2025 * `class LogFormatting`: remove redundant `forHumanFromMachine` and `forHumanOrMachine` (the system already does that inherently) diff --git a/trace-dispatcher/doc/config.json b/trace-dispatcher/doc/config.json index 89ed58239fd..5dac88a9edd 100644 --- a/trace-dispatcher/doc/config.json +++ b/trace-dispatcher/doc/config.json @@ -58,6 +58,5 @@ "maxFrequency": 2 } }, - "TraceOptionPeerFrequency": 2000, "TraceOptionResourceFrequency": 5000 } diff --git a/trace-dispatcher/doc/config.yaml b/trace-dispatcher/doc/config.yaml index 55a6819d875..c9d5cb22869 100644 --- a/trace-dispatcher/doc/config.yaml +++ b/trace-dispatcher/doc/config.yaml @@ -61,6 +61,4 @@ TraceOptions: BlockFetchClient.CompletedBlockFetch: maxFrequency: 2.0 -TraceOptionPeerFrequency: 2000 - TraceOptionResourceFrequency: 5000 diff --git a/trace-dispatcher/doc/trace-dispatcher.md b/trace-dispatcher/doc/trace-dispatcher.md index 582c646f46f..afc96d0cdce 100644 --- a/trace-dispatcher/doc/trace-dispatcher.md +++ b/trace-dispatcher/doc/trace-dispatcher.md @@ -343,9 +343,6 @@ TraceOptions: TraceOptionForwarder: # Configure the forwarder maxReconnectDelay: 20 -# Frequency of Peer messages set to two seconds -TraceOptionPeerFrequency: 2000 - # Any metrics emittted will get this prefix TraceOptionMetricsPrefix: "cardano.node.metrics." ``` @@ -377,7 +374,6 @@ The same in JSON looks like this: "TraceOptionForwarder": { "maxReconnectDelay": 20 }, - "TraceOptionPeerFrequency": 2000, "TraceOptionMetricsPrefix": "cardano.node.metrics." } ``` diff --git a/trace-dispatcher/src/Cardano/Logging/ConfigurationParser.hs b/trace-dispatcher/src/Cardano/Logging/ConfigurationParser.hs index ce8d5c5f74a..e5fd0369b89 100644 --- a/trace-dispatcher/src/Cardano/Logging/ConfigurationParser.hs +++ b/trace-dispatcher/src/Cardano/Logging/ConfigurationParser.hs @@ -33,7 +33,6 @@ data ConfigRepresentation = ConfigRepresentation { , traceOptionForwarder :: Maybe TraceOptionForwarder , traceOptionNodeName :: Maybe Text , traceOptionMetricsPrefix :: Maybe Text - , traceOptionPeerFrequency :: Maybe Int , traceOptionResourceFrequency :: Maybe Int , traceOptionLedgerMetricsFrequency :: Maybe Int } @@ -45,7 +44,6 @@ instance AE.FromJSON ConfigRepresentation where <*> obj .:? "TraceOptionForwarder" <*> obj .:? "TraceOptionNodeName" <*> obj .:? "TraceOptionMetricsPrefix" - <*> obj .:? "TraceOptionPeerFrequency" <*> obj .:? "TraceOptionResourceFrequency" <*> obj .:? "TraceOptionLedgerMetricsFrequency" parseJSON _ = mempty @@ -56,7 +54,6 @@ instance AE.ToJSON ConfigRepresentation where , "TraceOptionForwarder" .= traceOptionForwarder , "TraceOptionNodeName" .= traceOptionNodeName , "TraceOptionMetricsPrefix" .= traceOptionMetricsPrefix - , "TraceOptionPeerFrequency" .= traceOptionPeerFrequency , "TraceOptionResourceFrequency" .= traceOptionResourceFrequency , "TraceOptionLedgerMetricsFrequency" .= traceOptionLedgerMetricsFrequency ] @@ -115,7 +112,6 @@ readConfigurationWithDefault fp defaultConf = do (tcForwarder fileConf <|> tcForwarder defaultConf) (tcNodeName fileConf <|> tcNodeName defaultConf) (tcMetricsPrefix fileConf <|> tcMetricsPrefix defaultConf) - (tcPeerFrequency fileConf <|> tcPeerFrequency defaultConf) (tcResourceFrequency fileConf <|> tcResourceFrequency defaultConf) (tcLedgerMetricsFrequency fileConf <|> tcLedgerMetricsFrequency defaultConf) @@ -148,7 +144,6 @@ parseRepresentation bs = transform (decodeEither' bs) (traceOptionForwarder cr) (traceOptionNodeName cr) (traceOptionMetricsPrefix cr) - (traceOptionPeerFrequency cr) (traceOptionResourceFrequency cr) (traceOptionLedgerMetricsFrequency cr) @@ -171,7 +166,6 @@ configToRepresentation traceConfig = (tcForwarder traceConfig) (tcNodeName traceConfig) (tcMetricsPrefix traceConfig) - (tcPeerFrequency traceConfig) (tcResourceFrequency traceConfig) (tcLedgerMetricsFrequency traceConfig) where diff --git a/trace-dispatcher/src/Cardano/Logging/Types.hs b/trace-dispatcher/src/Cardano/Logging/Types.hs index 59a18ba73b4..2a7fe9681bc 100644 --- a/trace-dispatcher/src/Cardano/Logging/Types.hs +++ b/trace-dispatcher/src/Cardano/Logging/Types.hs @@ -545,8 +545,6 @@ data TraceConfig = TraceConfig { , tcNodeName :: Maybe Text -- | Optional prefix for metrics. , tcMetricsPrefix :: Maybe Text - -- | Optional peer trace frequency in milliseconds. - , tcPeerFrequency :: Maybe Int -- | Optional resource trace frequency in milliseconds. , tcResourceFrequency :: Maybe Int -- | Optional ledger metrics frequency in milliseconds. @@ -560,7 +558,6 @@ emptyTraceConfig = TraceConfig { , tcForwarder = Nothing , tcNodeName = Nothing , tcMetricsPrefix = Nothing - , tcPeerFrequency = Just 2000 -- Every 2 seconds , tcResourceFrequency = Just 5000 -- Every five seconds , tcLedgerMetricsFrequency = Just 1 -- Every slot } diff --git a/trace-dispatcher/test/Cardano/Logging/Test/Unit/Configuration.hs b/trace-dispatcher/test/Cardano/Logging/Test/Unit/Configuration.hs index 14f77adb2d4..70ec4ff47ea 100644 --- a/trace-dispatcher/test/Cardano/Logging/Test/Unit/Configuration.hs +++ b/trace-dispatcher/test/Cardano/Logging/Test/Unit/Configuration.hs @@ -57,7 +57,6 @@ config1 = TraceConfig { , tofMaxReconnectDelay = 60 } , tcNodeName = Nothing - , tcPeerFrequency = Nothing , tcResourceFrequency = Nothing , tcMetricsPrefix = Nothing , tcLedgerMetricsFrequency = Nothing @@ -76,7 +75,6 @@ config2 = TraceConfig { , tofMaxReconnectDelay = 60 } , tcNodeName = Just "node-1" - , tcPeerFrequency = Nothing , tcResourceFrequency = Nothing , tcMetricsPrefix = Nothing , tcLedgerMetricsFrequency = Nothing diff --git a/trace-dispatcher/test/Cardano/Logging/Test/Unit/Documentation.hs b/trace-dispatcher/test/Cardano/Logging/Test/Unit/Documentation.hs index 82fb305e52c..f2e97d83df0 100644 --- a/trace-dispatcher/test/Cardano/Logging/Test/Unit/Documentation.hs +++ b/trace-dispatcher/test/Cardano/Logging/Test/Unit/Documentation.hs @@ -40,7 +40,6 @@ config1 = TraceConfig { , tofMaxReconnectDelay = 60 } , tcNodeName = Nothing - , tcPeerFrequency = Nothing , tcResourceFrequency = Nothing , tcMetricsPrefix = Just "cardano" , tcLedgerMetricsFrequency = Nothing diff --git a/trace-dispatcher/trace-dispatcher.cabal b/trace-dispatcher/trace-dispatcher.cabal index efca9608ee7..c02ec6af323 100644 --- a/trace-dispatcher/trace-dispatcher.cabal +++ b/trace-dispatcher/trace-dispatcher.cabal @@ -1,7 +1,7 @@ cabal-version: 3.0 name: trace-dispatcher -version: 2.11.0 +version: 2.11.1 synopsis: Tracers for Cardano description: Package for development of simple and efficient tracers based on the arrow based contra-tracer package @@ -63,7 +63,6 @@ library Cardano.Logging.Types Cardano.Logging.Types.TraceMessage Cardano.Logging.Types.NodeInfo - Cardano.Logging.Types.NodePeers Cardano.Logging.Types.NodeStartupInfo Cardano.Logging.Utils Control.Tracer.Arrow