Skip to content

Add API to get orchestration history in .NET Isolated #3268

Merged
sophiatev merged 17 commits into
devfrom
stevosyan/add-orchestration-history-api-isolated
Dec 18, 2025
Merged

Add API to get orchestration history in .NET Isolated #3268
sophiatev merged 17 commits into
devfrom
stevosyan/add-orchestration-history-api-isolated

Conversation

@sophiatev

@sophiatev sophiatev commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

This PR introduces the server-side implementation of a new API to retrieve orchestration history in .NET isolated. The client-side implementation is in this PR.

The server-side call is implemented in the TaskHubGrpcServer. We also introduce a new method to stream the orchestration history in the DurabilityProvider. If the backend (so far only DTS) has an orchestration history streaming API implemented, then we will use that. If not, we will fall back to the "old method" (retrieving a JSON string of the orchestration history, deserializing it, converting it to protos, and sending that).

PR to expose the history streaming API in the orchestration service in DTS (currently in draft-mode until the new WebJobs package is released).

Issue describing the changes in this PR

resolves #issue_for_this_pr

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation PR is ready to merge and referenced in pending_docs.md
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)
  • My changes do not require any extra work to be leveraged by OutOfProc SDKs
    • Otherwise: That work is being tracked here: #issue_or_pr_in_each_sdk
  • My changes do not change the version of the WebJobs.Extensions.DurableTask package
    • Otherwise: major or minor version updates are reflected in /src/Worker.Extensions.DurableTask/AssemblyInfo.cs
  • My changes do not add EventIds to our EventSource logs
    • Otherwise: Ensure the EventIds are within the supported range in our existing Windows infrastructure. You may validate this with a deployed app's telemetry. You may also extend the range by completing a PR such as this one.
  • My changes should be added to v2.x branch.
    • Otherwise: This change applies exclusively to WebJobs.Extensions.DurableTask v3.x. It will be retained only in the dev and main branches and will not be merged into the v2.x branch.

@nytian nytian 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.

Thanks for the PR! Overall looks good to me and I will go back here once the dotnet sdk is released. Left some small comments.

Comment thread test/e2e/Apps/BasicDotNetIsolated/GetOrchestrationHistory.cs
Comment thread test/e2e/Tests/Tests/GetOrchestrationHistoryTests.cs Outdated
Comment thread src/WebJobs.Extensions.DurableTask/DurabilityProvider.cs
Comment thread test/e2e/Tests/Tests/GetOrchestrationHistoryTests.cs
Comment thread src/WebJobs.Extensions.DurableTask/HistoryEventJsonConverter.cs
Comment thread src/WebJobs.Extensions.DurableTask/TaskHubGrpcServer.cs Fixed
Comment thread src/WebJobs.Extensions.DurableTask/TaskHubGrpcServer.cs Dismissed
Copilot AI review requested due to automatic review settings December 17, 2025 00:13

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.

Pull request overview

This PR implements a new server-side API to retrieve orchestration history in .NET isolated worker processes. The implementation adds streaming support for orchestration history with automatic chunking for large histories (exceeding 2 MB), includes fallback to non-streaming methods for backends that don't support streaming, and adds comprehensive E2E tests to validate the functionality across different scenarios including failed orchestrations, large histories requiring chunking, and invalid instance IDs.

Key changes include:

  • Added StreamInstanceHistory gRPC endpoint in TaskHubGrpcServer with automatic chunking for histories exceeding 2 MB
  • Enhanced history event serialization to include tags and failure details in ProtobufUtils
  • Introduced HistoryEventJsonConverter for polymorphic deserialization of history events

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/WebJobs.Extensions.DurableTask/TaskHubGrpcServer.cs Implements the StreamInstanceHistory gRPC method with chunking logic and fallback to non-streaming API
src/WebJobs.Extensions.DurableTask/ProtobufUtils.cs Updates history event protobuf conversion to include tags for ExecutionStarted and TaskScheduled events, and failure details for ExecutionCompleted events
src/WebJobs.Extensions.DurableTask/HistoryEventJsonConverter.cs New JSON converter for polymorphic deserialization of HistoryEvent types
src/WebJobs.Extensions.DurableTask/DurabilityProvider.cs Adds virtual StreamOrchestrationHistoryAsync method for backends to implement streaming
src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs Adds pass-through method for GetOrchestrationHistoryAsync to the inner client
test/e2e/Tests/Tests/GetOrchestrationHistoryTests.cs Comprehensive E2E tests for failed orchestrations, large histories, and invalid instance IDs
test/e2e/Apps/BasicDotNetIsolated/GetOrchestrationHistory.cs Test orchestrations and HTTP trigger for history retrieval
test/e2e/Tests/Tests/DistributedTracingEntitiesTests.cs Improves JSON parsing using JsonSerializer instead of manual string manipulation
test/e2e/Tests/E2ETests.csproj Adds assembly signing and project reference to WebJobs.Extensions.DurableTask
Directory.Packages.props Updates package versions for Microsoft.DurableTask packages and transitive dependencies
samples/Directory.Packages.props Updates transitive dependency versions
test/Directory.Packages.props Updates transitive dependency versions
test/TimeoutTests/Python/Nuget.config Removes durabletask package source
test/SmokeTests/OOProcSmokeTests/durablePy/Nuget.config Removes durabletask package source

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/WebJobs.Extensions.DurableTask/HistoryEventJsonConverter.cs Outdated
Comment thread src/WebJobs.Extensions.DurableTask/HistoryEventJsonConverter.cs Outdated
Comment thread src/WebJobs.Extensions.DurableTask/HistoryEventJsonConverter.cs Outdated
Comment thread src/WebJobs.Extensions.DurableTask/TaskHubGrpcServer.cs
Comment thread test/e2e/Tests/E2ETests.csproj Outdated
Comment thread test/e2e/Tests/Tests/GetOrchestrationHistoryTests.cs
Comment thread src/WebJobs.Extensions.DurableTask/HistoryEventJsonConverter.cs
Copilot AI review requested due to automatic review settings December 17, 2025 19:13

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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/WebJobs.Extensions.DurableTask/TaskHubGrpcServer.cs:580

  • The GetFailureDetails method in this class is missing recursive handling of nested InnerFailure exceptions and the IsNonRetriable property. The equivalent method in ProtobufUtils.cs (lines 385-410) correctly handles these. This means inner exception details will be lost when streaming orchestration history. Consider either using the existing method from ProtobufUtils.GetFailureDetails or adding the missing recursive call and property assignment here.
        private static P.TaskFailureDetails? GetFailureDetails(FailureDetails? failureDetails)
        {
            if (failureDetails == null)
            {
                return null;
            }

            return new P.TaskFailureDetails
            {
                ErrorType = failureDetails.ErrorType,
                ErrorMessage = failureDetails.ErrorMessage,
                StackTrace = failureDetails.StackTrace,
            };
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nytian nytian 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.

Thanks for the PR!

Comment thread src/WebJobs.Extensions.DurableTask/ProtobufUtils.cs
Comment thread test/e2e/Apps/BasicDotNetIsolated/GetOrchestrationHistory.cs
@sophiatev
sophiatev merged commit c89b19c into dev Dec 18, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants