Skip to content

Isolate vendor-specific tracing from domain logic behind adapter boundaries #309

Description

@coderabbitai

Background

Raised during review of PR #303 by @leynos.

Domain functions in src/wrap/inline/ and src/wrap/tokenize/ currently import and use the vendor-specific tracing framework directly (#[tracing::instrument], debug!, trace!, tracing::enabled!). This couples infrastructure concerns to domain logic, making the domain harder to test without a tracing subscriber and harder to migrate to a different observability backend in the future.

Required work

  1. Define domain-level event types — e.g. enum ClassificationEvent — that capture the observable outcomes of classification and parsing decisions without referencing any external crate.
  2. Refactor classification functions (classify_fragment_kind, parse_link_or_image, find_footnote_end, the footnote predicate helpers) to accept an optional observer (e.g. a callback or a trait object implementing an Observer trait) and emit domain events through it, rather than emitting tracing calls inline.
  3. Implement a tracing-backed adapter that translates ClassificationEvent values into the appropriate debug!/trace! calls. Wire this adapter at the library boundary so existing instrumented behaviour is preserved.
  4. Remove direct tracing imports from all domain modules; retain the dependency only in the adapter layer and in [dev-dependencies] for tests.

Acceptance criteria

  • No use tracing:: import appears inside domain modules (src/wrap/inline/, src/wrap/tokenize/).
  • Domain functions can be called without any tracing subscriber installed and without any enabled! guard (all guards move to the adapter).
  • Existing traced-event tests continue to pass via the adapter.
  • Linters and tests pass under make test.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions