Skip to content

Commit bbbb52d

Browse files
Add telemetry
1 parent 6b1f61b commit bbbb52d

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

src/EditorFeatures/Core/Copilot/RoslynProposalAdjusterProvider.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
using System.Threading;
1010
using System.Threading.Tasks;
1111
using Microsoft.CodeAnalysis.Editor;
12-
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
1312
using Microsoft.CodeAnalysis.Host.Mef;
13+
using Microsoft.CodeAnalysis.Internal.Log;
1414
using Microsoft.CodeAnalysis.Remote;
1515
using Microsoft.CodeAnalysis.Text;
1616
using Microsoft.CodeAnalysis.Text.Shared.Extensions;
@@ -27,13 +27,13 @@ namespace Microsoft.CodeAnalysis.Copilot;
2727
internal sealed class RoslynProposalAdjusterProvider() : ProposalAdjusterProviderBase
2828
{
2929
public override Task<ProposalBase> AdjustProposalBeforeDisplayAsync(ProposalBase proposal, string providerName, CancellationToken cancellationToken)
30-
=> AdjustProposalAsync(proposal, providerName, cancellationToken);
30+
=> AdjustProposalAsync(proposal, providerName, before: true, cancellationToken);
3131

3232
public override Task<ProposalBase> AdjustProposalAfterAcceptAsync(ProposalBase proposal, string providerName, CancellationToken cancellationToken)
33-
=> AdjustProposalAsync(proposal, providerName, cancellationToken);
33+
=> AdjustProposalAsync(proposal, providerName, before: false, cancellationToken);
3434

3535
private async Task<ProposalBase> AdjustProposalAsync(
36-
ProposalBase proposal, string providerName, CancellationToken cancellationToken)
36+
ProposalBase proposal, string providerName, bool before, CancellationToken cancellationToken)
3737
{
3838
// Ensure we're only operating on one solution. It makes the logic much simpler, as we don't have to
3939
// worry about edits that touch multiple solutions.
@@ -80,9 +80,33 @@ private async Task<ProposalBase> AdjustProposalAsync(
8080

8181
// No adjustments were made. Don't touch anything.
8282
if (!adjustmentsProposed)
83+
{
84+
using var _3 = Logger.LogBlock(FunctionId.Copilot_AdjustProposal, KeyValueLogMessage.Create(static (d, args) =>
85+
{
86+
var (providerName, before) = args;
87+
d["ProviderName"] = providerName;
88+
d["Before"] = before;
89+
d["AdjustmentsProposed"] = false;
90+
},
91+
args: (providerName, before)),
92+
cancellationToken);
93+
8394
return proposal;
95+
}
8496

8597
var newProposal = Proposal.TryCreateProposal(proposal, finalEdits);
98+
99+
using var _4 = Logger.LogBlock(FunctionId.Copilot_AdjustProposal, KeyValueLogMessage.Create(static (d, args) =>
100+
{
101+
var (providerName, before, newProposal) = args;
102+
d["ProviderName"] = providerName;
103+
d["Before"] = before;
104+
d["AdjustmentsProposed"] = true;
105+
d["AdjustmentsAccepted"] = newProposal != null;
106+
},
107+
args: (providerName, before, newProposal)),
108+
cancellationToken);
109+
86110
return newProposal ?? proposal;
87111
}
88112

src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Log/FunctionId.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ internal enum FunctionId
646646
Copilot_Implement_NotImplementedException_Completed = 832,
647647

648648
Copilot_AnalyzeChange = 840,
649+
Copilot_AdjustProposal = 841,
649650

650651
Copilot_Rename = 851,
651652

0 commit comments

Comments
 (0)