Skip to content

feat(tracing): propagate log topic across spawns and label components - #669

Open
varex83agent wants to merge 1 commit into
mainfrom
feat/fix-588
Open

feat(tracing): propagate log topic across spawns and label components#669
varex83agent wants to merge 1 commit into
mainfrom
feat/fix-588

Conversation

@varex83agent

Copy link
Copy Markdown
Collaborator

Summary

MetricsLayer labels app_log_warn_total / app_log_error_total with a topic taken from the nearest enclosing span, falling back to "". Because tracing span context does not cross tokio::spawn, and pluto set the topic field in only two places (health, stacksnipe), effectively every other warn/error landed under topic="".

This PR restores charon-like topic attribution:

  1. Span-propagating spawn helperpluto_tracing::spawn(fut) wraps the future with fut.instrument(Span::current()), so a subtask inherits the topic of the code that spawned it. Use it in place of tokio::spawn inside long-running components. Two unit tests assert the helper propagates the topic while a bare tokio::spawn does not.

  2. Root topic span per long-running component — each component's entry point now carries a &'static str topic (keeping the label bounded), reusing charon's names.

Topics / components covered

topic pluto site
sched core/scheduler.rs actor run
tracker core/tracker/mod.rs actor run
sigagg core/sigagg.rs aggregate
bcast core/bcast/mod.rs broadcast, core/bcast/recast.rs slot_ticked
parsigex parsigex/behaviour.rs enqueue + notify_subscribers spawn
vapi core/validatorapi/router.rs per-request middleware
qbft consensus/qbft/runner.rs propose/participate/run_instance, component.rs cleanup spawn
p2p p2p/p2p.rs handle_event
relay cli/commands/relay.rs run, p2p/bootnode.rs relay-resolver spawn, relay-server/web.rs resolver spawn
peerinfo peerinfo/protocol.rs send_peer_info / recv_peer_info
dkg dkg/dkg.rs run (+ network-driver spawn via helper)
vmock testutil/validatormock/component.rs slot_ticked / run_scheduler
app-start app/node/mod.rs run (catch-all, mirrors charon's app.Run)

Pre-existing health and stacksnipe topics are unchanged.

Notes / deferred

  • The DB actors (dutydb / parsigdb / aggsigdb) and the fetcher have no distinct charon topic; they fall under app-start, matching charon.
  • The scheduler's subscribe_slot/subscribe_duty supervision loops run user callbacks belonging to other components, so they are intentionally left unlabelled at the loop level to avoid mislabelling callback errors under sched (the callbacks carry their own component topics).
  • infosync has no charon topic mapping and was left as-is.

Quality gates

  • cargo +nightly fmt --all — clean
  • cargo clippy --workspace --all-targets --all-features -- -D warnings — clean
  • cargo test --workspace --all-features — pass (incl. the two new spawn-propagation tests)

Closes #588

🤖 Generated with Claude Code

)

`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>
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.

Log topics: app_log_{warn,error}_total is unlabelled across almost all of pluto

1 participant