microsoft / microsoft/durabletask-dotnet
Add instance id to logging scopes
@YunchuWang is already working on this.
Since Dec 24, 2025.
- Dominant language
- C#
- Stars
- 193
- Forks
- 60
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 4
Description
Monitoring our durable workflows would be a lot easier if we'd see the corresponding instance id within app logs from orchestrators and activities in Application Insights. Ideally, all loggers in those durable functions would automatically use a scope containing the instance id.
Right now, we'd have to create our own scope in each orchestrator and also pass the instance id to each activity in order to create another logging scope there since, from my tests, the logging scope does not extend to activity invocations.
I've also looked into a middleware-based approach, however, I wasn't able to resolve the instance id reliably from FunctionContext.
As a side note, there are at least three different ways to create a logger and things unfortunately keep on changing:
- Migrate .NET apps from the in-process model to the isolated worker model - Logging:
ILogger<T>via DI (for Activities only?) - Create your first Durable Function in C#:
FunctionContext.GetLoggerin Activity - Diagnostics in Durable Functions - App Logging:
FunctionContext.GetLogger/TaskOrchestrationContext.CreateReplaySafeLogger
If you'd ask me, I'd say that all functions should use the conventional ILogger<T> via DI which would automatically be replay safe in orchestrators with some kind of way to obtain a non-replay safe logger for debugging purposes. I get that there are probably technical constraints for how the logger API is built though.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.