Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add telemetry for 'bad' experiences based on tag helpers #10906

Merged
merged 3 commits into from
Sep 23, 2024

Conversation

ryzngard
Copy link
Contributor

Helps add telemetry for cases like AB#2255138

@ryzngard ryzngard requested a review from a team as a code owner September 20, 2024 00:31
var document = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
var tagHelpers = document.GetTagHelpers();

if (Interlocked.Exchange(ref _lastReportedTagHelperCount, tagHelpers.Count) != tagHelpers.Count)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ If the user is getting "RZ10012" errors, isn't it possible (maybe likely?) that the tag helper count is going to be 0? If so, is using the tag helper count as a way to reduce telemetry events going to skew the data so it doesn't look as significant a problem? Would using the number of relevant diagnostics be better?

@davidwengier
Copy link
Contributor

(Noting that I'm on my phone so might have missed something, and can't view the work item linked in the description)

I'm a little unsure of the scenario this is trying to catch. The last tag helper count has a lifetime that matches the language server, but the number of tag helpers being stored in it comes from the document. That means it's the count of tag helpers available to that document based on usings etc. Seems like it would be trivial to trigger this telemetry just by switching tabs in an IDE. In fact, if the IDE request diagnostics from all open documents, I think a user wouldn't even have to switch. As they are typing a component tag, if they have multiple files open, this could just quietly report telemetry constantly in the background.

If the intention is to find issues with tag helper discovery then I think the project tag helper count would be better, though even that won't stand up to multiple documents being open if they're from different projects. We recently saw telemetry that seemed to show project tag helper count fluctuating, but we could tell whether it was just two projects in a solution that had different component counts, which even the standard Blazor App template would exhibit, or an actual problem.

Perhaps this telemetry should use a dictionary to keep last tag helper count per project? It might also be a good idea to report a hash of the project.

Also worth noting I don't believe the pull diags endpoint will be hit in VS Code so this would be VS only telemetry, though I'm not 100% confident on that.

@ryzngard
Copy link
Contributor Author

Definitely agree this should be a per project count. I'll update the PR

@ryzngard ryzngard merged commit a906642 into dotnet:main Sep 23, 2024
12 checks passed
@ryzngard ryzngard deleted the rz10012errors branch September 23, 2024 19:54
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Sep 23, 2024
@ryzngard
Copy link
Contributor Author

Merging before snap but feel free to add follow up comments and I'll address them

var document = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
var tagHelpers = document.GetTagHelpers();
var tagHelpers = await documentContext.Project.GetTagHelpersAsync(cancellationToken).ConfigureAwait(false);
var tagHelperCount = tagHelpers.Count();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: .Length

new Property("RZ10012errors", relevantDiagnosticsCount));
new("tagHelpers", tagHelperCount),
new("RZ10012errors", relevantDiagnosticsCount),
new("project", documentContext.Project.Key.Id));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this PII? Do have PIIProperty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It gets labeled in the server to not depend on client side labeling and ensure correct handling

@phil-allen-msft phil-allen-msft modified the milestones: Next, 17.12 P3 Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants