Skip to content

Comments

Add tracing integration#1282

Open
JoeyBF wants to merge 12 commits intorayon-rs:mainfrom
JoeyBF:tracing-integration
Open

Add tracing integration#1282
JoeyBF wants to merge 12 commits intorayon-rs:mainfrom
JoeyBF:tracing-integration

Conversation

@JoeyBF
Copy link
Contributor

@JoeyBF JoeyBF commented Feb 10, 2026

This PR adds optional support for the tracing crate, as mentioned in #915 (especially #915 (comment)).

Spans (INFO level):

  • rayon::worker_thread -- Wraps each worker thread's lifetime. Fields: worker, pool_id
  • rayon::job_execute -- Wraps each job execution. Fields: job_id, worker

Events (DEBUG level):

  • rayon::thread_idle -- Worker going idle
  • rayon::thread_active -- Worker waking up
  • rayon::job_injected -- Job injected into global queue. Fields: job_id, pool_id
  • rayon::job_stolen -- Job stolen from another thread. Fields: job_id, victim

Jobs capture the current span context when created. When executed (potentially on a different thread), they restore this context so job_execute spans appear as children of the span that spawned the work. This enables proper distributed tracing across thread boundaries.

Furthermore, all instrumentation compiles to no-ops when the feature is disabled, JobContext is zero-sized when tracing is off, and field values are computed inside macros to avoid overhead when filtered out.

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