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 flush method and make it implementation detail on how that happens #11087

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

ryzngard
Copy link
Contributor

rzls imports telemetry by creating an ExportProvider with the path to devkit telemetry if it's installed and enabled. Unfortunately that means that dispose is being prematurely called when that provider is torn down. To help with this two things are done:

  1. Make a flush method on ITelemetryReporter
  2. Make when flush happens an implementation detail on the specific providers.

In this case, rzls will flush after the language server host exits. In other cases IDisposable will be used to flush telemetry (VS and OOP)

@ryzngard ryzngard requested a review from a team as a code owner October 24, 2024 19:06
Copy link
Member

@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.

It's not clear to my why this couldn't just have been done by putting a using on line 80 of Program.cs, and have the Dispose method call Flush, but I have no problem with doing it explicitly either

@ryzngard ryzngard merged commit e9199b6 into dotnet:main Oct 24, 2024
12 checks passed
@ryzngard ryzngard deleted the flush_in_rzls branch October 24, 2024 21:39
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Oct 24, 2024
@ryzngard
Copy link
Contributor Author

It's not clear to my why this couldn't just have been done by putting a using on line 80 of Program.cs, and have the Dispose method call Flush, but I have no problem with doing it explicitly either

If we do that we double dispose, which isn't necessarily bad but also hard to spot and could lead to future bugs.

@davidwengier
Copy link
Member

Oh okay, so we're essentially not in charge of dispose, so we're probably calling flush on the already disposed object, to work around that?

@ryzngard
Copy link
Contributor Author

Yea. If we make it IDisposable then the container we use to discover the export from the devkit disposes of it

using var exportProvider = await ExportProviderBuilder

It was causing me a headache to figure out why dispose was at startup and not when I would expect.

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