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

Fix aggregate telemetry reliability #11134

Merged
merged 3 commits into from
Nov 1, 2024

Conversation

ryzngard
Copy link
Contributor

Currently telemetry is flushed after the language server host exits in VS Code. This is correctly flushing to the telemetry session, but can miss actually reporting the telemetry. In VS the lifetime of the TelemetrySession is managed centrally, but in VS Code it is up to each process to make sure it gets disposed properly. Without this telemetry that is fired could be dropped. This change addresses this by doing the following:

  1. Removing the flush method on ITelemetryReporter
  2. Making TelemetryReporter IDisposable (again). This will be disposed by the DI container.
  3. Keep the DI container (ExportProvider) alive in rzls until the language server host exits.

This should fix the reliability of some telemetry getting dropped. It still won't fix the scenario where the user force closes the process but better aligns VS and VS Code in expectation of lifetime management.

I noticed this while trying to set up dashboards. There are not nearly as many events as would be expected. If this still continues to be an issue one more option would be to flush on a timer. The data itself is aggregated and should handle that nicely.

@ryzngard ryzngard requested a review from a team as a code owner October 31, 2024 22:43
Copy link
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

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

Looks good to me!

src/Razor/src/rzls/Program.cs Outdated Show resolved Hide resolved
Copy link
Contributor

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

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

Makes much more sense to me

{
public void Dispose()
{
ExportProvider.Dispose();
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment here for why this doesn't dispose TelemetryReporter, even though it is disposable, would be good.

Alternatively, TryGetTelemetryReporterAsync could just return the ExportProvider, and the caller could grab the telemetry reporter from it, and this type wouldn't be needed at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true. It's only a tiny difference but I was trying to optimize for when CDK isn't installed so the provider wouldn't be needed to be kept.

@ryzngard ryzngard enabled auto-merge (squash) November 1, 2024 00:06
@ryzngard ryzngard merged commit 09cba53 into dotnet:main Nov 1, 2024
12 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Nov 1, 2024
@jjonescz jjonescz modified the milestones: Next, 17.13 P2 Nov 25, 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.

4 participants