refactor: carry Arc<TracingInfo> on WriteItem; drop WriteTask service_name#46
Merged
Conversation
HandlerCtx.tracing becomes Arc<TracingInfo> so the same tracing state can be shared with WriteItems without repeated cloning. HandlerCtx::new callers (axum and pubsub) now pass Arc<TracingInfo>. HandlerCtx::tracing_info, HandlerCtx::service_name, and HandlerArgs::service_name lose their `const` qualifier because Arc deref is not `const` on stable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
WriteItem, NotifyPermit, and OwnedNotifyPermit now carry Arc<TracingInfo> in place of tracing::Span. WriteTask::task_future reads the service label and request span off the shared TracingInfo, so the service_name field threaded through in #45 is no longer needed and has been removed from WriteTask. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Relocate WriteItem from src/pubsub/shared.rs (pubsub-gated) to
src/routes/ctx.rs so it is visible without the pubsub feature, and
gate the two notification methods that depend on tokio_stream
(HandlerCtx::notify_stream, HandlerCtx::spawn_notify_stream) behind
#[cfg(feature = "pubsub")]. The other notification APIs (notify,
permit*) remain unconditional; without pubsub they are harmless
no-ops.
Additional #[cfg] gates to silence dead-code / unused-import lints
exposed now that the lib actually compiles without features:
- message_event! macro + record_message_size + message_size behind
any(axum, pubsub)
- metrics::{histogram, Histogram} imports behind any(axum, pubsub)
- HandlerCtx::new gets allow(dead_code) when both axum and pubsub
are off (nothing can construct a HandlerCtx)
- WriteItem struct gets allow(dead_code) without pubsub (no reader)
Replace two intra-doc links whose targets are feature-gated
(pubsub::AxumWsCfg, pubsub::ajj_websocket in lib.rs; axum in
handler.rs) with inline code so rustdoc --no-default-features no
longer fails link resolution.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Arc<TracingInfo> on WriteItem; drop WriteTask service_name
Evalir
approved these changes
Apr 22, 2026
Member
Evalir
left a comment
There was a problem hiding this comment.
claude only had unuseful nits and i had none, lgtm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
service_name: &'static strthreading that PR chore: downgrade per-message log to trace #45 added toWriteTask. The write task now reads the service label and per-request span off anArc<TracingInfo>carried on eachWriteItem, so theajj.router.message_size_byteshistogram is still emitted with the correctservicelabel.HandlerCtx.tracingbecomesArc<TracingInfo>.WriteItem,NotifyPermit, andOwnedNotifyPermitcarryArc<TracingInfo>in place of a baretracing::Span. Permit-based sends move theArcinto theWriteItem;HandlerCtx::notifyand the response path doArc::clone(refcount bump — parity with the priorSpan::clone).--no-default-featuresbuild breakage unrelated to this refactor but exposed once things were being touched: relocatesWriteItemtoroutes/ctx.rs, gatestokio_stream-using methods behindpubsub, and adds#[cfg]gates / intra-doc link fixes to silence dead-code / broken-link diagnostics.Minor breaking change
Three
pub const fnmethods lose theirconstqualifier becauseArcderef is not available in const contexts on stable:HandlerCtx::tracing_infoHandlerCtx::service_nameHandlerArgs::service_nameSignatures are otherwise unchanged. Warrants a minor-version bump on the next release.
Commits
003db71— exposeTracingInfo::request_spanto cratef227836— storeTracingInfoinArconHandlerCtx2e4eb6c— carryArc<TracingInfo>onWriteItem; dropWriteTaskservice_name6bedcfc— make--no-default-featuresbuild cleanEach commit compiles independently (bisect-safe).
Test plan
cargo +nightly fmt -- --checkcargo clippy -p ajj --all-features --all-targets -- -D warningscargo clippy -p ajj --all-features --lib -- -D warningscargo clippy -p ajj --no-default-features --all-targets -- -D warningscargo clippy -p ajj --no-default-features --lib -- -D warningscargo t -p ajj --all-features(48 tests pass)RUSTDOCFLAGS="-D warnings" cargo doc -p ajj --no-deps(default,--all-features, and--no-default-featuresall clean)🤖 Generated with Claude Code