镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Add durable activity retry metadata and telemetry - #1435

Draft
Varshitha Bachu (bachuv) wants to merge 1 commit into
mainfrom
vabachu/activity-retry-runtime
Draft

Varshitha Bachu (bachuv) wants to merge 1 commit into
mainfrom
vabachu/activity-retry-runtime

Conversation

@bachuv

Copy link
Copy Markdown
Contributor

Why

Activity handlers and telemetry need durable retry-attempt information that is distinct from transport redelivery. This adds one-based attempt metadata, including the configured maximum and a replay-stable logical activity identifier, without moving retry ownership out of RetryInterceptor.

Approach

  • Add validated RetryMetadata and carry it through scheduling actions, TaskScheduledEvent, and activity TaskContext. Preserve optional metadata through Azure Storage queue/table serialization; no-policy calls and older histories remain compatible.
  • Isolate concurrent retry groups and preserve existing retry filters, timeout behavior, and compatibility timers. Sub-orchestration retry metadata remains out of scope.
  • Add retry attributes to activity spans and project retry-scheduled events from retained history onto the final orchestration span, using original scheduling timestamps. Map only the six allowed event attributes to correlated Application Insights custom events.
  • Cover validation, serialization, replay, concurrency, dispatcher propagation, and actual telemetry export. Support local prerelease packaging for Application Insights without changing default package versions.

Compatibility and tradeoffs

Retry events become visible only when the orchestration span completes; replay does not emit duplicates or create additional orchestration spans. Existing ContinueAsNew history resets and span lifecycles are unchanged, so inherited-trace continuation does not preserve prior-generation orchestration retry events for later reconstruction. Activity metadata and activity spans are independent of this retention boundary.

Failure types use structured failure details or sanitized types captured during normal replay. When the original legacy type is unavailable, telemetry reports TaskFailedException rather than guessing or parsing messages/stacks. Retry events do not include inputs, error messages, or stack traces. No new persisted telemetry state is introduced.

Validation

  • 111 targeted Core/runtime/export regressions passed on net8.0.
  • 52 targeted Core/telemetry regressions passed on net48.
  • Seven Azure Storage serialization regressions passed on each framework.
  • Signed Release production builds completed without warnings or errors.
  • Seven broader net48 fresh-trace tests also fail on untouched HEAD; verified separately and left unchanged.

Generated local NuGet artifacts are not included in this PR.

Carry validated replay-stable retry metadata through scheduled actions, history, and activity execution. Project retry events at orchestration completion with original timestamps and correlated allowlisted Application Insights telemetry. Add serialization, replay, dispatcher, and export regressions and document the existing generation boundary.
Copilot AI balanced review requested due to automatic review settings November 12, 2026 04:56
Comment on lines +300 to +311
foreach (ActivityEvent existing in activity.Events)
{
if (existing.Name == Schema.Task.RetryScheduled)
{
var tags = existing.Tags.ToDictionary(tag => tag.Key, tag => tag.Value);
if (tags.TryGetValue(Schema.Task.TaskId, out object? taskId) && taskId is int id
&& tags.TryGetValue(Schema.Task.RetryGroupId, out object? groupId) && groupId is string group)
{
emitted.Add((id, group));
}
}
}

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.

🟡 Changes recommended

Active issues can replace activity failures with validation errors when retry limits change and export a synthetic deserialization error instead of the documented failure-type fallback during replay.

2 open issues
What changed in this PR

Adds durable activity retry metadata across scheduling, history, activity execution, and telemetry while keeping retry ownership in RetryInterceptor.

Changes:

  • Carries validated attempt numbers, retry limits, and replay-stable group identifiers independently of transport redelivery.
  • Adds activity span attributes and completion-time retry events exported to Application Insights.
  • Adds serialization, replay, dispatcher, and telemetry tests, plus documentation and optional prerelease packaging support.
File Description
test/​DurableTask.Core.Tests/​RetryMetadataTests.cs Tests validation, serialization, replay, and retry isolation.
test/​DurableTask.Core.Tests/​DurableTelemetryModuleTests.cs Tests event export, correlation, timestamps, and allowed fields.
test/​DurableTask.Core.Tests/​DurableTask.Core.Tests.csproj References Application Insights for export tests.
test/​DurableTask.Core.Tests/​DispatcherMiddlewareTests.cs Tests metadata propagation and completion/termination telemetry.
test/​DurableTask.AzureStorage.Tests/​TableEntityConverterTests.cs Tests history-table metadata serialization and validation.
test/​DurableTask.AzureStorage.Tests/​DataContractJsonConverterTests.cs Tests queue metadata preservation and validation.
src/​DurableTask.Core/​Tracing/​TraceHelper.cs Adds retry tags and history-based event projection.
src/​DurableTask.Core/​Tracing/​Schema.cs Defines retry telemetry attribute and event names.
src/​DurableTask.Core/​TaskOrchestrationDispatcher.cs Propagates metadata and projects events before span completion.
src/​DurableTask.Core/​TaskOrchestrationContext.cs Attaches scheduling metadata and captures replay failure types.
src/​DurableTask.Core/​TaskContext.cs Exposes durable retry metadata to activities.
src/​DurableTask.Core/​TaskActivityDispatcher.cs Copies scheduled metadata into activity context.
src/​DurableTask.Core/​RetryMetadata.cs Defines the validated retry metadata contract.
src/​DurableTask.Core/​RetryInterceptor.cs Tracks retry attempt context around each invocation.
src/​DurableTask.Core/​OrchestrationContext.cs Holds asynchronous-flow-local retry context.
src/​DurableTask.Core/​History/​TaskScheduledEvent.cs Stores optional durable retry metadata in history.
src/​DurableTask.Core/​Command/​ScheduleTaskOrchestratorAction.cs Carries retry metadata in scheduling actions.
src/​DurableTask.ApplicationInsights/​DurableTelemetryModule.cs Exports correlated retry events with allowlisted attributes.
src/​DurableTask.ApplicationInsights/​DurableTask.ApplicationInsights.csproj Supports optional package version suffixes.
docs/​telemetry/​traces/​semantic-conventions.md Documents retry attributes, projection, and retention limits.
docs/​telemetry/​application-insights.md Documents retry custom-event export behavior.
docs/​features/​retries.md Documents activity retry metadata and compatibility.

Review effort: Balanced

Comment on lines +62 to +63
retryContext.AttemptNumber = retryCount + 1;
retryContext.PreviousFailure = lastException;

internal static string? GetTaskFailureType(Exception failure) =>
(failure as OrchestrationException)?.FailureDetails?.ErrorType
?? failure.InnerException?.GetType().FullName
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.

2 participants