1- // Copyright (c) Microsoft Corporation.
1+ // Copyright (c) Microsoft Corporation.
22// Licensed under the MIT License.
33
44using System . Buffers ;
1111using DurableTask . Core . Entities ;
1212using DurableTask . Core . Entities . OperationFormat ;
1313using DurableTask . Core . History ;
14+ using DurableTask . Core . Tracing ;
1415using Google . Protobuf ;
1516using Google . Protobuf . WellKnownTypes ;
1617using DTCore = DurableTask . Core ;
@@ -590,6 +591,10 @@ internal static void ToEntityBatchRequest(
590591 Operation = operationRequest . Operation ,
591592 Input = operationRequest . Input ,
592593 Id = Guid . Parse ( operationRequest . RequestId ) ,
594+ TraceContext = operationRequest . TraceContext != null ?
595+ new DistributedTraceContext (
596+ operationRequest . TraceContext . TraceParent ,
597+ operationRequest . TraceContext . TraceState ) : null ,
593598 } ;
594599 }
595600
@@ -612,12 +617,16 @@ internal static void ToEntityBatchRequest(
612617 return new OperationResult ( )
613618 {
614619 Result = operationResult . Success . Result ,
620+ StartTimeUtc = operationResult . Success . StartTimeUtc ? . ToDateTime ( ) ,
621+ EndTimeUtc = operationResult . Success . EndTimeUtc ? . ToDateTime ( ) ,
615622 } ;
616623
617624 case P . OperationResult . ResultTypeOneofCase . Failure :
618625 return new OperationResult ( )
619626 {
620627 FailureDetails = operationResult . Failure . FailureDetails . ToCore ( ) ,
628+ StartTimeUtc = operationResult . Failure . StartTimeUtc ? . ToDateTime ( ) ,
629+ EndTimeUtc = operationResult . Failure . EndTimeUtc ? . ToDateTime ( ) ,
621630 } ;
622631
623632 default :
@@ -645,6 +654,8 @@ internal static void ToEntityBatchRequest(
645654 Success = new P . OperationResultSuccess ( )
646655 {
647656 Result = operationResult . Result ,
657+ StartTimeUtc = operationResult . StartTimeUtc ? . ToTimestamp ( ) ,
658+ EndTimeUtc = operationResult . EndTimeUtc ? . ToTimestamp ( ) ,
648659 } ,
649660 } ;
650661 }
@@ -655,6 +666,8 @@ internal static void ToEntityBatchRequest(
655666 Failure = new P . OperationResultFailure ( )
656667 {
657668 FailureDetails = ToProtobuf ( operationResult . FailureDetails ) ,
669+ StartTimeUtc = operationResult . StartTimeUtc ? . ToTimestamp ( ) ,
670+ EndTimeUtc = operationResult . EndTimeUtc ? . ToTimestamp ( ) ,
658671 } ,
659672 } ;
660673 }
@@ -683,6 +696,11 @@ internal static void ToEntityBatchRequest(
683696 Input = operationAction . SendSignal . Input ,
684697 InstanceId = operationAction . SendSignal . InstanceId ,
685698 ScheduledTime = operationAction . SendSignal . ScheduledTime ? . ToDateTime ( ) ,
699+ RequestTime = operationAction . SendSignal . RequestTime ? . ToDateTimeOffset ( ) ,
700+ ParentTraceContext = operationAction . SendSignal . ParentTraceContext != null ?
701+ new DistributedTraceContext (
702+ operationAction . SendSignal . ParentTraceContext . TraceParent ,
703+ operationAction . SendSignal . ParentTraceContext . TraceState ) : null ,
686704 } ;
687705
688706 case P . OperationAction . OperationActionTypeOneofCase . StartNewOrchestration :
@@ -694,6 +712,11 @@ internal static void ToEntityBatchRequest(
694712 InstanceId = operationAction . StartNewOrchestration . InstanceId ,
695713 Version = operationAction . StartNewOrchestration . Version ,
696714 ScheduledStartTime = operationAction . StartNewOrchestration . ScheduledTime ? . ToDateTime ( ) ,
715+ RequestTime = operationAction . StartNewOrchestration . RequestTime ? . ToDateTimeOffset ( ) ,
716+ ParentTraceContext = operationAction . StartNewOrchestration . ParentTraceContext != null ?
717+ new DistributedTraceContext (
718+ operationAction . StartNewOrchestration . ParentTraceContext . TraceParent ,
719+ operationAction . StartNewOrchestration . ParentTraceContext . TraceState ) : null ,
697720 } ;
698721 default :
699722 throw new NotSupportedException ( $ "Deserialization of { operationAction . OperationActionTypeCase } is not supported.") ;
@@ -725,6 +748,14 @@ internal static void ToEntityBatchRequest(
725748 Input = sendSignalAction . Input ,
726749 InstanceId = sendSignalAction . InstanceId ,
727750 ScheduledTime = sendSignalAction . ScheduledTime ? . ToTimestamp ( ) ,
751+ RequestTime = sendSignalAction . RequestTime ? . ToTimestamp ( ) ,
752+ ParentTraceContext = sendSignalAction . ParentTraceContext != null ?
753+ new P . TraceContext
754+ {
755+ TraceParent = sendSignalAction . ParentTraceContext . TraceParent ,
756+ TraceState = sendSignalAction . ParentTraceContext . TraceState ,
757+ }
758+ : null ,
728759 } ;
729760 break ;
730761
@@ -737,6 +768,14 @@ internal static void ToEntityBatchRequest(
737768 Version = startNewOrchestrationAction . Version ,
738769 InstanceId = startNewOrchestrationAction . InstanceId ,
739770 ScheduledTime = startNewOrchestrationAction . ScheduledStartTime ? . ToTimestamp ( ) ,
771+ RequestTime = startNewOrchestrationAction . RequestTime ? . ToTimestamp ( ) ,
772+ ParentTraceContext = startNewOrchestrationAction . ParentTraceContext != null ?
773+ new P . TraceContext
774+ {
775+ TraceParent = startNewOrchestrationAction . ParentTraceContext . TraceParent ,
776+ TraceState = startNewOrchestrationAction . ParentTraceContext . TraceState ,
777+ }
778+ : null ,
740779 } ;
741780 break ;
742781 }
0 commit comments