feat(tracing): propagate log topic across spawns and label components - #669
Open
varex83agent wants to merge 1 commit into
Open
feat(tracing): propagate log topic across spawns and label components#669varex83agent wants to merge 1 commit into
varex83agent wants to merge 1 commit into
Conversation
) `MetricsLayer` labels `app_log_{warn,error}_total` with the `topic` field from the nearest enclosing span. Span context is not carried across `tokio::spawn`, and pluto set the `topic` field in only two places, so almost every warn/error was counted under `topic=""`. Add a span-propagating spawn helper (`pluto_tracing::spawn`) that attaches `Span::current()` to the spawned future, restoring context-like topic propagation, and set a `&'static str` `topic` root span on each long-running component, reusing charon's topic names: - sched, tracker, sigagg, bcast (+recast), parsigex, vapi, qbft, p2p, peerinfo, dkg, relay, vmock, and app-start as the catch-all. Adds tests asserting the helper propagates the topic across the task boundary while a bare `tokio::spawn` does not. Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
varex83agent
force-pushed
the
feat/fix-588
branch
from
August 25, 2026 15:10
6782d5d to
7836e72
Compare
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
MetricsLayerlabelsapp_log_warn_total/app_log_error_totalwith atopictaken from the nearest enclosing span, falling back to"". Because tracing span context does not crosstokio::spawn, and pluto set thetopicfield in only two places (health,stacksnipe), effectively every other warn/error landed undertopic="".This PR restores charon-like topic attribution:
Span-propagating spawn helper —
pluto_tracing::spawn(fut)wraps the future withfut.instrument(Span::current()), so a subtask inherits the topic of the code that spawned it. Use it in place oftokio::spawninside long-running components. Two unit tests assert the helper propagates the topic while a baretokio::spawndoes not.Root
topicspan per long-running component — each component's entry point now carries a&'static strtopic(keeping the label bounded), reusing charon's names.Topics / components covered
schedcore/scheduler.rsactorruntrackercore/tracker/mod.rsactorrunsigaggcore/sigagg.rsaggregatebcastcore/bcast/mod.rsbroadcast,core/bcast/recast.rsslot_tickedparsigexparsigex/behaviour.rsenqueue+notify_subscribersspawnvapicore/validatorapi/router.rsper-request middlewareqbftconsensus/qbft/runner.rspropose/participate/run_instance,component.rscleanup spawnp2pp2p/p2p.rshandle_eventrelaycli/commands/relay.rsrun,p2p/bootnode.rsrelay-resolver spawn,relay-server/web.rsresolver spawnpeerinfopeerinfo/protocol.rssend_peer_info/recv_peer_infodkgdkg/dkg.rsrun(+ network-driver spawn via helper)vmocktestutil/validatormock/component.rsslot_ticked/run_schedulerapp-startapp/node/mod.rsrun(catch-all, mirrors charon'sapp.Run)Pre-existing
healthandstacksnipetopics are unchanged.Notes / deferred
app-start, matching charon.subscribe_slot/subscribe_dutysupervision loops run user callbacks belonging to other components, so they are intentionally left unlabelled at the loop level to avoid mislabelling callback errors undersched(the callbacks carry their own component topics).infosynchas no charon topic mapping and was left as-is.Quality gates
cargo +nightly fmt --all— cleancargo clippy --workspace --all-targets --all-features -- -D warnings— cleancargo test --workspace --all-features— pass (incl. the two new spawn-propagation tests)Closes #588
🤖 Generated with Claude Code