@@ -179,12 +179,12 @@ public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message,
179179 jobContext . SetVariable ( Constants . Variables . System . WorkFolder , HostContext . GetDirectory ( WellKnownDirectory . Work ) , isFilePath : true ) ;
180180
181181 var azureVmCheckCommand = jobContext . GetHostContext ( ) . GetService < IAsyncCommandContext > ( ) ;
182- azureVmCheckCommand . InitializeCommandContext ( jobContext , " GetAzureVMMetada" ) ;
182+ azureVmCheckCommand . InitializeCommandContext ( jobContext , Constants . AsyncExecution . Commands . Names . GetAzureVMMetada ) ;
183183 azureVmCheckCommand . Task = Task . Run ( ( ) => jobContext . SetVariable ( Constants . Variables . System . IsAzureVM , PlatformUtil . DetectAzureVM ( ) ? "1" : "0" ) ) ;
184184 jobContext . AsyncCommands . Add ( azureVmCheckCommand ) ;
185185
186186 var dockerDetectCommand = jobContext . GetHostContext ( ) . GetService < IAsyncCommandContext > ( ) ;
187- dockerDetectCommand . InitializeCommandContext ( jobContext , " DetectDockerContainer" ) ;
187+ dockerDetectCommand . InitializeCommandContext ( jobContext , Constants . AsyncExecution . Commands . Names . DetectDockerContainer ) ;
188188 dockerDetectCommand . Task = Task . Run ( ( ) => jobContext . SetVariable ( Constants . Variables . System . IsDockerContainer , PlatformUtil . DetectDockerContainer ( ) ? "1" : "0" ) ) ;
189189 jobContext . AsyncCommands . Add ( dockerDetectCommand ) ;
190190
@@ -277,6 +277,31 @@ public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message,
277277 this . ExpandProperties ( sidecar , jobContext . Variables ) ;
278278 }
279279
280+ // Send telemetry in case if git is preinstalled on windows platform
281+ var isSelfHosted = StringUtil . ConvertToBoolean ( jobContext . Variables . Get ( Constants . Variables . Agent . IsSelfHosted ) ) ;
282+ if ( PlatformUtil . RunningOnWindows && isSelfHosted )
283+ {
284+ var windowsPreinstalledGitCommand = jobContext . GetHostContext ( ) . GetService < IAsyncCommandContext > ( ) ;
285+ windowsPreinstalledGitCommand . InitializeCommandContext ( jobContext , Constants . AsyncExecution . Commands . Names . WindowsPreinstalledGitTelemetry ) ;
286+ windowsPreinstalledGitCommand . Task = Task . Run ( ( ) =>
287+ {
288+ var hasPreinstalledGit = false ;
289+
290+ var filePath = WhichUtil . Which ( "git.exe" , require : false , trace : null ) ;
291+ if ( ! string . IsNullOrEmpty ( filePath ) )
292+ {
293+ hasPreinstalledGit = true ;
294+ }
295+
296+ PublishTelemetry ( context : jobContext , area : "PipelinesTasks" , feature : "WindowsGitTelemetry" , properties : new Dictionary < string , string >
297+ {
298+ { "hasPreinstalledGit" , hasPreinstalledGit . ToString ( ) }
299+ } ) ;
300+ } ) ;
301+
302+ jobContext . AsyncCommands . Add ( windowsPreinstalledGitCommand ) ;
303+ }
304+
280305 // Get the job extension.
281306 Trace . Info ( "Getting job extension." ) ;
282307 var hostType = jobContext . Variables . System_HostType ;
@@ -301,7 +326,13 @@ public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message,
301326 if ( AgentKnobs . FailJobWhenAgentDies . GetValue ( jobContext ) . AsBoolean ( ) &&
302327 HostContext . AgentShutdownToken . IsCancellationRequested )
303328 {
304- PublishTelemetry ( jobContext , TaskResult . Failed . ToString ( ) , "111" ) ;
329+ PublishTelemetry ( context : jobContext , area : "PipelinesTasks" , feature : "AgentShutdown" , properties : new Dictionary < string , string >
330+ {
331+ { "JobId" , jobContext . Variables . System_JobId . ToString ( ) } ,
332+ { "JobResult" , TaskResult . Failed . ToString ( ) } ,
333+ { "TracePoint" , "111" } ,
334+ } ) ;
335+
305336 Trace . Error ( $ "Job is canceled during initialize.") ;
306337 Trace . Error ( $ "Caught exception: { ex } ") ;
307338 return await CompleteJobAsync ( jobServer , jobContext , message , TaskResult . Failed ) ;
@@ -610,20 +641,14 @@ private void ReplaceConfigUriBaseInJobRequestMessage(Pipelines.AgentJobRequestMe
610641 }
611642 }
612643
613- private void PublishTelemetry ( IExecutionContext context , string Task_Result , string TracePoint )
644+ private void PublishTelemetry ( IExecutionContext context , string area , String feature , Dictionary < string , string > properties )
614645 {
615646 try
616647 {
617- var telemetryData = new Dictionary < string , string >
618- {
619- { "JobId" , context . Variables . System_JobId . ToString ( ) } ,
620- { "JobResult" , Task_Result } ,
621- { "TracePoint" , TracePoint } ,
622- } ;
623648 var cmd = new Command ( "telemetry" , "publish" ) ;
624- cmd . Data = JsonConvert . SerializeObject ( telemetryData , Formatting . None ) ;
625- cmd . Properties . Add ( "area" , "PipelinesTasks" ) ;
626- cmd . Properties . Add ( "feature" , "AgentShutdown" ) ;
649+ cmd . Data = JsonConvert . SerializeObject ( properties , Formatting . None ) ;
650+ cmd . Properties . Add ( "area" , area ) ;
651+ cmd . Properties . Add ( "feature" , feature ) ;
627652
628653 var publishTelemetryCmd = new TelemetryCommandExtension ( ) ;
629654 publishTelemetryCmd . Initialize ( HostContext ) ;
0 commit comments