@@ -179,12 +179,12 @@ public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message,
179
179
jobContext . SetVariable ( Constants . Variables . System . WorkFolder , HostContext . GetDirectory ( WellKnownDirectory . Work ) , isFilePath : true ) ;
180
180
181
181
var azureVmCheckCommand = jobContext . GetHostContext ( ) . GetService < IAsyncCommandContext > ( ) ;
182
- azureVmCheckCommand . InitializeCommandContext ( jobContext , " GetAzureVMMetada" ) ;
182
+ azureVmCheckCommand . InitializeCommandContext ( jobContext , Constants . AsyncExecution . Commands . Names . GetAzureVMMetada ) ;
183
183
azureVmCheckCommand . Task = Task . Run ( ( ) => jobContext . SetVariable ( Constants . Variables . System . IsAzureVM , PlatformUtil . DetectAzureVM ( ) ? "1" : "0" ) ) ;
184
184
jobContext . AsyncCommands . Add ( azureVmCheckCommand ) ;
185
185
186
186
var dockerDetectCommand = jobContext . GetHostContext ( ) . GetService < IAsyncCommandContext > ( ) ;
187
- dockerDetectCommand . InitializeCommandContext ( jobContext , " DetectDockerContainer" ) ;
187
+ dockerDetectCommand . InitializeCommandContext ( jobContext , Constants . AsyncExecution . Commands . Names . DetectDockerContainer ) ;
188
188
dockerDetectCommand . Task = Task . Run ( ( ) => jobContext . SetVariable ( Constants . Variables . System . IsDockerContainer , PlatformUtil . DetectDockerContainer ( ) ? "1" : "0" ) ) ;
189
189
jobContext . AsyncCommands . Add ( dockerDetectCommand ) ;
190
190
@@ -277,6 +277,31 @@ public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message,
277
277
this . ExpandProperties ( sidecar , jobContext . Variables ) ;
278
278
}
279
279
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
+
280
305
// Get the job extension.
281
306
Trace . Info ( "Getting job extension." ) ;
282
307
var hostType = jobContext . Variables . System_HostType ;
@@ -301,7 +326,13 @@ public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message,
301
326
if ( AgentKnobs . FailJobWhenAgentDies . GetValue ( jobContext ) . AsBoolean ( ) &&
302
327
HostContext . AgentShutdownToken . IsCancellationRequested )
303
328
{
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
+
305
336
Trace . Error ( $ "Job is canceled during initialize.") ;
306
337
Trace . Error ( $ "Caught exception: { ex } ") ;
307
338
return await CompleteJobAsync ( jobServer , jobContext , message , TaskResult . Failed ) ;
@@ -610,20 +641,14 @@ private void ReplaceConfigUriBaseInJobRequestMessage(Pipelines.AgentJobRequestMe
610
641
}
611
642
}
612
643
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 )
614
645
{
615
646
try
616
647
{
617
- var telemetryData = new Dictionary < string , string >
618
- {
619
- { "JobId" , context . Variables . System_JobId . ToString ( ) } ,
620
- { "JobResult" , Task_Result } ,
621
- { "TracePoint" , TracePoint } ,
622
- } ;
623
648
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 ) ;
627
652
628
653
var publishTelemetryCmd = new TelemetryCommandExtension ( ) ;
629
654
publishTelemetryCmd . Initialize ( HostContext ) ;
0 commit comments