Skip to content

Tracing libraries#5251

Merged
coot merged 12 commits intomainfrom
fmaste/cardano-logging
Feb 13, 2026
Merged

Tracing libraries#5251
coot merged 12 commits intomainfrom
fmaste/cardano-logging

Conversation

@fmaste
Copy link
Contributor

@fmaste fmaste commented Nov 25, 2025

Move Tracing Instances to Ouroboros-Network

Summary

This PR moves the LogFormatting and MetaTrace instances from the cardano-node executable (specifically src/Cardano/Node/Tracing/Tracers/**) to the ouroboros-network package.

Architectural Changes

To handle dependencies correctly and keep components reusable, two new sub-libraries have been created in ouroboros-network.cabal:

  1. framework-tracing:

    • Contains instances related to lower-level components.
    • Depends only on the framework sub-library.
    • Note: Instances related to network-mux (from the network-mux package) are located here. This satisfies the requirement from network-mux maintainers to keep that package low-level and free of high-level tracing dependencies while providing the necessary instances for the framework.
  2. tracing:

    • Contains instances related to higher-level components (e.g., PeerSelection).
    • Depends on the ouroboros-network library (which in turn uses framework).

Motivation

  • Reuse: This move allows other projects based on the Ouroboros networking layer, such as dmq-node, to reuse these tracing instances without duplicating code. PR #32 is a work-in-progress updating dmq-node to depend on these new sub-libraries.
  • Decoupling: This refactor is a key step in decoupling the core networking code from cardano-diffusion.

Hierarchy Note

Most tracing modules ended up under the Ouroboros.Network.Tracing.PeerSelection hierarchy. This is a side effect of the migration strategy where one module was created per data type, reflecting the structure of the data types being traced.

Modifications & Cut Dependencies

The instances were modified to compile within ouroboros-network, necessitating the removal of dependencies on cardano-diffusion and ouroboros-consensus.

Specific items requiring attention or review:

  • Network.Mux.Tracing:
    • Removed references to ExnMempoolTimeout (from ouroboros-consensus) in impliesMempoolTimeoutHard. It now uses string matching (isPrefixOf) to identify these exceptions, avoiding a heavy dependency on the consensus layer.
    • New Implementation: Added explicit handling for constructors TraceNewMux and TraceStarting to ensure the instances are complete and compile against the current network-mux definitions.
  • PeerSelection.Governor.DebugPeerSelection:
    • Removed imports from cardano-diffusion.
    • Changed the LogFormatting instance for DebugPeerSelection to use generic types (extraState, extraFlags, etc.) instead of specific Cardano.* types.
    • Commented out specific counters (e.g., counters field in forMachine) that relied on cardanoPeerSelectionStatetoCounters.
  • PeerSelection.Governor.PeerSelectionCounters:
    • Generalized the LogFormatting instance to PeerSelectionCounters extraCounters.
    • Action Item: Commented out machine output fields for Bootstrap Peers (e.g., knownBootstrapPeers, activeBootstrapPeers) as they relied on Cardano.view* functions from cardano-diffusion.
  • PeerSelection.Governor.TracePeerSelection:
    • Removed TraceLedgerStateJudgementChanged and TraceUseBootstrapPeersChanged as they were ExtraTrace types imported from cardano-diffusion.
    • TraceTargetsChanged: A field present in cardano-node master might be missing here (see TODO in source).
    • Added extraTrace to the TracePeerSelection instance head to support the generic type.
    • New Implementation: Added explicit handling for the ExtraTrace constructor in LogFormatting and MetaTrace instances (namespaceFor, severityFor, etc.) to resolve non-exhaustive pattern match errors. This mirrors how Mux.TraceNewMux and Mux.TraceStarting are handled, ensuring the code compiles while acknowledging that the specific trace types are now generic.

Origin

Instances extracted from cardano-node "master" (2026-02-11, 85869e9dd21d9dac7c4381418346e97259c3303b)

Checklist

Quality

  • Commit sequence makes sense and have useful messages, see ref.
  • New tests are added and existing tests are updated.
  • Self-reviewed the PR.

Maintenance

  • Linked an issue or added the PR to the current sprint of ouroboros-network project.
  • Added labels.
  • Updated changelog files.
  • The documentation has been properly updated, see ref.

Copy link
Contributor

@crocodile-dentist crocodile-dentist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also my comments re network-mux in #5235 and whether to make it a separate library instead.

@fmaste fmaste force-pushed the fmaste/cardano-logging branch from 34b6cf0 to fa8c099 Compare January 27, 2026 13:16
@fmaste fmaste force-pushed the fmaste/cardano-logging branch 4 times, most recently from 3cd44fb to 2d19849 Compare January 29, 2026 00:14
@fmaste fmaste changed the base branch from main to coot/dmq-related-changes January 29, 2026 01:09
@coot coot force-pushed the fmaste/cardano-logging branch from 4564ef3 to a917998 Compare February 10, 2026 14:04
@fmaste fmaste changed the base branch from coot/dmq-related-changes to main February 10, 2026 14:04
@coot coot marked this pull request as ready for review February 10, 2026 14:05
@coot coot requested a review from a team as a code owner February 10, 2026 14:05
@coot coot force-pushed the fmaste/cardano-logging branch 3 times, most recently from 15a2043 to 75c72b3 Compare February 10, 2026 14:29
@fmaste fmaste force-pushed the fmaste/cardano-logging branch from 75c72b3 to 7395aa4 Compare February 10, 2026 15:45
@fmaste fmaste force-pushed the fmaste/cardano-logging branch 5 times, most recently from 78992cf to 4bc9879 Compare February 12, 2026 14:26
@fmaste fmaste changed the title cardano logging libraries Tracing libraries Feb 12, 2026
Includes network-mux instances in Network.Mux.Logging
@fmaste fmaste force-pushed the fmaste/cardano-logging branch from bd8770c to 333bfcf Compare February 12, 2026 17:36
… main

"Add behind firewall conf to prevent node from initiating connection to behind-firewall remote peer" (09f84dd)
…amework-tracing

- Directory Renames:
  - ouroboros-network/cardano-logging           -> ouroboros-network/tracing
  - ouroboros-network/framework/cardano-logging -> ouroboros-network/framework/tracing
- Modules & Files Refactoring:
  - ouroboros-network:framework-tracing: Remove the extra Framework hierarchy.
    - Network.Mux.Logging                       -> Network.Mux.Tracing
    - Ouroboros.Network.Logging.Framework.*     -> Ouroboros.Network.Tracing.*
  - ouroboros-network:tracing Move everything under PeerSelection.
    - Ouroboros.Network.Logging                 -> Ouroboros.Network.Tracing.PeerSelection
    - Ouroboros.Network.Logging.PeerSelection.* -> Ouroboros.Network.Tracing.PeerSelection.*
@fmaste fmaste force-pushed the fmaste/cardano-logging branch from 333bfcf to 8e5557f Compare February 12, 2026 18:36
Ran ./scripts/ci/run-stylish-haskell.sh and ./scripts/run-cabal-gild.sh
Fix for "Pattern match(es) are non-exhaustive"
Fix for "Pattern match(es) are non-exhaustive"
@fmaste fmaste force-pushed the fmaste/cardano-logging branch from 8e5557f to 61f97b0 Compare February 12, 2026 19:42
@coot coot added this pull request to the merge queue Feb 13, 2026
@coot coot added the tracing Issues / PRs related to tracing label Feb 13, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Feb 13, 2026
@coot coot added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit 16af3f5 Feb 13, 2026
12 checks passed
@coot coot deleted the fmaste/cardano-logging branch February 13, 2026 19:04
@github-project-automation github-project-automation bot moved this from In Progress to Done in Ouroboros Network Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tracing Issues / PRs related to tracing

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants