Skip to content

Commit

Permalink
Merge #3867
Browse files Browse the repository at this point in the history
3867: tracing: change of configuration structure r=jutaro a=jutaro



Co-authored-by: Yupanqui <jnf@arcor.de>
  • Loading branch information
iohk-bors[bot] and jutaro committed May 17, 2022
2 parents 91a11ba + ba5ba32 commit 1ae1ed0
Show file tree
Hide file tree
Showing 12 changed files with 240 additions and 314 deletions.
5 changes: 3 additions & 2 deletions cardano-node/src/Cardano/Node/Tracing/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import qualified Data.Map as Map
import Data.Maybe (fromMaybe)
import Data.Time.Clock (getCurrentTime)


import System.Metrics as EKG

import Network.Mux.Trace (TraceLabelPeer (..))
Expand Down Expand Up @@ -57,7 +58,7 @@ initTraceDispatcher ::
-> IO (Tracers RemoteConnectionId LocalConnectionId blk p2p)
initTraceDispatcher nc p networkMagic nodeKernel p2pMode = do
trConfig <- readConfiguration (unConfigPath $ ncConfigFile nc)
-- trace ("TraceConfig " <> show trConfig) $ pure ()
putStrLn $ "New tracer configuration: " <> show trConfig

tracers <- mkTracers trConfig

Expand Down Expand Up @@ -112,5 +113,5 @@ initTraceDispatcher nc p networkMagic nodeKernel p2pMode = do
forwarderBackendEnabled =
any checkForwarder . concat . Map.elems $ tcOptions trConfig

checkForwarder (ConfBackend backends) = Forwarder `elem` backends
checkForwarder (ConfBackend backends') = Forwarder `elem` backends'
checkForwarder _ = False
74 changes: 28 additions & 46 deletions configuration/cardano/mainnet-config-new-tracing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,80 +44,62 @@ TurnOnLogging: True
# Use old tracing as standard for now
UseTraceDispatcher: True


TraceOptionSeverity:
# Show messages of Severity Notice or higher as default
- ns: ""
TraceOptions:
Node:
severity: Notice
detail: DNormal
backends:
- Stdout MachineFormat
- EKGBackend
- Forwarder

# But modify severity for the following namespaces
- ns: Node.ChainDB
Node.ChainDB:
severity: Info

- ns: Node.AcceptPolicy
Node.AcceptPolicy:
severity: Info

- ns: Node.DNSResolver
Node.DNSResolver:
severity: Info

- ns: Node.DNSSubscription
Node.DNSSubscription:
severity: Info

- ns: Node.DiffusionInit
Node.DiffusionInit:
severity: Info

- ns: Node.ErrorPolicy
Node.ErrorPolicy:
severity: Info

- ns: Node.Forge
Node.Forge:
severity: Info

- ns: Node.IpSubscription
Node.IpSubscription:
severity: Info

- ns: Node.LocalErrorPolicy
Node.LocalErrorPolicy:
severity: Info

- ns: Node.Mempool
Node.Mempool:
severity: Info

- ns: Node.Resources
Node.Resources:
severity: Info

TraceOptionDetail:
# All messages are shown with normal detail level
- ns: ""
detail: DNormal

TraceOptionBackend:
# Use these backends
- ns: ""
backends:
- Stdout MachineFormat
- EKGBackend
# - Forwarder

# Limit the frequency of the following messages
TraceOptionLimiter:
- ns: Node.ChainDB.AddBlockEvent.AddedBlockToQueue
limiterName: AddedBlockToQueueLimiter
limiterFrequency: 2.0
Node.ChainDB.AddBlockEvent.AddedBlockToQueue:
maxFrequency: 2.0

- ns: Node.ChainDB.AddBlockEvent.AddedBlockToVolatileDB
limiterName: AddedBlockToVolatileDBLimiter
limiterFrequency: 2.0
Node.ChainDB.AddBlockEvent.AddedBlockToVolatileDB:
maxFrequency: 2.0

- ns: Node.ChainDB.CopyToImmutableDBEvent.CopiedBlockToImmutableDB
limiterName: CopiedBlockToImmutableDBLimiter
limiterFrequency: 2.0
Node.ChainDB.CopyToImmutableDBEvent.CopiedBlockToImmutableDB:
maxFrequency: 2.0

- ns: Node.ChainDB.AddBlockEvent.AddBlockValidation.ValidCandidate
limiterName: ValidCandidateLimiter
limiterFrequency: 2.0
Node.ChainDB.AddBlockEvent.AddBlockValidation.ValidCandidate:
maxFrequency: 2.0

- ns: Node.BlockFetchClient.CompletedBlockFetch
limiterName: CompletedBlockFetchLimiter
limiterFrequency: 2.0
Node.BlockFetchClient.CompletedBlockFetch:
maxFrequency: 2.0

# Options for the trace forwarder
TraceOptionForwarder:
Expand Down
98 changes: 37 additions & 61 deletions configuration/cardano/membench-config-new.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,110 +45,87 @@ TurnOnLogging: True
# Use old tracing as standard for now
UseTraceDispatcher: True


TraceOptionSeverity:
# Show messages of Severity Notice or higher as default
- ns: ""
TraceOptions:
Node:
severity: Silence
detail: DNormal
backends:
- Stdout MachineFormat
- EKGBackend
- Forwarder

# But modify severity for the following namespaces
- ns: Node.ChainDB
severity: Info
Node.ChainDB:
severity: Info

- ns: Node.ChainDB.AddBlockEvent.AddBlockValidation.ValidCandidate
Node.ChainDB.AddBlockEvent.AddBlockValidation.ValidCandidate:
severity: Silence

- ns: Node.ChainDB.InitChainSelEvent.UpdateLedgerDb
Node.ChainDB.InitChainSelEvent.UpdateLedgerDb:
severity: Silence

- ns: Node.ConnectionManager
severity: Info

- ns: Node.AcceptPolicy
Node.ConnectionManager:
severity: Info

- ns: Node.DNSResolver
Node.AcceptPolicy:
severity: Info

- ns: Node.DNSSubscription
Node.DNSResolver:
severity: Info

- ns: Node.DiffusionInit
Node.DNSSubscription:
severity: Info

- ns: Node.ErrorPolicy
Node.DiffusionInit:
severity: Info

- ns: Node.Forge
Node.ErrorPolicy:
severity: Info

- ns: Node.InboundGovernor
Node.Forge:
severity: Info

- ns: Node.IpSubscription
Node.InboundGovernor:
severity: Info

- ns: Node.IpSubscription
Node.IpSubscription:
severity: Info

- ns: Node.LedgerPeers
Node.LedgerPeers:
severity: Info

- ns: Node.LocalErrorPolicy
Node.LocalErrorPolicy:
severity: Info

- ns: Node.LocalRootPeers
Node.LocalRootPeers:
severity: Info

- ns: Node.Mempool
Node.Mempool:
severity: Info

- ns: Node.PeerSelection
Node.PeerSelection:
severity: Info

- ns: Node.PeerSelectionActions
Node.PeerSelectionActions:
severity: Info

- ns: Node.PublicRootPeers
Node.PublicRootPeers:
severity: Info

- ns: Node.Resources
severity: Silence

TraceOptionDetail:
# All messages are shown with normal detail level
- ns: ""
detail: DNormal
Node.ChainDB.AddBlockEvent.AddedBlockToQueue:
maxFrequency: 2.0

TraceOptionBackend:
# Use these backends
- ns: ""
backends:
- Stdout MachineFormat
- EKGBackend
- Forwarder

# Limit the frequency of the following messages
TraceOptionLimiter:
- ns: Node.ChainDB.AddBlockEvent.AddedBlockToQueue
limiterName: AddedBlockToQueueLimiter
limiterFrequency: 2.0
Node.ChainDB.AddBlockEvent.AddedBlockToVolatileDB:
maxFrequency: 2.0

- ns: Node.ChainDB.AddBlockEvent.AddedBlockToVolatileDB
limiterName: AddedBlockToVolatileDBLimiter
limiterFrequency: 2.0
Node.ChainDB.CopyToImmutableDBEvent.CopiedBlockToImmutableDB:
maxFrequency: 2.0

- ns: Node.ChainDB.CopyToImmutableDBEvent.CopiedBlockToImmutableDB
limiterName: CopiedBlockToImmutableDBLimiter
limiterFrequency: 2.0
Node.ChainDB.AddBlockEvent.AddBlockValidation.ValidCandidate:
maxFrequency: 2.0

- ns: Node.ChainDB.AddBlockEvent.AddBlockValidation.ValidCandidate
limiterName: ValidCandidateLimiter
limiterFrequency: 2.0

- ns: Node.BlockFetchClient.CompletedBlockFetch
limiterName: CompletedBlockFetchLimiter
limiterFrequency: 2.0
Node.BlockFetchClient.CompletedBlockFetch:
maxFrequency: 2.0

# Options for the trace forwarder
TraceOptionForwarder:
Expand All @@ -160,7 +137,6 @@ TraceOptionPeerFreqency: 2000

TraceOptionResourceFreqency: 5000


##### Stubs for legacy logging config #####

TurnOnLogMetrics: False
Expand Down
31 changes: 16 additions & 15 deletions doc/New Tracing Quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ advice to use namespaces for any analysis tools of traces!
1. Specify a filter for the severity of the messages you want to see, e.g.:

~~~yaml
TraceOptionSeverity:
# Show messages of Severity Notice or higher as default
- ns: ""
# Show messages of Severity Notice or higher as default
Node:
severity: Notice

# But show ChainDB messages starting from Info
- ns: Node.ChainDB
Node.ChainDB:
severity: Info
~~~

Expand All @@ -48,9 +47,10 @@ advice to use namespaces for any analysis tools of traces!
2. Specify in which detail level, the messages get shown.

~~~yaml
TraceOptionDetail:
# All messages are shown with normal detail level
- ns: ""
Node:
# Keep this
severity: Notice
# All messages are shown with normal detail level
detail: DNormal
~~~

Expand All @@ -62,21 +62,22 @@ advice to use namespaces for any analysis tools of traces!
frequency in which messages get shown.

~~~yaml
TraceOptionLimiter:
# Only show a maximum of 2 of these messages per second
- ns: Node.ChainDB.AddBlockEvent.AddedBlockToQueue
limiterName: AddedBlockToQueueLimiter
limiterFrequency: 2.0
Node.ChainDB.AddBlockEvent.AddedBlockToQueue:
# Only show a maximum of 2 of these messages per second
maxFrequency: 2.0
~~~

The activity of limiters will be written in the traces as well.

4. Specify the backends the messages are routed to.

~~~yaml
TraceOptionBackend:
# Use these backends
- ns: ""
Node:
# Keep this
severity: Notice
# And this
detail: DNormal
# And specify a list of backends to use
backends:
- Stdout MachineFormat
- EKGBackend
Expand Down
21 changes: 7 additions & 14 deletions trace-dispatcher/doc/trace-dispatcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -524,41 +524,34 @@ If the configuration file is in Yaml format, the following entry means, that by
all messages with Info or higher Priority are shown:

```yaml
TraceOptionSeverity:
- ns: ''
severity: Info
```

But if you want to see Debug messages of the ChainDB tracer, then add:

```yaml
TraceOptionSeverity:
- ns: ''
Node:
severity: Info
- ns: Node.ChainDB
Node.ChainDB:
severity: Debug
```

And if you never want to see any message of the AcceptPolicy tracer, then add:

```yaml
TraceOptionSeverity:
- ns: ''
Node:
severity: Info
- ns: Node.ChainDB
Node.ChainDB:
severity: Debug
- ns: Node.AcceptPolicy
Node.AcceptPolicy:
severity: SilentF
```

As another example, if you don't want to see more then 1 BlockFetchClient
message per second, then add this to your configuration file:

```yaml
TraceOptionLimiter:
- ns: Node.BlockFetchClient
limiterName: BlockFetchLimiter
limiterFrequency: 1.0
Node.BlockFetchClient:
maxFrequency: 1.0
```

## Documentation
Expand Down

0 comments on commit 1ae1ed0

Please sign in to comment.