Skip to content

fix: record latency before ret/err events#2

Merged
pruthvikar merged 3 commits intomasterfrom
fix/latency-before-events
Mar 16, 2026
Merged

fix: record latency before ret/err events#2
pruthvikar merged 3 commits intomasterfrom
fix/latency-before-events

Conversation

@pruthvikar
Copy link
Member

What

  • Record the latency span field before ret/err events fire, not after

Why

The latency flag was recording elapsed time on the span after ret/err events had already emitted their log lines. This meant those events always showed latency = Empty — breaking Datadog log ingestion.

The previous TraceLatency approach used Drop on a local variable inside the async block, which naturally dropped before events fired. The fork's macro expansion moved recording to after the events, silently breaking the pipeline.

How

Async case: Move latency_inst and latency_record inside each mk_fut variant so latency records after #block.await completes but before ret/err events.

Sync case: Split block evaluation from the match expression, inserting latency_record between them.

Testing

  • cargo check -p tracing-attributes passes
  • Verified against engine-rust full workspace build (makers clippy -p traits_derive)

🤖 Generated with Claude Code

@pruthvikar pruthvikar force-pushed the fix/latency-before-events branch 2 times, most recently from 0842747 to c5edd69 Compare March 16, 2026 16:35
The latency field was recorded AFTER ret/err events fired, so the
events' log output always showed latency as Empty. This broke the
previous TraceLatency Drop-based approach where the timer dropped
(recording latency) inside the block before events fired.

Move latency_inst and latency_record into each mk_fut variant so
that latency is recorded after the block completes but before any
ret/err events emit their log lines.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pruthvikar pruthvikar force-pushed the fix/latency-before-events branch from c5edd69 to b1db5d6 Compare March 16, 2026 17:06
pruthvikar and others added 2 commits March 16, 2026 17:28
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Box `matchers::BuildError` in closure to fix `result_large_err`
- Use `self.cmp(other)` in `PartialOrd` impls for `MatchPattern` and
  `MatchDebug` to fix `non_canonical_partial_ord_impl`

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pruthvikar pruthvikar merged commit 0805330 into master Mar 16, 2026
44 of 53 checks passed
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