Support distributed tracing for Orleans Reminders
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 14h 42m
- Merged PRs (30d)
- 354
Description
Would be cool if Orleans reminders will support `System.Diagnostics.Activity.Current.Id` is used to track the activity in distributed tracing.
It will flow from registration time and then to execution time. I did it manually with DAPR Actor reminders. It must be just one more string correlation id implicitly parameter in scheduler database.
Probably makes sense, initially, to make this feature disabled by default to avoid breaking changes but let Orleans Reminder config to enable it explicitly.
I may show sample.
Implementation may be simple take current activity Id and put it into state store
``` fsharp
SystemDiagnosticsActivityId =
match System.Diagnostics.Activity.Current with
| null -> "" // special case when activity is turned off
| activity -> activity.Id |> defaultIfNull "" // special case when activity id is null
```
During reminder execution activity must be
``` fsharp
let activityImpersonated (systemDiagnosticsActivityId: string) (action: unit -> Task<'TResult>) = task {
use activityOriginal =
// external thread acvivity will record that it is going to start new activity from another distributed tracing context.
activitySource
.StartActivity("StartingImpersonatedActivity")
.AddTag("WorkflowActorMessageActivityImpersonated", systemDiagnosticsActivityId)
Debug.Assert(Activity.Current = activityOriginal, "Creation of activity will make it current.")
use activityImpersonated =
activitySource
.CreateActivity("ActivityImpersonation", ActivityKind.Internal)
.SetParentId(systemDiagnosticsActivityId)
.Start()
Debug.Assert(Activity.Current = activityImpersonated, "Impersonated activity is current now.")
try
let! result = action()
systemDiagnosticsActivityStatusOk(activityImpersonated)
return result
with exc ->
systemDiagnosticsActivityStatusException(activityImpersonated, exc)
return exc |> AggregateException |> raise
}
```
@ReubenBond
Contributor guide
Research direction
The issue names Orleans reminders, reminder registration and execution, the scheduler database, and System.Diagnostics.Activity.Current, but no repository files or tests. Start by tracing reminder registration into scheduler state storage and later execution, then determine how an opt-in correlation ID would flow between them. Done means distributed tracing context is preserved for reminder execution without changing default behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100