@@ -728,23 +728,23 @@ protected void OnInstructionsReceived(object sender, JObject instructions)
728
728
this . Logger . LogTraceMessage ( $ "{ nameof ( NetworkingWorkloadExecutor ) } .Notification = { instructions } ") ;
729
729
730
730
Item < State > notification = instructions . ToObject < Item < State > > ( ) ;
731
- EventContext relatedContext = EventContext . Persisted ( ) ;
732
731
733
732
if ( notification . Definition . Properties . ContainsKey ( nameof ( NetworkingWorkloadState . Tool ) ) )
734
733
{
735
734
NetworkingWorkloadState serverInstructions = new NetworkingWorkloadState ( notification . Definition . Properties ) ;
735
+ telemetryContext . AddClientRequestId ( serverInstructions . ClientRequestId ) ;
736
736
737
737
if ( serverInstructions . ToolState == NetworkingWorkloadToolState . Stop )
738
738
{
739
739
this . Logger . LogTraceMessage ( $ "Synchronization: Stopping all workloads...") ;
740
- this . StopServerTool ( relatedContext ) ;
741
- this . DeleteWorkloadStateAsync ( relatedContext , cancellationToken ) . GetAwaiter ( ) . GetResult ( ) ;
740
+ this . StopServerTool ( telemetryContext ) ;
741
+ this . DeleteWorkloadStateAsync ( telemetryContext , cancellationToken ) . GetAwaiter ( ) . GetResult ( ) ;
742
742
}
743
743
else if ( serverInstructions . ToolState == NetworkingWorkloadToolState . Start )
744
744
{
745
745
this . Logger . LogTraceMessage ( $ "Synchronization: Starting { serverInstructions . Tool } workload...") ;
746
- this . StopServerTool ( relatedContext ) ;
747
- this . DeleteWorkloadStateAsync ( relatedContext , cancellationToken ) . GetAwaiter ( ) . GetResult ( ) ;
746
+ this . StopServerTool ( telemetryContext ) ;
747
+ this . DeleteWorkloadStateAsync ( telemetryContext , cancellationToken ) . GetAwaiter ( ) . GetResult ( ) ;
748
748
749
749
// The client will pass the settings to the server side. The server side will need to be updated
750
750
// to use those settings specified below. (e.g. communications protocol, concurrent threads, network buffer size).
@@ -778,10 +778,10 @@ protected void OnInstructionsReceived(object sender, JObject instructions)
778
778
NetworkingWorkloadExecutor . LocalApiClient ,
779
779
nameof ( NetworkingWorkloadState ) ,
780
780
serverInstructions ,
781
- relatedContext ,
781
+ telemetryContext ,
782
782
cancellationToken ) . GetAwaiter ( ) . GetResult ( ) ;
783
783
784
- this . StartServerTool ( serverInstructions . Tool , relatedContext , cancellationToken ) ;
784
+ this . StartServerTool ( serverInstructions . Tool , serverInstructions . ClientRequestId , telemetryContext , cancellationToken ) ;
785
785
}
786
786
}
787
787
} ) ;
@@ -877,24 +877,25 @@ await this.ClientExecutionRetryPolicy.ExecuteAsync(async () =>
877
877
{
878
878
if ( ! cancellationToken . IsCancellationRequested )
879
879
{
880
+ // The request ID enables correlation between client/server and server operations.
881
+ Guid requestId = Guid . NewGuid ( ) ;
882
+ relatedContext . AddClientRequestId ( requestId ) ;
883
+
880
884
this . Logger . LogTraceMessage ( "Synchronization: Wait for server online..." ) ;
881
885
882
886
// 1) Confirm server is online.
883
887
// ===========================================================================
884
- await NetworkingWorkloadExecutor . ServerApiClient . PollForHeartbeatAsync ( this . ServerOnlinePollingTimeout , cancellationToken , logger : this . Logger )
885
- . ConfigureAwait ( false ) ;
888
+ await NetworkingWorkloadExecutor . ServerApiClient . PollForHeartbeatAsync ( this . ServerOnlinePollingTimeout , cancellationToken , logger : this . Logger ) ;
886
889
887
890
// 2) Wait for the server to signal the eventing API is online.
888
891
// ===========================================================================
889
- await NetworkingWorkloadExecutor . ServerApiClient . PollForServerOnlineAsync ( this . ServerOnlinePollingTimeout , cancellationToken , logger : this . Logger )
890
- . ConfigureAwait ( false ) ;
892
+ await NetworkingWorkloadExecutor . ServerApiClient . PollForServerOnlineAsync ( this . ServerOnlinePollingTimeout , cancellationToken , logger : this . Logger ) ;
891
893
892
894
// 3) Request the server to stop ALL workload processes
893
895
// ===========================================================================
894
896
this . Logger . LogTraceMessage ( "Synchronization: Request server to stop all workloads..." ) ;
895
897
896
- await this . RequestStopAllWorkloadsAsync ( telemetryContext , cancellationToken )
897
- . ConfigureAwait ( false ) ;
898
+ await this . RequestStopAllWorkloadsAsync ( relatedContext , cancellationToken ) ;
898
899
899
900
// 4) Request the server start the next workload.
900
901
// ===========================================================================
@@ -924,7 +925,8 @@ await this.RequestStopAllWorkloadsAsync(telemetryContext, cancellationToken)
924
925
this . ProfilingEnabled ,
925
926
this . ProfilingScenario ,
926
927
this . ProfilingPeriod . ToString ( ) ,
927
- this . ProfilingWarmUpPeriod . ToString ( ) ) ;
928
+ this . ProfilingWarmUpPeriod . ToString ( ) ,
929
+ requestId ) ;
928
930
929
931
Item < State > instructions = new Item < State > ( nameof ( NetworkingWorkloadState ) , workloadInstructions ) ;
930
932
relatedContext . AddContext ( "instructions" , instructions ) ;
@@ -933,8 +935,8 @@ await this.RequestStopAllWorkloadsAsync(telemetryContext, cancellationToken)
933
935
await NetworkingWorkloadExecutor . SendInstructionsAsync (
934
936
NetworkingWorkloadExecutor . ServerApiClient ,
935
937
instructions ,
936
- telemetryContext ,
937
- cancellationToken ) . ConfigureAwait ( false ) ;
938
+ relatedContext ,
939
+ cancellationToken ) ;
938
940
939
941
// 5) Confirm the server has started the requested workload.
940
942
// ===========================================================================
@@ -947,14 +949,15 @@ await NetworkingWorkloadExecutor.ServerApiClient.PollForExpectedStateAsync<Netwo
947
949
&& serverState . ToolState == NetworkingWorkloadToolState . Running ;
948
950
} ,
949
951
this . StateConfirmationPollingTimeout ,
950
- cancellationToken ) . ConfigureAwait ( false ) ;
952
+ cancellationToken ) ;
951
953
952
954
this . Logger . LogTraceMessage ( "Synchronization: Server workload startup confirmed..." ) ;
953
955
this . Logger . LogTraceMessage ( "Synchronization: Start client workload..." ) ;
954
956
955
957
// 6) Execute the client workload.
956
958
// ===========================================================================
957
959
NetworkingWorkloadToolExecutor executor = this . CreateWorkloadExecutor ( toolName ) ;
960
+ executor . ClientRequestId = requestId ;
958
961
959
962
try
960
963
{
@@ -965,11 +968,8 @@ await executor.ExecuteAsync(cancellationToken)
965
968
{
966
969
this . Logger . LogTraceMessage ( "Synchronization: Wait for server to stop workload..." ) ;
967
970
968
- await NetworkingWorkloadExecutor . PollUntilStateDeletedAsync (
969
- NetworkingWorkloadExecutor . ServerApiClient ,
970
- nameof ( NetworkingWorkloadState ) ,
971
- this . StateConfirmationPollingTimeout ,
972
- cancellationToken ) . ConfigureAwait ( false ) ;
971
+ await this . RequestStopAllWorkloadsAsync ( telemetryContext , cancellationToken )
972
+ . ConfigureAwait ( false ) ;
973
973
}
974
974
}
975
975
@@ -1026,7 +1026,7 @@ private Task DeleteWorkloadStateAsync(EventContext telemetryContext, Cancellatio
1026
1026
} ) ;
1027
1027
}
1028
1028
1029
- private void StartServerTool ( NetworkingWorkloadTool toolName , EventContext telemetryContext , CancellationToken cancellationToken )
1029
+ private void StartServerTool ( NetworkingWorkloadTool toolName , Guid ? clientRequestId , EventContext telemetryContext , CancellationToken cancellationToken )
1030
1030
{
1031
1031
try
1032
1032
{
@@ -1037,6 +1037,7 @@ private void StartServerTool(NetworkingWorkloadTool toolName, EventContext telem
1037
1037
{
1038
1038
CancellationTokenSource cancellationSource = CancellationTokenSource . CreateLinkedTokenSource ( cancellationToken ) ;
1039
1039
NetworkingWorkloadToolExecutor action = this . CreateWorkloadExecutor ( toolName ) ;
1040
+ action . ClientRequestId = clientRequestId ;
1040
1041
1041
1042
this . backgroundWorkloadServer = new BackgroundWorkloadServer
1042
1043
{
0 commit comments