Skip to content

Commit ae273b7

Browse files
committed
trace-dispatcher: adoptions for consistency checks
1 parent de061e9 commit ae273b7

File tree

5 files changed

+145
-42
lines changed

5 files changed

+145
-42
lines changed

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

Lines changed: 127 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module Cardano.Node.Tracing.Documentation
2020
import Control.Exception (SomeException)
2121
import Data.Aeson.Types (ToJSON)
2222
import Data.Proxy (Proxy (..))
23+
import qualified Data.Text as T
2324
import qualified Data.Text.IO as T
2425
import GHC.Generics (Generic)
2526
import Network.Mux (MuxTrace (..), WithMuxBearer (..))
@@ -193,52 +194,60 @@ docTracers configFileName outputFileName _ _ _ = do
193194
configReflection <- emptyConfigReflection
194195

195196
-- NodeInfo tracer
196-
nodeInfoTr <- mkDataPointTracer
197+
nodeInfoDp <- mkDataPointTracer
197198
trDataPoint
198-
configureTracers configReflection trConfig [nodeInfoTr]
199-
nodeInfoTrDoc <- documentTracer (nodeInfoTr :: Trace IO NodeInfo)
199+
configureTracers configReflection trConfig [nodeInfoDp]
200+
nodeInfoDpDoc <- documentTracer (nodeInfoDp :: Trace IO NodeInfo)
200201

201-
nodeStartupInfoTr <- mkDataPointTracer
202+
nodeStartupInfoDp <- mkDataPointTracer
202203
trDataPoint
203-
configureTracers configReflection trConfig [nodeStartupInfoTr]
204-
nodeStartupInfoTrDoc <- documentTracer
205-
(nodeStartupInfoTr :: Trace IO NodeStartupInfo)
204+
configureTracers configReflection trConfig [nodeStartupInfoDp]
205+
nodeStartupInfoDpDoc <- documentTracer
206+
(nodeStartupInfoDp :: Trace IO NodeStartupInfo)
206207

207208
-- State tracer
208209
stateTr <- mkCardanoTracer
209210
trBase trForward mbTrEKG
210211
["NodeState"]
211212
configureTracers configReflection trConfig [stateTr]
212213
stateTrDoc <- documentTracer (stateTr :: Trace IO SR.NodeState)
214+
let stateNS = map (nsGetComplete . nsReplacePrefix ["NodeState"])
215+
(allNamespaces :: [Namespace SR.NodeState])
213216

214217
-- Peers tracer
215-
216218
peersTr <- mkCardanoTracer
217219
trBase trForward mbTrEKG
218220
["Net", "Peers", "List"]
219221
configureTracers configReflection trConfig [peersTr]
220222
peersTrDoc <- documentTracer (peersTr :: Trace IO [PeerT blk])
223+
let peersNS = map (nsGetComplete . nsReplacePrefix ["Net", "Peers", "List"])
224+
(allNamespaces :: [Namespace [PeerT blk]])
221225

222226
-- Resource tracer
223227
resourcesTr <- mkCardanoTracer
224228
trBase trForward mbTrEKG
225229
[]
226230
configureTracers configReflection trConfig [resourcesTr]
227231
resourcesTrDoc <- documentTracer (resourcesTr :: Trace IO ResourceStats)
232+
let resourcesNS = map nsGetComplete
233+
(allNamespaces :: [Namespace ResourceStats])
228234

229235
-- Startup tracer
230236
startupTr <- mkCardanoTracer
231237
trBase trForward mbTrEKG
232238
["Startup"]
233239
configureTracers configReflection trConfig [startupTr]
234240
startupTrDoc <- documentTracer (startupTr :: Trace IO (StartupTrace blk))
241+
let startupNS = map (nsGetComplete . nsReplacePrefix ["Startup"])
242+
(allNamespaces :: [Namespace (StartupTrace blk)])
235243

236244
shutdownTr <- mkCardanoTracer
237245
trBase trForward mbTrEKG
238246
["Shutdown"]
239247
configureTracers configReflection trConfig [shutdownTr]
240248
shutdownTrDoc <- documentTracer (shutdownTr :: Trace IO ShutdownTrace)
241-
249+
let shutdownNS = map (nsGetComplete . nsReplacePrefix ["Shutdown"])
250+
(allNamespaces :: [Namespace ShutdownTrace])
242251

243252
chainDBTr <- mkCardanoTracer'
244253
trBase trForward mbTrEKG
@@ -247,12 +256,16 @@ docTracers configFileName outputFileName _ _ _ = do
247256
configureTracers configReflection trConfig [chainDBTr]
248257
chainDBTrDoc <- documentTracer (chainDBTr ::
249258
Trace IO (ChainDB.TraceEvent blk))
259+
let chainDBNS = map (nsGetComplete . nsReplacePrefix ["ChainDB"])
260+
(allNamespaces :: [Namespace (ChainDB.TraceEvent blk)])
250261

