Skip to content

Verbose tracing emits marten.append.event on every append route (#5772) - #5782

Merged
jeremydmiller merged 1 commit into
masterfrom
gh-5772-verbose-append-tracing
Oct 28, 2026
Merged

jeremydmiller merged 1 commit into
masterfrom
gh-5772-verbose-append-tracing

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Closes #5772.

Problem

With TrackConnections = TrackLevel.Verbose, EventTracingConnectionLifetime.writeVerboseEvents emitted marten.append.event only for operations deriving from Weasel.Storage.AppendEventOperationBase. Both Quick routes fell through, and their Role() is Events, so the fallback branch skipped them too:

  • The bulk route. QuickAppendEventsOperationBase handles one mt_quick_append_events call per stream. Under QuickWithServerTimestamps, the V9 default, nearly every append and StartStream goes through it.
  • The per-event Quick route that reads its sequence back. This is weasel#747, live since Read back the seq_id a per-event Start draws, so a failed batch tombstones it (#5454 follow-up) #5755 merged. QuickAppendEventWithVersionReadingSequenceOperation is internal to Weasel and implements IStorageOperation directly. It is what a Quick-mode StartStream uses (and the daemon's side-effect appends).

Fix

  • The tracer handles three cases:
    • AppendEventOperationBase: one event, as before.
    • QuickAppendEventsOperationBase: one event per event in its StreamAction.
    • The new TracedQuickAppendEventOperation: one event.
  • TracedQuickAppendEventOperation is a Marten wrapper around Weasel's per-event Quick operation that exposes Event / Stream. ClosedShapeEventDocumentStorage.QuickAppendEventWithVersion wraps only when TrackConnections == Verbose (fixed at store construction), and only an operation that is neither an AppendEventOperationBase nor a NoDataReturnedCall. Below Verbose nothing is wrapped and nothing changes. The wrapper forwards ConfigureCommand, PostprocessAsync (so the seq_id read-back still happens), Role, DocumentType, TryTransform and ToString. Like the wrapped operation, it is not a NoDataReturnedCall.

The cleaner long-term shape is a public interface in Weasel for per-event append operations, which the tracer could check instead of the wrapper. That needs a Weasel release, so this PR doesn't wait on it.

Tests

CoreTests/Bugs/Bug_5772_verbose_tracing_of_quick_appends captures the marten.connection activity under Verbose. It asserts exactly one marten.append.event per appended event, in order, across Rich, Quick and QuickWithServerTimestamps, for both StartStream and Append. The Quick StartStream case also asserts every event's Sequence was still read back through the wrapper.

Rich Quick QuickWithServerTimestamps
master green red (Start + Append) red (Start + Append)
tracer change only, no wrapper green red (Start only) green
this PR green green green

Run locally on net10.0 / PG17: Bug_5772*, EventTracingConnectionLifetimeTests, marten_activity_parenting and Bug_3911*, 30/30 pass.

Not covered by a test: the daemon side-effect append path, which uses the same QuickAppendEventWithVersion and so gets the same wrapping.

No public API change.

🤖 Generated with Claude Code

With TrackConnections = Verbose, marten.append.event was emitted only for
an operation deriving from Weasel.Storage.AppendEventOperationBase, which
only Rich mode's per-event appends are. Neither Quick route was traced:

- the bulk mt_quick_append_events operation (QuickAppendEventsOperationBase),
  which carries a whole stream and is the V9 default's route for almost
  every append. The tracer now emits one event per event in its stream.
- the per-event Quick append that reads its seq_id back (weasel#747, since
  #5755), used by a Quick-mode StartStream. Weasel's type is internal and
  not an AppendEventOperationBase, so under Verbose tracing Marten now
  wraps it in TracedQuickAppendEventOperation, which exposes the event.
  Nothing is wrapped below Verbose.

Closes #5772

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremydmiller
jeremydmiller merged commit fe22faf into master Oct 28, 2026
32 checks passed
@jeremydmiller
jeremydmiller deleted the gh-5772-verbose-append-tracing branch October 28, 2026 21:10
This was referenced Oct 29, 2026
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.

Verbose OpenTelemetry tracing skips marten.append.event for Quick-mode appends

1 participant