Using disposable objects in Orchestration functions

Open
#1,225 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp

Research direction

Start by reproducing the orchestration replay behavior described in the issue, focusing on the IDisposable scope around the awaited activity calls. Document when the scope is created and disposed during replay, and explain the correct pattern for logging and instrumentation so the collected data remains accurate.

Written by the indexing model from the issue text.

Description

Is there any guidance on how to correctly use objects that implement IDisposable in Orchestration functions?

Let's consider something like this:

using (IActivityScope scope = _activityScopeFactory.CreateScope())
{
    await context.CallActivityAsync("TestActivity1");
    await context.CallActivityAsync("TestActivity2");

    // (...) etc.
}

Unless we're doing something wrong, the current behavior we're observing is that the scope object will be created multiple times, every time the orchestration is re-run to be replayed when the various activity complete. However, the Dispose on said scope only ever gets called once, as the orchestration completes?

Is there a way to somehow get it to always run?

We're doing this for logging and instrumentation, so there's no risk of leaking expensive stuff, but it's still quite annoying because the data we gather with this flow is just not correct. We'd love to get any insight on how to do it the right way.

Dominant language
C#
Stars
1.7k
Forks
335
Avg merge
4d 2h
Merged PRs (30d)
6

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.

More from Azure/durabletask

All issues in Azure/durabletask

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.