251262
replayBlockTr <- mkCardanoTracer
252263
trBase trForward mbTrEKG
253264
["ChainDB", "ReplayBlock"]
254265
configureTracers configReflection trConfig [replayBlockTr]
255266
replayBlockTrDoc <- documentTracer (replayBlockTr :: Trace IO ReplayBlockStats)
267+
let replayBlockNS = map (nsGetComplete . nsReplacePrefix ["ChainDB", "ReplayBlock"])
268+
(allNamespaces :: [Namespace ReplayBlockStats])
256269

257270
-- Consensus tracers
258271

@@ -264,20 +277,30 @@ docTracers configFileName outputFileName _ _ _ = do
264277
(Trace IO (BlockFetch.TraceLabelPeer
265278
(ConnectionId RemoteAddress)
266279
(TraceChainSyncClientEvent blk))))
280+
let chainSyncClientNS = map
281+
(nsGetComplete . nsReplacePrefix ["ChainSync", "Client"])
282+
(allNamespaces :: [Namespace (BlockFetch.TraceLabelPeer
283+
(ConnectionId RemoteAddress)
284+
(TraceChainSyncClientEvent blk))])
267285

268286
chainSyncServerHeaderTr <- mkCardanoTracer
269287
trBase trForward mbTrEKG
270288
["ChainSync", "ServerHeader"]
271289
configureTracers configReflection trConfig [chainSyncServerHeaderTr]
272290
chainSyncServerHeaderTrDoc <- documentTracer (chainSyncServerHeaderTr ::
273291
(Trace IO (TraceChainSyncServerEvent blk)))
292+
let chainSyncServerHeaderNS = map (nsGetComplete . nsReplacePrefix ["ChainSync", "ServerHeader"])
293+
(allNamespaces :: [Namespace (TraceChainSyncServerEvent blk)])
274294

275295
chainSyncServerBlockTr <- mkCardanoTracer
276296
trBase trForward mbTrEKG
277297
["ChainSync", "ServerBlock"]
278298
configureTracers configReflection trConfig [chainSyncServerBlockTr]
279299
chainSyncServerBlockTrDoc <- documentTracer (chainSyncServerBlockTr ::
280300
(Trace IO (TraceChainSyncServerEvent blk)))
301+
let chainSyncServerBlockNS = map (nsGetComplete . nsReplacePrefix ["ChainSync", "ServerBlock"])
302+
(allNamespaces :: [Namespace (TraceChainSyncServerEvent blk)])
303+
281304

282305
blockFetchDecisionTr <- mkCardanoTracer
283306
trBase trForward mbTrEKG
@@ -287,6 +310,10 @@ docTracers configFileName outputFileName _ _ _ = do
287310
Trace IO [BlockFetch.TraceLabelPeer
288311
remotePeer
289312
(FetchDecision [Point (Header blk)])])
313+
let blockFetchDecisionNS = map (nsGetComplete . nsReplacePrefix ["BlockFetch", "Decision"])
314+
(allNamespaces :: [Namespace [BlockFetch.TraceLabelPeer
315+
remotePeer
316+
(FetchDecision [Point (Header blk)])]])
290317

291318
blockFetchClientTr <- mkCardanoTracer
292319
trBase trForward mbTrEKG
@@ -296,6 +323,10 @@ docTracers configFileName outputFileName _ _ _ = do
296323
Trace IO (BlockFetch.TraceLabelPeer
297324
remotePeer
298325
(BlockFetch.TraceFetchClientState (Header blk))))
326+
let blockFetchClientNS = map (nsGetComplete . nsReplacePrefix ["BlockFetch", "Client"])
327+
(allNamespaces :: [Namespace (BlockFetch.TraceLabelPeer
328+
remotePeer
329+
(BlockFetch.TraceFetchClientState (Header blk)))])
299330

300331
-- TODO Yup
301332
-- blockFetchClientMetricsTr <- do
@@ -311,13 +342,17 @@ docTracers configFileName outputFileName _ _ _ = do
311342
configureTracers configReflection trConfig [blockFetchServerTr]
312343
blockFetchServerTrDoc <- documentTracer (blockFetchServerTr ::
313344
Trace IO (TraceBlockFetchServerEvent blk))
345+
let blockFetchServerNS = map (nsGetComplete . nsReplacePrefix ["BlockFetch", "Server"])
346+
(allNamespaces :: [Namespace (TraceBlockFetchServerEvent blk)])
314347

315348
forgeKESInfoTr <- mkCardanoTracer
316349
trBase trForward mbTrEKG
317350
["Forge", "KESInfo"]
318351
configureTracers configReflection trConfig [forgeKESInfoTr]
319352
forgeKESInfoTrDoc <- documentTracer (forgeKESInfoTr ::
320353
Trace IO (Consensus.TraceLabelCreds HotKey.KESInfo))
354+
let forgeKESInfoNS = map (nsGetComplete . nsReplacePrefix ["Forge", "KESInfo"])
355+
(allNamespaces :: [Namespace (Consensus.TraceLabelCreds HotKey.KESInfo)])
321356

322357
txInboundTr <- mkCardanoTracer
323358
trBase trForward mbTrEKG
@@ -327,6 +362,10 @@ docTracers configFileName outputFileName _ _ _ = do
327362
Trace IO (BlockFetch.TraceLabelPeer
328363
remotePeer
329364
(TraceTxSubmissionInbound (GenTxId blk) (GenTx blk))))
365+
let txInboundNS = map (nsGetComplete . nsReplacePrefix ["TxSubmission", "TxInbound"])
366+
(allNamespaces :: [Namespace (BlockFetch.TraceLabelPeer
367+
remotePeer
368+
(TraceTxSubmissionInbound (GenTxId blk) (GenTx blk)))])
330369

331370
txOutboundTr <- mkCardanoTracer
332371
trBase trForward mbTrEKG
@@ -336,20 +375,30 @@ docTracers configFileName outputFileName _ _ _ = do
336375
Trace IO (BlockFetch.TraceLabelPeer
337376
remotePeer
338377
(TraceTxSubmissionOutbound (GenTxId blk) (GenTx blk))))
378+
let txOutboundNS = map (nsGetComplete . nsReplacePrefix ["TxSubmission", "TxOutbound"])
379+
(allNamespaces :: [Namespace (BlockFetch.TraceLabelPeer
380+
remotePeer
381+
(TraceTxSubmissionOutbound (GenTxId blk) (GenTx blk)))])
339382

340383
localTxSubmissionServerTr <- mkCardanoTracer
341384
trBase trForward mbTrEKG
342385
["TxSubmission", "LocalServer"]
343386
configureTracers configReflection trConfig [localTxSubmissionServerTr]
344387
localTxSubmissionServerTrDoc <- documentTracer (localTxSubmissionServerTr ::
345388
Trace IO (TraceLocalTxSubmissionServerEvent blk))
389+
let localTxSubmissionServerNS = map (nsGetComplete . nsReplacePrefix
390+
["TxSubmission", "LocalServer"])
391+
(allNamespaces :: [Namespace
392+
(TraceLocalTxSubmissionServerEvent blk)])
346393

347394
mempoolTr <- mkCardanoTracer
348395
trBase trForward mbTrEKG
349396
["Mempool"]
350397
configureTracers configReflection trConfig [mempoolTr]
351398
mempoolTrDoc <- documentTracer (mempoolTr ::
352399
Trace IO (TraceEventMempool blk))
400+
let mempoolNS = map (nsGetComplete . nsReplacePrefix ["Mempool"])
401+
(allNamespaces :: [Namespace (TraceEventMempool blk)])
353402

354403
forgeTr <- mkCardanoTracer
355404
trBase trForward mbTrEKG
@@ -679,9 +728,76 @@ docTracers configFileName outputFileName _ _ _ = do
679728
dtAcceptPolicyTrDoc <- documentTracer (dtAcceptPolicyTr ::
680729
Trace IO NtN.AcceptConnectionsPolicyTrace)
681730

682-
let bl = nodeInfoTrDoc
731+
let allNamespaces' :: [[T.Text]] =
732+
stateNS
733+
<> peersNS
734+
<> resourcesNS
735+
<> startupNS
736+
<> shutdownNS
737+
<> chainDBNS
738+
<> replayBlockNS
739+
-- -- Consensus
740+
<> chainSyncClientNS
741+
<> chainSyncServerHeaderNS
742+
<> chainSyncServerBlockNS
743+
<> blockFetchDecisionNS
744+
<> blockFetchClientNS
745+
<> blockFetchServerNS
746+
-- <> forgeKESInfoNS
747+
-- <> txInboundNS
748+
-- <> txOutboundNS
749+
-- <> localTxSubmissionServerNS
750+
-- <> mempoolNS
751+
-- <> forgeNS
752+
-- -- <> forgeThreadStatsNS
753+
-- <> blockchainTimeNS
754+
-- -- NodeToClient
755+
-- <> keepAliveClientNS
756+
-- <> chainSyncNS
757+
-- <> txMonitorNS
758+
-- <> txSubmissionNS
759+
-- <> stateQueryNS
760+
-- -- Node to Node
761+
-- <> chainSyncNodeNS
762+
-- <> chainSyncSerialisedNS
763+
-- <> blockFetchNS
764+
-- <> blockFetchSerialisedNS
765+
-- <> txSubmission2NS
766+
-- -- Diffusion
767+
-- <> dtMuxNS
768+
-- <> dtLocalMuxNS
769+
-- <> dtHandshakeNS
770+
-- <> dtLocalHandshakeNS
771+
-- <> dtDiffusionInitializationNS
772+
-- <> dtLedgerPeersNS
773+
-- -- DiffusionNSacersExNSa P2P
774+
-- <> localRootPeersNS
775+
-- <> publicRootPeersNS
776+
-- <> peerSelectionNS
777+
-- <> debugPeerSelectionNS
778+
-- <> debugPeerSelectionResponderNS
779+
-- <> peerSelectionCountersNS
780+
-- <> peerSelectionActionsNS
781+
-- <> connectionManagerNS
782+
-- <> connectionManagerNSansitionsNS
783+
-- <> serverNS
784+
-- <> inboundGovernorNS
785+
-- <> inboundGovernorNSansitionsNS
786+
-- <> localConnectionManagerNS
787+
-- <> localServerNS
788+
-- <> localInboundGovernorNS
789+
-- -- DiffusionNSacersExNSa nonP2P
790+
-- <> dtIpSubscriptionNS
791+
-- <> dtDnsSubscriptionNS
792+
-- <> dtDnsResolverNS
793+
-- <> dtErrorPolicyNS
794+
-- <> dtLocalErrorPolicyNS
795+
-- <> dtAcceptPolicyNS
796+
797+
798+
let bl = nodeInfoDpDoc
799+
<> nodeStartupInfoDpDoc
683800
<> stateTrDoc
684-
<> nodeStartupInfoTrDoc
685801
<> resourcesTrDoc
686802
<> startupTrDoc
687803
<> shutdownTrDoc

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ configureTracers cr config tracers = do
6464
T.traceWith
6565
tr
6666
(emptyLoggingContext
67-
{ lcNSInner = nsGetInner ns}
67+
{ lcNSInner = nsInner ns}
6868
, Left control))
6969
(allNamespaces :: [Namespace a])
7070

@@ -404,7 +404,7 @@ getLimiterSpec :: TraceConfig -> Namespace a -> Maybe (Text, Double)
404404
getLimiterSpec config ns = getOption limiterSelector config (nsGetComplete ns)
405405
where
406406
limiterSelector :: ConfigOption -> Maybe (Text, Double)
407-
limiterSelector (ConfLimiter f) = Just (intercalate "." (nsGetPrefix ns ++ nsGetInner ns), f)
407+
limiterSelector (ConfLimiter f) = Just (intercalate "." (nsPrefix ns ++ nsInner ns), f)
408408
limiterSelector _ = Nothing
409409

410410
-- | Searches in the config to find an option

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ module Cardano.Logging.DocuGenerator (
1717
, addFiltered
1818
, addLimiter
1919
, addSilent
20-
-- Convenience functions
21-
, showT
20+
2221
, addDocumentedNamespace
2322

2423
, DocuResult
@@ -41,14 +40,13 @@ import Cardano.Logging.Types
4140
import Control.Monad.IO.Class (MonadIO, liftIO)
4241
import qualified Control.Tracer as TR
4342

44-
import Cardano.Logging.Utils (showT)
4543
import Trace.Forward.Utils.DataPoint (DataPoint (..))
4644

4745
-- | Convenience function for adding a namespace prefix to a documented
4846
addDocumentedNamespace :: [Text] -> Documented a -> Documented a
49-
addDocumentedNamespace tl (Documented list) =
47+
addDocumentedNamespace out (Documented list) =
5048
Documented $ map
51-
(\ dm@DocMsg {} -> dm {dmNamespace = nsReplacePrefix (dmNamespace dm) tl})
49+
(\ dm@DocMsg {} -> dm {dmNamespace = nsReplacePrefix out (dmNamespace dm)})
5250
list
5351

5452
data DocuResult =
@@ -288,7 +286,7 @@ documentTracersRun tracers = do
288286
, ldPrivacyCoded = privacyFor ns Nothing
289287
, ldDetailsCoded = detailsFor ns Nothing
290288
}))
291-
TR.traceWith tr (emptyLoggingContext {lcNSInner = nsGetInner ns},
289+
TR.traceWith tr (emptyLoggingContext {lcNSInner = nsInner ns},
292290
Left (TCDocument idx dc)))
293291
nsIdx
294292

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ withInnerNames :: forall m a. (Monad m, MetaTrace a) => Trace m a -> Trace m a
139139
withInnerNames (Trace tr) = Trace $
140140
T.contramap
141141
(\case
142-
(lc, Right a) -> (lc {lcNSInner = nsGetInner (namespaceFor a)}, Right a)
142+
(lc, Right a) -> (lc {lcNSInner = nsInner (namespaceFor a)}, Right a)
143143
(lc, Left c) -> (lc, Left c))
144144
tr
145145

0 commit comments

Comments
 (0)