@@ -5,7 +5,6 @@ namespace VirtualClient.Actions
55{
66 using System ;
77 using System . Collections . Generic ;
8- using System . IO ;
98 using System . Linq ;
109 using System . Net ;
1110 using System . Net . Http ;
@@ -270,24 +269,27 @@ protected override void Validate()
270269
271270 private async Task CaptureRedisVersionAsync ( EventContext telemetryContext , CancellationToken token )
272271 {
273- string command = $ "{ this . RedisExecutablePath } --version";
274- IProcessProxy process = await this . ExecuteCommandAsync ( command , null , this . RedisPackagePath , telemetryContext , token , runElevated : true ) ;
275- string output = process . StandardOutput . ToString ( ) ;
276- Match match = Regex . Match ( output , @"v=(\d+\.\d+\.\d+)" ) ;
277- if ( match . Success )
272+ try
278273 {
279- this . RedisVersion = match . Groups [ 1 ] . Value ;
280- telemetryContext . AddContext ( "RedisVersion" , this . RedisVersion ) ;
281- this . Logger . LogMessage ( $ "{ this . TypeName } .RedisVersionCaptured", LogLevel . Information , telemetryContext ) ;
282- this . MetadataContract . AddForScenario (
283- "Redis-Benchmark" ,
284- null ,
285- toolVersion : this . RedisVersion ) ;
286- this . MetadataContract . Apply ( telemetryContext ) ;
274+ string command = $ "{ this . RedisExecutablePath } --version";
275+ IProcessProxy process = await this . ExecuteCommandAsync ( command , null , this . RedisPackagePath , telemetryContext , token , runElevated : true ) ;
276+ string output = process . StandardOutput . ToString ( ) ;
277+ Match match = Regex . Match ( output , @"v=(\d+\.\d+\.\d+)" ) ;
278+ this . RedisVersion = match . Success ? match . Groups [ 1 ] . Value : null ;
279+ if ( ! string . IsNullOrEmpty ( this . RedisVersion ) )
280+ {
281+ telemetryContext . AddContext ( "RedisVersion" , this . RedisVersion ) ;
282+ this . Logger . LogMessage ( $ "{ this . TypeName } .RedisVersionCaptured", LogLevel . Information , telemetryContext ) ;
283+ this . MetadataContract . AddForScenario (
284+ "Redis-Benchmark" ,
285+ null ,
286+ toolVersion : this . RedisVersion ) ;
287+ this . MetadataContract . Apply ( telemetryContext ) ;
288+ }
287289 }
288- else
290+ catch ( Exception ex )
289291 {
290- throw new WorkloadException ( "Failed to parse Redis version from output." , ErrorReason . CriticalWorkloadFailure ) ;
292+ this . Logger . LogErrorMessage ( ex , telemetryContext ) ;
291293 }
292294 }
293295
0 commit comments