microsoft / microsoft/durabletask-dotnet

Add instance id to logging scopes

Open
#250 1 comment 2 reactions 2 assignees View on GitHub

@YunchuWang is already working on this.

Since Dec 24, 2025.

Observability P3
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:

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.