Skip to content

Commit 57534b7

Browse files
committed
Review changes regarding tracing
1 parent 10b1a67 commit 57534b7

File tree

7 files changed

+35
-43
lines changed

7 files changed

+35
-43
lines changed

cardano-node/src/Cardano/Node/Tracing/StateRep.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import qualified Ouroboros.Consensus.Storage.LedgerDB as LgrDb
3636
import Ouroboros.Network.Block (pointSlot)
3737

3838
import Control.DeepSeq (NFData)
39-
import Data.Aeson hiding (Result(..))
39+
import Data.Aeson hiding (Result (..))
4040
import Data.Text as T (Text, pack)
4141
import Data.Time.Clock
4242
import Data.Time.Clock.POSIX
@@ -112,14 +112,16 @@ deriving instance (NFData NodeState)
112112

113113
instance LogFormatting NodeState where
114114
forMachine _ = \case
115+
NodeTracingOnlineConfiguring -> mconcat
116+
[ "kind" .= String "NodeTracingOnlineConfiguring" ]
115117
NodeOpeningDbs x -> mconcat
116118
[ "kind" .= String "NodeOpeningDbs", "openingDb" .= toJSON x]
117119
NodeReplays x -> mconcat
118120
[ "kind" .= String "NodeReplays", "replays" .= toJSON x]
119121
NodeInitChainSelection x -> mconcat
120122
[ "kind" .= String "NodeInitChainSelection", "chainSel" .= toJSON x]
121123
NodeKernelOnline -> mconcat
122-
[ "kind" .= String "NodeInitChainSelection"]
124+
[ "kind" .= String "NodeKernelOnline"]
123125
NodeAddBlock x -> mconcat
124126
[ "kind" .= String "NodeAddBlock", "addBlock" .= toJSON x]
125127
NodeStartup x -> mconcat
@@ -128,7 +130,6 @@ instance LogFormatting NodeState where
128130
[ "kind" .= String "NodeShutdown", "shutdown" .= toJSON x]
129131
NodeTracingFailure x -> mconcat
130132
[ "kind" .= String "NodeTracingFailure", "message" .= toJSON x]
131-
_ -> mempty
132133

133134
forHuman (NodeTracingFailure errMsg) = T.pack errMsg
134135
forHuman _ = ""
@@ -186,9 +187,9 @@ instance MetaTrace NodeState where
186187
documentFor (Namespace _ ["NodeInitChainSelection"]) = Just
187188
"Performing initial chain selection"
188189
documentFor (Namespace _ ["NodeKernelOnline"]) = Just
189-
""
190+
"Tracing system configured and node kernel is online"
190191
documentFor (Namespace _ ["NodeAddBlock"]) = Just
191-
"Applying block"
192+
"Applying block"
192193
documentFor (Namespace _ ["NodeStartup"]) = Just
193194
"Node startup"
194195
documentFor (Namespace _ ["NodeShutdown"]) = Just

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

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,20 @@ module Cardano.Node.Tracing.Tracers.Diffusion
1717

1818
import Cardano.Logging
1919
import Cardano.Node.Configuration.TopologyP2P ()
20-
21-
#ifdef linux_HOST_OS
22-
import Network.Mux.TCPInfo (StructTCPInfo (..))
23-
#endif
2420
import qualified Ouroboros.Network.Diffusion.Types as Diff
2521
import Ouroboros.Network.PeerSelection.LedgerPeers (NumberOfPeers (..), PoolStake (..),
2622
TraceLedgerPeers (..))
2723
import qualified Ouroboros.Network.Protocol.Handshake.Type as HS
28-
import qualified Network.Mux as Mux
29-
import Network.Mux.Types (SDUHeader (..), unRemoteClockModel)
30-
import Network.TypedProtocol.Codec (AnyMessage (..))
3124

3225
import Data.Aeson (Value (String), (.=))
3326
import qualified Data.List as List
3427
import Data.Text (Text, pack)
3528
import Data.Typeable
3629
import Formatting
30+
import qualified Network.Mux as Mux
31+
import Network.Mux.TCPInfo (StructTCPInfo (..))
32+
import Network.Mux.Types (SDUHeader (..), unRemoteClockModel)
33+
import Network.TypedProtocol.Codec (AnyMessage (..))
3734

3835
--------------------------------------------------------------------------------
3936
-- Mux Tracer
@@ -890,8 +887,6 @@ instance MetaTrace TraceLedgerPeers where
890887
severityFor (Namespace _ ["NotEnoughLedgerPeers"]) _ = Just Warning
891888
severityFor (Namespace _ ["NotEnoughBigLedgerPeers"]) _ = Just Warning
892889
severityFor (Namespace _ ["TraceLedgerPeersDomains"]) _ = Just Debug
893-
severityFor (Namespace _ ["TraceLedgerPeersResult"]) _ = Just Debug
894-
severityFor (Namespace _ ["TraceLedgerPeersFailure"]) _ = Just Debug
895890
severityFor (Namespace _ ["UsingBigLedgerPeerSnapshot"]) _ = Just Debug
896891
severityFor _ _ = Nothing
897892

@@ -917,10 +912,6 @@ instance MetaTrace TraceLedgerPeers where
917912
""
918913
documentFor (Namespace _ ["TraceLedgerPeersDomains"]) = Just
919914
""
920-
documentFor (Namespace _ ["TraceLedgerPeersResult"]) = Just
921-
""
922-
documentFor (Namespace _ ["TraceLedgerPeersFailure"]) = Just
923-
""
924915
documentFor (Namespace _ ["UsingBigLedgerPeerSnapshot"]) = Just $ mconcat
925916
[ "Trace for when a request for big ledger peers is fulfilled from the snapshot file"
926917
, " defined in the topology configuration file."]
@@ -937,7 +928,5 @@ instance MetaTrace TraceLedgerPeers where
937928
, Namespace [] ["ReusingLedgerState"]
938929
, Namespace [] ["FallingBackToPublicRootPeers"]
939930
, Namespace [] ["TraceLedgerPeersDomains"]
940-
, Namespace [] ["TraceLedgerPeersResult"]
941-
, Namespace [] ["TraceLedgerPeersFailure"]
942931
, Namespace [] ["UsingBigLedgerPeerSnapshot"]
943932
]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ instance ( Show (BlockNodeToNodeVersion blk)
223223
mconcat [ "kind" .= String "LedgerPeerSnapshot"
224224
, "message" .= String (
225225
mconcat [
226-
"Topology file misconfiguration: peer snapshot recorded ",
226+
"Topology file misconfiguration: peer snapshot recorded ",
227227
showT wOrigin, " but topology specifies ",
228228
"to use ledger peers: ", showT useLedgerPeers,
229229
". Possible fix: update your big ledger peer snapshot ",

cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ module Cardano.Tracing.OrphanInstances.Network
2121
, FetchDecisionToJSON (..)
2222
) where
2323

24+
import Cardano.Network.Diffusion (CardanoDebugPeerSelection, CardanoPeerSelectionCounters,
25+
CardanoTraceLocalRootPeers, CardanoTracePeerSelection, TraceChurnMode (..))
26+
import Cardano.Network.OrphanInstances ()
27+
import qualified Cardano.Network.PeerSelection.ExtraRootPeers as Cardano.PublicRootPeers
28+
import qualified Cardano.Network.PeerSelection.Governor.PeerSelectionState as Cardano
29+
import qualified Cardano.Network.PeerSelection.Governor.Types as Cardano
2430
import Cardano.Node.Queries (ConvertTxId)
2531
import Cardano.Tracing.OrphanInstances.Common
2632
import Cardano.Tracing.Render
@@ -29,12 +35,6 @@ import Ouroboros.Consensus.Ledger.Query (BlockQuery, Query)
2935
import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, GenTx, GenTxId,
3036
HasTxs (..), TxId, txId)
3137
import Ouroboros.Consensus.Node.Run (RunNode, estimateBlockSize)
32-
import Cardano.Network.Diffusion (CardanoDebugPeerSelection,
33-
CardanoTraceLocalRootPeers, CardanoTracePeerSelection,
34-
CardanoPeerSelectionCounters, TraceChurnMode (..))
35-
import qualified Cardano.Network.PeerSelection.Governor.PeerSelectionState as Cardano
36-
import qualified Cardano.Network.PeerSelection.Governor.Types as Cardano
37-
import qualified Cardano.Network.PeerSelection.ExtraRootPeers as Cardano.PublicRootPeers
3838
import qualified Ouroboros.Network.AnchoredFragment as AF
3939
import qualified Ouroboros.Network.AnchoredSeq as AS
4040
import Ouroboros.Network.Block
@@ -45,28 +45,29 @@ import Ouroboros.Network.BlockFetch.Decision (FetchDecision, FetchDecl
4545
import qualified Ouroboros.Network.BlockFetch.Decision.Trace as BlockFetch
4646
import Ouroboros.Network.ConnectionHandler (ConnectionHandlerTrace (..))
4747
import Ouroboros.Network.ConnectionId (ConnectionId (..))
48-
import Ouroboros.Network.ConnectionManager.Core as ConnMgr (Trace (..))
4948
import Ouroboros.Network.ConnectionManager.ConnMap (ConnMap (..))
49+
import Ouroboros.Network.ConnectionManager.Core as ConnMgr (Trace (..))
5050
import Ouroboros.Network.ConnectionManager.State (ConnStateId (..))
5151
import qualified Ouroboros.Network.ConnectionManager.Types as ConnMgr
52-
import Ouroboros.Network.PeerSelection.RootPeersDNS.DNSActions (DNSTrace (..))
53-
import qualified Ouroboros.Network.Diffusion.Types as Diffusion
5452
import Ouroboros.Network.DeltaQ (GSV (..), PeerGSV (..))
53+
import qualified Ouroboros.Network.Diffusion.Types as Diffusion
5554
import qualified Ouroboros.Network.Driver.Stateful as Stateful
5655
import qualified Ouroboros.Network.InboundGovernor as InboundGovernor
5756
import qualified Ouroboros.Network.InboundGovernor.State as InboundGovernor
5857
import Ouroboros.Network.KeepAlive (TraceKeepAliveClient (..))
5958
import Ouroboros.Network.NodeToClient (NodeToClientVersion (..))
6059
import qualified Ouroboros.Network.NodeToClient as NtC
61-
import Ouroboros.Network.NodeToNode (NodeToNodeVersion (..),
62-
RemoteAddress, TraceSendRecv (..))
60+
import Ouroboros.Network.NodeToNode (NodeToNodeVersion (..), RemoteAddress,
61+
TraceSendRecv (..))
6362
import qualified Ouroboros.Network.NodeToNode as NtN
63+
import Ouroboros.Network.OrphanInstances ()
6464
import Ouroboros.Network.PeerSelection.Governor (DebugPeerSelection (..),
6565
DebugPeerSelectionState (..), PeerSelectionCounters, PeerSelectionState (..),
6666
PeerSelectionTargets (..), PeerSelectionView (..), TracePeerSelection (..),
6767
peerSelectionStateToCounters)
6868
import Ouroboros.Network.PeerSelection.LedgerPeers
6969
import Ouroboros.Network.PeerSelection.PeerStateActions (PeerSelectionActionsTrace (..))
70+
import Ouroboros.Network.PeerSelection.RootPeersDNS.DNSActions (DNSTrace (..))
7071
import Ouroboros.Network.PeerSelection.RootPeersDNS.LocalRootPeers
7172
(TraceLocalRootPeers (..))
7273
import Ouroboros.Network.PeerSelection.RootPeersDNS.PublicRootPeers
@@ -92,9 +93,6 @@ import Ouroboros.Network.TxSubmission.Inbound (ProcessedTxCount (..),
9293
TraceTxSubmissionInbound (..))
9394
import Ouroboros.Network.TxSubmission.Outbound (TraceTxSubmissionOutbound (..))
9495

95-
import Cardano.Network.OrphanInstances ()
96-
import Ouroboros.Network.OrphanInstances ()
97-
9896
import Control.Exception (Exception (..))
9997
import Control.Monad.Class.MonadTime.SI (DiffTime, Time (..))
10098
import Data.Aeson (Value (..))
@@ -237,8 +235,7 @@ instance HasSeverityAnnotation TraceLedgerPeers where
237235
NotEnoughLedgerPeers {} -> Warning
238236
NotEnoughBigLedgerPeers {} -> Warning
239237
TraceLedgerPeersDomains {} -> Debug
240-
-- TraceLedgerPeersResult {} -> Debug
241-
-- TraceLedgerPeersFailure {} -> Debug
238+
242239
UsingBigLedgerPeerSnapshot {} -> Debug
243240

244241

cardano-tracer/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ChangeLog
22

33
## 0.3.5 (October, 2025)
4-
* Updated to `ekg-forward-1.0`, `ouroboros-network-0.22.3`, `ouroboros-network-api-0.16` and `ouroboros-network-0.22.3`.
4+
* Updated to `ekg-forward-1.0`, `ouroboros-network-0.22.3`, `ouroboros-network-api-0.16`.
55

66
## 0.3.4 (July, 2025)
77
* Forwarding protocol supports connections over TCP socket, in addition to Unix domain sockets.

trace-dispatcher/doc/trace-dispatcher.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,15 @@ The usual form to provide a configuration is via a configuration file, wich can
306306
can be given based on a namespace are: `severity`, `detail`, `backends` and `limiter`.
307307

308308
Backends can be a combination of `Forwarder`, `EKGBackend`, `PrometheusSimple [suffix|nosuffix] [bindhost] <port>` and
309-
one of `Stdout MachineFormat`, `Stdout HumanFormatColoured` and `Stdout HumanFormatUncoloured`.
309+
one of `Stdout MachineFormat`, `Stdout HumanFormatColoured` and `Stdout HumanFormatUncoloured`.
310310

311311
The connection for the `Forwarder` backend is provided on the application command line. It is a socket path over which applications like `cardano-node` connect with `cardano-tracer`. `--tracer-socket-path-connect /path/to/forward.sock` sets
312312
the backends's role to `Initiator`, whereas `--tracer-socket-path-accept /path/to/forward.sock` sets it to `Responder`. Except for debugging purposes, the former should be chosen: the application takes the `Initiator` role, and `cardano-tracer` is
313-
in the `Responder` role, which means setting its network `tag` to `AcceptAt` in its config (see there).
313+
in the `Responder` role, which means setting its network `tag` to `AcceptAt` in its config (see there).
314314

315315
The `PrometheusSimple` backend provides Prometheus metrics _directly from the process_, without forwarding. It always applies to all tracers globally, and should only be configured once.
316316
Providing an available port number in the connection string is mandatory; this will bind to localhost only by default. By specifying a bind host, the metrics can be queried remotely, e.g. over IPv4 by
317-
binding to `0.0.0.0`, or IPv6 by binding to `::`. Metrics will be available under the URL `/metrics`.
317+
binding to `0.0.0.0`, or IPv6 by binding to `::`. Metrics will be available under the URL `/metrics`.
318318
The `nosuffix` modifier removes suffixes like `_int` from metrics names, making them more similar to those in the old system; `suffix` is the implicit default and can be omitted.
319319

320320
*CAUTION*: Generally allowing remote queries of Prometheus metrics is risky and should only be done in an environment you control.
@@ -691,6 +691,11 @@ The consistency checks cover the following aspects:
691691

692692
- Any namespace in the configuration must be found by a hierarchical lookup in `all namespaces`.
693693

694+
If the checker encounters any problems it emits a `TracerConsistencyWarnings` message through the
695+
`Cardano.Logging.TraceDispatcherMessage` type. The message is routed via the `Reflection` namespace
696+
and carries `Warninig` severity so that misconfigured namespaces are surfaced prominently in both the
697+
logs and forwarded tracing output.
698+
694699
## Trace Backends Overview
695700

696701
As mentioned earlier, trace backends serve as the final destinations for all traces once they have undergone trace interpretation, resulting in metrics and messages. The system defines three trace backends:

trace-dispatcher/src/Cardano/Logging/TraceDispatcherMessage.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ instance LogFormatting TraceDispatcherMessage where
6262
<> Text.intercalate (Text.singleton ' ') noMetrics <> ". Here is a complete list of all tracers: "
6363
<> Text.intercalate (Text.singleton ' ') allTracers <> "."
6464
forHuman (MetricsInfo mmap) = "Number of metrics delivered, " <> textShow mmap
65-
forHuman (TracerConsistencyWarnings errs) = "Consistency check found error: " <> textShow errs
65+
forHuman (TracerConsistencyWarnings errs) = "Consistency check found warnings: " <> textShow errs
6666
forHuman (TracerInfoConfig tc) = "Effective Tracer config is: " <> Text.decodeUtf8 (toStrict (encode tc))
6767

6868

@@ -134,7 +134,7 @@ instance MetaTrace TraceDispatcherMessage where
134134
severityFor (Namespace _ ["UnknownNamespace"]) _ = Just Error
135135
severityFor (Namespace _ ["TracerInfo"]) _ = Just Notice
136136
severityFor (Namespace _ ["MetricsInfo"]) _ = Just Debug
137-
severityFor (Namespace _ ["TracerConsistencyWarnings"]) _ = Just Error
137+
severityFor (Namespace _ ["TracerConsistencyWarnings"]) _ = Just Warning
138138
severityFor (Namespace _ ["TracerConfigInfo"]) _ = Just Notice
139139
severityFor _ _ = Nothing
140140

0 commit comments

Comments
 (0)