@@ -334,6 +334,10 @@ export class SuggestController implements IEditorContribution {
334334
335335 const isResolved = item . isResolved ;
336336
337+ // telemetry data points: duration of command execution, info about async additional edits (-1=n/a, -2=none, 1=success, 0=failed)
338+ let _commandExectionDuration = - 1 ;
339+ let _additionalEditsAppliedAsync = - 1 ;
340+
337341 if ( Array . isArray ( item . completion . additionalTextEdits ) ) {
338342
339343 // cancel -> stops all listening and closes widget
@@ -399,21 +403,7 @@ export class SuggestController implements IEditorContribution {
399403 return true ;
400404 } ) . then ( applied => {
401405 this . _logService . trace ( '[suggest] async resolving of edits DONE (ms, applied?)' , sw . elapsed ( ) , applied ) ;
402- type AsyncSuggestEdits = { extensionId : string ; providerId : string ; applied : boolean } ;
403- type AsyncSuggestEditsClassification = {
404- owner : 'jrieken' ;
405- comment : 'Information about async additional text edits' ;
406- extensionId : { classification : 'PublicNonPersonalData' ; purpose : 'FeatureInsight' ; comment : 'Extension contributing the completions item' } ;
407- providerId : { classification : 'PublicNonPersonalData' ; purpose : 'FeatureInsight' ; comment : 'Provider of the completions item' } ;
408- applied : { classification : 'SystemMetaData' ; purpose : 'FeatureInsight' ; isMeasurement : true ; comment : 'If async additional text edits could be applied' } ;
409- } ;
410- if ( typeof applied === 'boolean' ) {
411- this . _telemetryService . publicLog2 < AsyncSuggestEdits , AsyncSuggestEditsClassification > ( 'suggest.asyncAdditionalEdits' , {
412- extensionId : item . extensionId ?. value ?? 'unknown' ,
413- providerId : item . provider . _debugDisplayName ?? 'unknown' ,
414- applied
415- } ) ;
416- }
406+ _additionalEditsAppliedAsync = applied === true ? 1 : applied === false ? 0 : - 2 ;
417407 } ) . finally ( ( ) => {
418408 docListener . dispose ( ) ;
419409 typeListener . dispose ( ) ;
@@ -448,12 +438,15 @@ export class SuggestController implements IEditorContribution {
448438 this . model . trigger ( { auto : true , retrigger : true } ) ;
449439 } else {
450440 // exec command, done
441+ const sw = new StopWatch ( ) ;
451442 tasks . push ( this . _commandService . executeCommand ( item . completion . command . id , ...( item . completion . command . arguments ? [ ...item . completion . command . arguments ] : [ ] ) ) . catch ( e => {
452443 if ( item . completion . extensionId ) {
453444 onUnexpectedExternalError ( e ) ;
454445 } else {
455446 onUnexpectedError ( e ) ;
456447 }
448+ } ) . finally ( ( ) => {
449+ _commandExectionDuration = sw . elapsed ( ) ;
457450 } ) ) ;
458451 }
459452 }
@@ -484,14 +477,14 @@ export class SuggestController implements IEditorContribution {
484477
485478 // clear only now - after all tasks are done
486479 Promise . all ( tasks ) . finally ( ( ) => {
487- this . _reportSuggestionAcceptedTelemetry ( item , model , isResolved ) ;
480+ this . _reportSuggestionAcceptedTelemetry ( item , model , isResolved , _commandExectionDuration , _additionalEditsAppliedAsync ) ;
488481
489482 this . model . clear ( ) ;
490483 cts . dispose ( ) ;
491484 } ) ;
492485 }
493486
494- private _reportSuggestionAcceptedTelemetry ( item : CompletionItem , model : ITextModel , itemResolved : boolean ) {
487+ private _reportSuggestionAcceptedTelemetry ( item : CompletionItem , model : ITextModel , itemResolved : boolean , commandExectionDuration : number , additionalEditsAppliedAsync : number ) {
495488
496489 if ( Math . floor ( Math . random ( ) * 100 ) === 0 ) {
497490 // throttle telemetry event because accepting completions happens a lot
@@ -502,6 +495,8 @@ export class SuggestController implements IEditorContribution {
502495 extensionId : string ; providerId : string ;
503496 fileExtension : string ; languageId : string ; basenameHash : string ; kind : number ;
504497 resolveInfo : number ; resolveDuration : number ;
498+ commandDuration : number ;
499+ additionalEditsAsync : number ;
505500 } ;
506501 type AcceptedSuggestionClassification = {
507502 owner : 'jrieken' ;
@@ -514,6 +509,8 @@ export class SuggestController implements IEditorContribution {
514509 kind : { classification : 'SystemMetaData' ; purpose : 'FeatureInsight' ; isMeasurement : true ; comment : 'The completion item kind' } ;
515510 resolveInfo : { classification : 'SystemMetaData' ; purpose : 'FeatureInsight' ; isMeasurement : true ; comment : 'If the item was inserted before resolving was done' } ;
516511 resolveDuration : { classification : 'SystemMetaData' ; purpose : 'FeatureInsight' ; isMeasurement : true ; comment : 'How long resolving took to finish' } ;
512+ commandDuration : { classification : 'SystemMetaData' ; purpose : 'FeatureInsight' ; isMeasurement : true ; comment : 'How long a completion item command took' } ;
513+ additionalEditsAsync : { classification : 'SystemMetaData' ; purpose : 'FeatureInsight' ; isMeasurement : true ; comment : 'Info about asynchronously applying additional edits' } ;
517514 } ;
518515
519516 this . _telemetryService . publicLog2 < AcceptedSuggestion , AcceptedSuggestionClassification > ( 'suggest.acceptedSuggestion' , {
@@ -524,7 +521,9 @@ export class SuggestController implements IEditorContribution {
524521 languageId : model . getLanguageId ( ) ,
525522 fileExtension : extname ( model . uri ) ,
526523 resolveInfo : ! item . provider . resolveCompletionItem ? - 1 : itemResolved ? 1 : 0 ,
527- resolveDuration : item . resolveDuration
524+ resolveDuration : item . resolveDuration ,
525+ commandDuration : commandExectionDuration ,
526+ additionalEditsAsync : additionalEditsAppliedAsync
528527 } ) ;
529528 }
530529
0 commit comments