Skip to content

feat(durablejobs,journaling): add tracing and batching metrics - #10151

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rebond/durablejobs-tracing-metrics
May 30, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rebond/durablejobs-tracing-metrics

Conversation

@ReubenBond

@ReubenBond ReubenBond commented May 29, 2026 •

Copy link
Copy Markdown
Member

Depends on #10150.

Adds distributed tracing and batching-effectiveness instrumentation for DurableJobs and journaling, including handler execution tracking and the receiver shared-dependency refactor.

This branch is stacked on #10150, so the PR diff is cumulative until earlier PRs land and this branch is rebased.

Microsoft Reviewers: Open in CodeFlow

Adds W3C-compatible distributed tracing across DurableJobs scheduling,
execution, handler invocation, and journaling persistence.

* Introduces the Microsoft.Orleans.DurableJobs ActivitySource plus
  orleans.durable_job.* / orleans.journal.* semantic-convention tag
  keys (in Orleans.Core.Abstractions), with InternalsVisibleTo wired
  to DurableJobs and Journaling.
* DurableJobsDiagnostics owns Producer/Consumer/Internal activity
  helpers (StartScheduleActivity, StartExecuteActivity,
  StartHandlerActivity, StartPersistBatchActivity,
  StartDeleteShardActivity) plus CaptureTraceContext /
  TryParseTraceContext.
* DurableJob and ScheduleJobRequest persist the schedule activity's
  W3C traceparent/tracestate; JobShard / JournaledJobShardState copy
  it onto the created DurableJob so the trace survives persistence.
  ShardExecutor.ExecuteJobAsync re-roots the execute span to the
  persisted context and tags completed/retried/failed/canceled.
* The DurableJobReceiverExtension wraps handler invocation in an
  Internal span so user grain code naturally inherits the same trace.
* JournaledJobShard captures Activity.Current.Context on every
  PendingOperation at enqueue time (exposed via IHasCapturedContext)
  and uses it as the parent (with the remaining distinct contexts as
  ActivityLinks, capped at 128) when starting the persist-batch and
  delete-shard spans.
* JournaledStateManager.WorkItem captures the calling activity's W3C
  id when an operation is enqueued and starts a journal {op} span on
  the Microsoft.Orleans.Storage ActivitySource using that captured
  parent / link set so each shard read/write/delete shows up as a
  child of the request that caused it.
* Adds an end-to-end DurableJobsTracingTests covering schedule/execute/
  handler/journal trace continuity, plus the IDurableJobGrain
  plumbing used to read back the handler's recorded TraceId.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ReubenBond
ReubenBond force-pushed the rebond/durablejobs-tracing-metrics branch from ff7dc80 to 2384800 Compare May 30, 2026 20:58
@ReubenBond
ReubenBond marked this pull request as ready for review May 30, 2026 21:05
@ReubenBond
ReubenBond enabled auto-merge May 30, 2026 21:05
@ReubenBond
ReubenBond requested a review from Copilot May 30, 2026 21:05
@ReubenBond
ReubenBond added this pull request to the merge queue May 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Merged via the queue into dotnet:main with commit 8bac831 May 30, 2026
62 checks passed
@ReubenBond
ReubenBond deleted the rebond/durablejobs-tracing-metrics branch May 30, 2026 21:51
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants