Skip to content

Introduce trace-dispatcher-api and restructure the package split#16

Draft
jutaro wants to merge 5 commits into
masterfrom
jutaro/trace-dispatcher-api
Draft

Introduce trace-dispatcher-api and restructure the package split#16
jutaro wants to merge 5 commits into
masterfrom
jutaro/trace-dispatcher-api

Conversation

@jutaro

@jutaro jutaro commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary
Extracts a new thin package trace-dispatcher-api from trace-dispatcher, then refines its internal structure so each module has a single, well-named responsibility.

Motivation
Previously all tracing types and combinators lived inside trace-dispatcher. Any package that only needed to instrument its own code — define LogFormatting/MetaTrace instances and call traceWith — was forced to depend on the full backend stack (EKG, Prometheus, CBOR forwarding, async, YAML config parser, …). The split makes the stable API surface available as a lightweight dependency.

Changes
New package: trace-dispatcher-api
Contains only what a package needs to define trace types and emit messages:

Cardano.Logging.Types — the Trace carrier, TraceControl GADT, LogFormatting/MetaTrace typeclasses, and the full TraceConfig/BackendConfig dependency chain (required because TraceControl embeds it in-band).
Cardano.Logging.Trace — filtering and per-message annotation combinators (filterTraceBySeverity, setSeverity, withPrivacy, withNames, …).
Cardano.Logging.API — a single-import front door re-exporting both modules, with a module haddock that explains when to use this package versus trace-dispatcher.
Build-depends for trace-dispatcher-api is kept deliberately small: no async, bytestring, cborg-json, time, or YAML.

trace-dispatcher-api split into 7 focused modules
The two original large files (Types.hs at 568 lines, Trace.hs at 389 lines) were further divided along natural seams:

Module Contents
Cardano.Logging.Types.Annotations SeverityS/F, Privacy, DetailLevel, Metric, Namespace, LoggingContext
Cardano.Logging.Types.Config BackendConfig, TraceConfig, ForwarderAddr/Mode, Verbosity, PrometheusSimpleRun
Cardano.Logging.Types.Doc ConfigReflection, DocCollector, LogDoc
Cardano.Logging.Types (hub) Trace, TraceControl, LogFormatting, MetaTrace, Folding + re-exports
Cardano.Logging.Trace.Combinators traceWith, contramapM, foldTraceM, routingTrace, contramap'
Cardano.Logging.Trace (hub) filter*, set/with severity/privacy/detail/names + re-export Combinators
Cardano.Logging.API front-door re-export of Types + Trace
The dependency graph is a strict DAG with no cycles: Annotations → Config → Doc → Types → Combinators → Trace → API.

trace-dispatcher tightened
FormattedMessage/TraceObject/PreFormatted moved from the API into Cardano.Logging.Formatter.
HowToConnect/Host/Port moved into Cardano.Logging.Tracer.Forward.
Utils, Types.NodeInfo, Types.NodeStartupInfo, Types.TraceMessage moved from the API into trace-dispatcher.
Cardano.Logging (the mega-module) gains a three-step usage haddock and no longer re-exports FrequencyLimiter or TraceDispatcherMessage as public API.
Compatibility
All changes are additive from the perspective of existing consumers of trace-dispatcher: import Cardano.Logging continues to export the same surface. The new sub-modules are opt-in additional import targets.

jutaro added 3 commits June 19, 2026 15:30
The trace-dispatcher-api / trace-dispatcher split was too coarse: output types
(FormattedMessage, TraceObject, PreFormatted), the forwarder connection type
(HowToConnect/Host/Port), and several utility/domain modules lived in the API
package despite having no business being there — they pulled in bytestring, async,
cborg-json, and time as transitive API dependencies.

Moved to trace-dispatcher:

FormattedMessage, TraceObject, PreFormatted → Cardano.Logging.Formatter
HowToConnect, Host, Port → Cardano.Logging.Tracer.Forward
Cardano.Logging.Utils, Types.NodeInfo, Types.NodeStartupInfo, Types.TraceMessage
trace-dispatcher-api now exposes exactly two modules (Cardano.Logging.Types,
Cardano.Logging.Trace) covering the Trace newtype, the LogFormatting/MetaTrace
typeclasses, core combinators, and the TraceControl dependency chain. Removed four
no-longer-needed build-depends (async, bytestring, cborg-json, time).

New Cardano.Logging.API is added as the single-import front door for the package,
re-exporting both modules with a module haddock that explains the two-tier role and
guides users toward Cardano.Logging (from trace-dispatcher) when they need the
full backend stack.

Cardano.Logging (the trace-dispatcher mega-module) gains a three-step usage
haddock and no longer re-exports FrequencyLimiter or TraceDispatcherMessage, which
are internal implementation details.
@jutaro jutaro force-pushed the jutaro/trace-dispatcher-api branch from e5fd150 to a4d50d8 Compare June 19, 2026 13:32
jutaro added 2 commits June 22, 2026 11:25
Removed references to hermod-trace-resources
limitFrequency => maxFrequency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant