From 77013b607870d31090ee7803d7e186f60d4cf0e6 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Wed, 5 Aug 2020 23:18:35 -0700 Subject: [PATCH 1/7] fix correlation test fail except for external event with extended session false --- src/DurableTask.Core/TaskHubClient.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/DurableTask.Core/TaskHubClient.cs b/src/DurableTask.Core/TaskHubClient.cs index 9b18298a5..e8c874581 100644 --- a/src/DurableTask.Core/TaskHubClient.cs +++ b/src/DurableTask.Core/TaskHubClient.cs @@ -535,6 +535,8 @@ async Task InternalCreateOrchestrationInstanceWithRaisedE }; this.logHelper.SchedulingOrchestration(startedEvent); + + CorrelationTraceClient.Propagate(() => CreateAndTrackDependencyTelemetry(requestTraceContext)); // Raised events and create orchestration calls use different methods so get handled separately await this.ServiceClient.CreateTaskOrchestrationAsync(startMessage, dedupeStatuses); @@ -559,10 +561,10 @@ async Task InternalCreateOrchestrationInstanceWithRaisedE }, Event = eventRaisedEvent, }; + await this.ServiceClient.SendTaskOrchestrationMessageAsync(eventMessage); } - CorrelationTraceClient.Propagate(() => CreateAndTrackDependencyTelemetry(requestTraceContext)); return orchestrationInstance; } From c3fcec4c03c82983eaefa92117c245826d6fad6d Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Mon, 14 Sep 2020 22:10:38 -0700 Subject: [PATCH 2/7] Fix for External Event only Orchestration with Unit Test --- .../AzureStorageOrchestrationService.cs | 25 ++- .../Tracking/AzureTableTrackingStore.cs | 8 +- .../CorrelationTraceClient.cs | 18 +++ src/DurableTask.Core/History/HistoryEvent.cs | 6 + .../Correlation/CorrelationScenarioTest.cs | 144 +++++++++++++++++- .../TestOrchestrationClient.cs | 7 + 6 files changed, 200 insertions(+), 8 deletions(-) diff --git a/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs b/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs index 51ba2cfa2..2920d5f8e 100644 --- a/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs +++ b/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs @@ -657,11 +657,11 @@ public async Task LockNextTaskOrchestrationWorkItemAs // Create or restore Correlation TraceContext TraceContextBase currentRequestTraceContext = null; - CorrelationTraceClient.Propagate( - () => + await CorrelationTraceClient.PropagateAsync( + async () => { var isReplaying = session.RuntimeState.ExecutionStartedEvent?.IsPlayed ?? false; - TraceContextBase parentTraceContext = GetParentTraceContext(session.CurrentMessageBatch); + TraceContextBase parentTraceContext = await GetParentTraceContextAsync(session); currentRequestTraceContext = GetRequestTraceContext(isReplaying, parentTraceContext); }); @@ -763,8 +763,9 @@ public async Task LockNextTaskOrchestrationWorkItemAs } } - static TraceContextBase GetParentTraceContext(IList messages) + async Task GetParentTraceContextAsync(OrchestrationSession session) { + var messages = session.CurrentMessageBatch; TraceContextBase parentTraceContext = null; foreach(var message in messages) { @@ -803,7 +804,15 @@ static TraceContextBase GetParentTraceContext(IList messages) break; } - } + } else + { + if (message.TaskMessage.Event is EventRaisedEvent) + { + var history = await this.trackingStore.GetHistoryEventsAsync(session.Instance.InstanceId, session.Instance.ExecutionId); + var traceContextString = history.Events.OrderByDescending(p => p.Timestamp).Where(p => p.Correlation != null).FirstOrDefault().Correlation; + parentTraceContext = TraceContextBase.Restore(traceContextString); + } + } } return parentTraceContext ?? TraceContextFactory.Empty; @@ -826,6 +835,12 @@ message.TaskMessage.Event is DurableTask.Core.History.TaskFailedEvent || return false; } + //async Task GetTraceContextFromTrackingStoreAsync(OrchestrationSession session) + //{ + // var history = await this.trackingStore.GetHistoryEventsAsync(session.Instance.InstanceId, session.Instance.ExecutionId); + + //} + static TraceContextBase GetRequestTraceContext(bool isReplaying, TraceContextBase parentTraceContext) { TraceContextBase currentRequestTraceContext = TraceContextFactory.Empty; diff --git a/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs b/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs index d20a8c314..e36464e82 100644 --- a/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs +++ b/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs @@ -946,7 +946,7 @@ public override async Task UpdateStateAsync( ["LastUpdatedTime"] = new EntityProperty(newEvents.Last().Timestamp), } }; - + for (int i = 0; i < newEvents.Count; i++) { bool isFinalEvent = i == newEvents.Count - 1; @@ -980,6 +980,12 @@ public override async Task UpdateStateAsync( instanceEntity.Properties["Version"] = new EntityProperty(executionStartedEvent.Version); instanceEntity.Properties["CreatedTime"] = new EntityProperty(executionStartedEvent.Timestamp); instanceEntity.Properties["RuntimeStatus"] = new EntityProperty(OrchestrationStatus.Running.ToString()); + CorrelationTraceClient.Propagate(() => + { + var traceContext = CorrelationTraceContext.Current; + historyEntity.Properties["Correlation"] = new EntityProperty(traceContext.SerializableTraceContext); + }); + this.SetInstancesTablePropertyFromHistoryProperty( historyEntity, instanceEntity, diff --git a/src/DurableTask.Core/CorrelationTraceClient.cs b/src/DurableTask.Core/CorrelationTraceClient.cs index 6ba74bda8..35e254884 100644 --- a/src/DurableTask.Core/CorrelationTraceClient.cs +++ b/src/DurableTask.Core/CorrelationTraceClient.cs @@ -16,6 +16,7 @@ namespace DurableTask.Core using System; using System.Collections.Generic; using System.Diagnostics; + using System.Threading.Tasks; using DurableTask.Core.Settings; /// @@ -113,6 +114,23 @@ public static void Propagate(Action action) Execute(action); } + /// + /// Execute Aysnc Function for propagete correlation information + /// It suppresses the execution when .DisablePropagation is true. + /// + /// + /// + public static Task PropagateAsync(Func func) + { + if (CorrelationSettings.Current.EnableDistributedTracing) + { + return func(); + } else + { + return Task.CompletedTask; + } + } + static void Tracking(Action tracking) { Execute(tracking); diff --git a/src/DurableTask.Core/History/HistoryEvent.cs b/src/DurableTask.Core/History/HistoryEvent.cs index a6c71c9e3..a8b35836b 100644 --- a/src/DurableTask.Core/History/HistoryEvent.cs +++ b/src/DurableTask.Core/History/HistoryEvent.cs @@ -88,5 +88,11 @@ protected HistoryEvent(int eventId) /// Implementation for . /// public ExtensionDataObject ExtensionData { get; set; } + + /// + /// Gets the Correlation + /// + [DataMember] + public string Correlation { get; set; } } } \ No newline at end of file diff --git a/test/DurableTask.AzureStorage.Tests/Correlation/CorrelationScenarioTest.cs b/test/DurableTask.AzureStorage.Tests/Correlation/CorrelationScenarioTest.cs index 0cfe522fc..5e96da93f 100644 --- a/test/DurableTask.AzureStorage.Tests/Correlation/CorrelationScenarioTest.cs +++ b/test/DurableTask.AzureStorage.Tests/Correlation/CorrelationScenarioTest.cs @@ -25,7 +25,6 @@ namespace DurableTask.AzureStorage.Tests.Correlation using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.DataContracts; using Microsoft.ApplicationInsights.Extensibility.Implementation; - using Microsoft.ApplicationInsights.W3C; using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; @@ -519,9 +518,10 @@ public async Task MultipleParentScenarioAsync(Protocol protocol, bool enableExte while (IsNotReadyForRaiseEvent(host.Client)) { - await Task.Delay(TimeSpan.FromMilliseconds(300)); + await Task.Delay(TimeSpan.FromMilliseconds(100)); } + await Task.Delay(TimeSpan.FromSeconds(1)); tasks.Add(host.Client.RaiseEventAsync("someEvent", "hi")); await Task.WhenAll(tasks); @@ -575,6 +575,146 @@ internal static void Reset() } } + [DataTestMethod] + [DataRow(Protocol.W3CTraceContext, false)] + [DataRow(Protocol.HttpCorrelationProtocol, false)] + [DataRow(Protocol.W3CTraceContext, true)] + [DataRow(Protocol.HttpCorrelationProtocol, true)] + public async Task MultipleParentMultiLayerScenarioAsync(Protocol protocol, bool enableExtendedSessions) + { + MultiParentOrchestrator.Reset(); + CorrelationSettings.Current.Protocol = protocol; + CorrelationSettings.Current.EnableDistributedTracing = true; + var host = new TestCorrelationOrchestrationHost(); + var tasks = new List(); + tasks.Add(host.ExecuteOrchestrationAsync(typeof(MultiParentMultiLayeredOrchestrator), "world", 30, enableExtendedSessions)); + + while (IsNotReadyForTwoRaiseEvents(host.Client)) + { + await Task.Delay(TimeSpan.FromMilliseconds(100)); + } + + await Task.Delay(TimeSpan.FromSeconds(1)); + foreach(string instanceId in MultiParentChildOrchestrator.InstanceIds) + { + tasks.Add(host.Client.RaiseEventAsync(instanceId, "someEvent", "hi")); + } + await Task.WhenAll(tasks); + + List actual = Convert(tasks[0]); + + Assert.AreEqual(11, actual.Count); + CollectionAssert.AreEqual( + new (Type, string)[] + { + (typeof(RequestTelemetry), TraceConstants.Client), + (typeof(DependencyTelemetry), TraceConstants.Client), + (typeof(RequestTelemetry), $"{TraceConstants.Orchestrator} MultiParentMultiLayeredOrchestrator"), + (typeof(DependencyTelemetry), $"{TraceConstants.Orchestrator} {typeof(MultiParentChildOrchestrator).FullName}"), + (typeof(RequestTelemetry), $"{TraceConstants.Orchestrator} MultiParentChildOrchestrator"), + (typeof(DependencyTelemetry), $"{TraceConstants.Orchestrator} {typeof(Hello).FullName}"), + (typeof(RequestTelemetry), $"{TraceConstants.Activity} Hello"), + (typeof(DependencyTelemetry), $"{TraceConstants.Orchestrator} {typeof(MultiParentChildOrchestrator).FullName}"), + (typeof(RequestTelemetry), $"{TraceConstants.Orchestrator} MultiParentChildOrchestrator"), + (typeof(DependencyTelemetry), $"{TraceConstants.Orchestrator} {typeof(Hello).FullName}"), + (typeof(RequestTelemetry), $"{TraceConstants.Activity} Hello") + }, actual.Select(x => (x.GetType(), x.Name)).ToList()); + MultiParentChildOrchestrator.Reset(); + + } + + bool IsNotReadyForTwoRaiseEvents(TestOrchestrationClient client) + { + return client == null || !(MultiParentChildOrchestrator.ReadyForExternalEvent == 2); + } + + [KnownType(typeof(MultiParentChildOrchestrator))] + [KnownType(typeof(Hello))] + internal class MultiParentMultiLayeredOrchestrator : TaskOrchestration + { + public override async Task RunTask(OrchestrationContext context, string input) + { + var tasks = new List>(); + tasks.Add(context.CreateSubOrchestrationInstance(typeof(MultiParentChildOrchestrator), "foo")); + tasks.Add(context.CreateSubOrchestrationInstance(typeof(MultiParentChildOrchestrator), "bar")); + await Task.WhenAll(tasks); + return $"{tasks[0].Result}:{tasks[1].Result}"; + } + } + [KnownType(typeof(Hello))] + internal class MultiParentChildOrchestrator : TaskOrchestration + { + private static object lockExternalEvent = new object(); + private static object lockId = new object(); + private static int readyCountForExternalEvent = 0; + private static List orchestrationIds = new List(); + public static int ReadyForExternalEvent + { + get + { + return readyCountForExternalEvent; + } + + set + { + lock (lockExternalEvent) + { + readyCountForExternalEvent = value; + } + } + } + public static IEnumerable InstanceIds + { + get + { + IEnumerable result; + lock(lockId) + { + result = orchestrationIds.ToList(); + } + return result; + } + } + + public static void AddOrchestrationId(string orchestrationId) + { + lock(lockId) + { + orchestrationIds.Add(orchestrationId); + } + } + + public static void IncrementReadyForExternalEvent() + { + lock (lockExternalEvent) + { + readyCountForExternalEvent++; + } + } + + readonly TaskCompletionSource receiveEvent = new TaskCompletionSource(); + + public async override Task RunTask(OrchestrationContext context, string input) + { + AddOrchestrationId(context.OrchestrationInstance.InstanceId); + IncrementReadyForExternalEvent(); + await this.receiveEvent.Task; + await context.ScheduleTask(typeof(Hello), input); + return "done"; + } + + public override void OnEvent(OrchestrationContext context, string name, string input) + { + this.receiveEvent.SetResult(null); + } + + internal static void Reset() + { + ReadyForExternalEvent = 0; + orchestrationIds = new List(); + } + } + [DataTestMethod] [DataRow(Protocol.W3CTraceContext, false)] [DataRow(Protocol.HttpCorrelationProtocol, false)] diff --git a/test/DurableTask.AzureStorage.Tests/TestOrchestrationClient.cs b/test/DurableTask.AzureStorage.Tests/TestOrchestrationClient.cs index 48f8e78c4..b9ac0ade9 100644 --- a/test/DurableTask.AzureStorage.Tests/TestOrchestrationClient.cs +++ b/test/DurableTask.AzureStorage.Tests/TestOrchestrationClient.cs @@ -121,6 +121,13 @@ public Task RaiseEventAsync(string eventName, object eventData) return this.client.RaiseEventAsync(instance, eventName, eventData); } + public Task RaiseEventAsync(string instanceId, string eventName, object eventData) + { + Trace.TraceInformation($"Raising event to instance {instanceId} with name = {eventName}."); + var instance = new OrchestrationInstance { InstanceId = instanceId }; + return this.client.RaiseEventAsync(instance, eventName, eventData); + } + public Task TerminateAsync(string reason) { Trace.TraceInformation($"Terminating instance {this.instanceId} with reason = {reason}."); From b63ce9d5863aa48ab5d2ed51756de34c050db69a Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Wed, 23 Sep 2020 00:41:48 -0700 Subject: [PATCH 3/7] Remove trackingStore operation --- .../AzureStorageOrchestrationService.cs | 19 +++++++------------ .../Tracking/AzureTableTrackingStore.cs | 2 ++ .../History/ExecutionStartedEvent.cs | 6 ++++++ src/DurableTask.Core/History/HistoryEvent.cs | 5 ----- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs b/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs index 2920d5f8e..0dc144201 100644 --- a/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs +++ b/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs @@ -657,11 +657,11 @@ public async Task LockNextTaskOrchestrationWorkItemAs // Create or restore Correlation TraceContext TraceContextBase currentRequestTraceContext = null; - await CorrelationTraceClient.PropagateAsync( - async () => + CorrelationTraceClient.Propagate( + () => { var isReplaying = session.RuntimeState.ExecutionStartedEvent?.IsPlayed ?? false; - TraceContextBase parentTraceContext = await GetParentTraceContextAsync(session); + TraceContextBase parentTraceContext = GetParentTraceContext(session); currentRequestTraceContext = GetRequestTraceContext(isReplaying, parentTraceContext); }); @@ -763,7 +763,7 @@ await CorrelationTraceClient.PropagateAsync( } } - async Task GetParentTraceContextAsync(OrchestrationSession session) + TraceContextBase GetParentTraceContext(OrchestrationSession session) { var messages = session.CurrentMessageBatch; TraceContextBase parentTraceContext = null; @@ -808,8 +808,9 @@ async Task GetParentTraceContextAsync(OrchestrationSession ses { if (message.TaskMessage.Event is EventRaisedEvent) { - var history = await this.trackingStore.GetHistoryEventsAsync(session.Instance.InstanceId, session.Instance.ExecutionId); - var traceContextString = history.Events.OrderByDescending(p => p.Timestamp).Where(p => p.Correlation != null).FirstOrDefault().Correlation; + var history = session.RuntimeState.Events; + + var traceContextString = history.Where(p => p.EventType == EventType.ExecutionStarted).Select(p => (ExecutionStartedEvent)p).FirstOrDefault().Correlation; parentTraceContext = TraceContextBase.Restore(traceContextString); } } @@ -835,12 +836,6 @@ message.TaskMessage.Event is DurableTask.Core.History.TaskFailedEvent || return false; } - //async Task GetTraceContextFromTrackingStoreAsync(OrchestrationSession session) - //{ - // var history = await this.trackingStore.GetHistoryEventsAsync(session.Instance.InstanceId, session.Instance.ExecutionId); - - //} - static TraceContextBase GetRequestTraceContext(bool isReplaying, TraceContextBase parentTraceContext) { TraceContextBase currentRequestTraceContext = TraceContextFactory.Empty; diff --git a/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs b/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs index e36464e82..0790853bb 100644 --- a/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs +++ b/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs @@ -56,6 +56,7 @@ class AzureTableTrackingStore : TrackingStoreBase OutputProperty, "Reason", "Details", + "Correlation" }; readonly string storageAccountName; @@ -984,6 +985,7 @@ public override async Task UpdateStateAsync( { var traceContext = CorrelationTraceContext.Current; historyEntity.Properties["Correlation"] = new EntityProperty(traceContext.SerializableTraceContext); + estimatedBytes += System.Text.ASCIIEncoding.ASCII.GetByteCount(traceContext.SerializableTraceContext); }); this.SetInstancesTablePropertyFromHistoryProperty( diff --git a/src/DurableTask.Core/History/ExecutionStartedEvent.cs b/src/DurableTask.Core/History/ExecutionStartedEvent.cs index e022678cd..1fb7f0981 100644 --- a/src/DurableTask.Core/History/ExecutionStartedEvent.cs +++ b/src/DurableTask.Core/History/ExecutionStartedEvent.cs @@ -79,5 +79,11 @@ internal ExecutionStartedEvent() /// [DataMember] public IDictionary Tags { get; set; } + + /// + /// Gets or sets the serialized end-to-end correlation state. + /// + [DataMember] + public string Correlation { get; set; } } } \ No newline at end of file diff --git a/src/DurableTask.Core/History/HistoryEvent.cs b/src/DurableTask.Core/History/HistoryEvent.cs index a8b35836b..fab1057b8 100644 --- a/src/DurableTask.Core/History/HistoryEvent.cs +++ b/src/DurableTask.Core/History/HistoryEvent.cs @@ -89,10 +89,5 @@ protected HistoryEvent(int eventId) /// public ExtensionDataObject ExtensionData { get; set; } - /// - /// Gets the Correlation - /// - [DataMember] - public string Correlation { get; set; } } } \ No newline at end of file From 18342b89e6186cd9420e7fb7bdc7ae68052aa7b7 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Wed, 23 Sep 2020 00:44:38 -0700 Subject: [PATCH 4/7] fix: wrong else line --- src/DurableTask.Core/CorrelationTraceClient.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DurableTask.Core/CorrelationTraceClient.cs b/src/DurableTask.Core/CorrelationTraceClient.cs index 35e254884..99fd91943 100644 --- a/src/DurableTask.Core/CorrelationTraceClient.cs +++ b/src/DurableTask.Core/CorrelationTraceClient.cs @@ -125,7 +125,8 @@ public static Task PropagateAsync(Func func) if (CorrelationSettings.Current.EnableDistributedTracing) { return func(); - } else + } + else { return Task.CompletedTask; } From 11725f8ae70ba8d60e27d4a48b743b102957ecac Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Thu, 24 Sep 2020 23:46:52 -0700 Subject: [PATCH 5/7] Set ExecutionStartedEvent.Correlation on the DurableTask.Core side. --- .../Tracking/AzureTableTrackingStore.cs | 5 ++--- src/DurableTask.Core/TaskOrchestrationDispatcher.cs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs b/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs index 0790853bb..8c38b36ce 100644 --- a/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs +++ b/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs @@ -983,9 +983,8 @@ public override async Task UpdateStateAsync( instanceEntity.Properties["RuntimeStatus"] = new EntityProperty(OrchestrationStatus.Running.ToString()); CorrelationTraceClient.Propagate(() => { - var traceContext = CorrelationTraceContext.Current; - historyEntity.Properties["Correlation"] = new EntityProperty(traceContext.SerializableTraceContext); - estimatedBytes += System.Text.ASCIIEncoding.ASCII.GetByteCount(traceContext.SerializableTraceContext); + historyEntity.Properties["Correlation"] = new EntityProperty(executionStartedEvent.Correlation); + estimatedBytes += System.Text.ASCIIEncoding.ASCII.GetByteCount(executionStartedEvent.Correlation); }); this.SetInstancesTablePropertyFromHistoryProperty( diff --git a/src/DurableTask.Core/TaskOrchestrationDispatcher.cs b/src/DurableTask.Core/TaskOrchestrationDispatcher.cs index 439d73c6b..b09fd4067 100644 --- a/src/DurableTask.Core/TaskOrchestrationDispatcher.cs +++ b/src/DurableTask.Core/TaskOrchestrationDispatcher.cs @@ -392,6 +392,13 @@ protected async Task OnProcessWorkItemAsync(TaskOrchestrationWorkItem work } } + // correlation + CorrelationTraceClient.Propagate(() => { + if (runtimeState.ExecutionStartedEvent != null) + runtimeState.ExecutionStartedEvent.Correlation = CorrelationTraceContext.Current.SerializableTraceContext; + }); + + // finish up processing of the work item if (!continuedAsNew && runtimeState.Events.Last().EventType != EventType.OrchestratorCompleted) { @@ -416,6 +423,11 @@ protected async Task OnProcessWorkItemAsync(TaskOrchestrationWorkItem work workItem.InstanceId, "Updating state for continuation"); + // correlation + CorrelationTraceClient.Propagate(() => { + continueAsNewExecutionStarted.Correlation = CorrelationTraceContext.Current.SerializableTraceContext; + }); + runtimeState = new OrchestrationRuntimeState(); runtimeState.AddEvent(new OrchestratorStartedEvent(-1)); runtimeState.AddEvent(continueAsNewExecutionStarted); From ceb34198e2f64e05d67113060e5da43f16fe218e Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Fri, 25 Sep 2020 23:14:29 -0700 Subject: [PATCH 6/7] Update src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs Co-authored-by: Chris Gillum --- .../AzureStorageOrchestrationService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs b/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs index 0dc144201..02d6a5837 100644 --- a/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs +++ b/src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs @@ -810,7 +810,7 @@ TraceContextBase GetParentTraceContext(OrchestrationSession session) { var history = session.RuntimeState.Events; - var traceContextString = history.Where(p => p.EventType == EventType.ExecutionStarted).Select(p => (ExecutionStartedEvent)p).FirstOrDefault().Correlation; + string traceContextString = session.RuntimeState.ExecutionStartedEvent?.Correlation; parentTraceContext = TraceContextBase.Restore(traceContextString); } } From b3d6bea35b915ab49a2e44cfda820547e4b74231 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ushio Date: Fri, 25 Sep 2020 23:15:59 -0700 Subject: [PATCH 7/7] Update src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs Co-authored-by: Chris Gillum --- .../Tracking/AzureTableTrackingStore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs b/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs index 8c38b36ce..0419c553b 100644 --- a/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs +++ b/src/DurableTask.AzureStorage/Tracking/AzureTableTrackingStore.cs @@ -984,7 +984,7 @@ public override async Task UpdateStateAsync( CorrelationTraceClient.Propagate(() => { historyEntity.Properties["Correlation"] = new EntityProperty(executionStartedEvent.Correlation); - estimatedBytes += System.Text.ASCIIEncoding.ASCII.GetByteCount(executionStartedEvent.Correlation); + estimatedBytes += Encoding.Unicode.GetByteCount(executionStartedEvent.Correlation); }); this.SetInstancesTablePropertyFromHistoryProperty(