Skip to content

Commit

Permalink
Merge pull request #74688 from dibarbet/project_load_telemetry
Browse files Browse the repository at this point in the history
Only report project load events for initial load in VSCode
  • Loading branch information
dibarbet authored Aug 8, 2024
2 parents 3acf211 + 045ae70 commit c098e96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public async Task OpenSolutionAsync(string solutionFilePath)

foreach (var project in await buildHost.GetProjectsInSolutionAsync(solutionFilePath, CancellationToken.None))
{
_projectsToLoadAndReload.AddWork(new ProjectToLoad(project.ProjectPath, project.ProjectGuid));
_projectsToLoadAndReload.AddWork(new ProjectToLoad(project.ProjectPath, project.ProjectGuid, ReportTelemetry: true));
}

// Wait for the in progress batch to complete and send a project initialized notification to the client.
Expand All @@ -131,7 +131,7 @@ public async Task OpenProjectsAsync(ImmutableArray<string> projectFilePaths)

using (await _gate.DisposableWaitAsync())
{
_projectsToLoadAndReload.AddWork(projectFilePaths.Select(p => new ProjectToLoad(p, ProjectGuid: null)));
_projectsToLoadAndReload.AddWork(projectFilePaths.Select(p => new ProjectToLoad(p, ProjectGuid: null, ReportTelemetry: true)));

// Wait for the in progress batch to complete and send a project initialized notification to the client.
await _projectsToLoadAndReload.WaitUntilCurrentBatchCompletesAsync();
Expand Down Expand Up @@ -278,7 +278,7 @@ private async Task<bool> LoadOrReloadProjectAsync(ProjectToLoad projectToLoad, T
_workspaceFactory.ProjectSystemHostInfo);

var loadedProject = new LoadedProject(projectSystemProject, _workspaceFactory.Workspace.Services.SolutionServices, _fileChangeWatcher, _workspaceFactory.TargetFrameworkManager);
loadedProject.NeedsReload += (_, _) => _projectsToLoadAndReload.AddWork(projectToLoad);
loadedProject.NeedsReload += (_, _) => _projectsToLoadAndReload.AddWork(projectToLoad with { ReportTelemetry = false });
existingProjects.Add(loadedProject);

(targetTelemetryInfo, targetNeedsRestore) = await loadedProject.UpdateWithNewProjectInfoAsync(loadedProjectInfo, _logger);
Expand All @@ -288,7 +288,11 @@ private async Task<bool> LoadOrReloadProjectAsync(ProjectToLoad projectToLoad, T
}
}

await _projectLoadTelemetryReporter.ReportProjectLoadTelemetryAsync(telemetryInfos, projectToLoad, cancellationToken);
if (projectToLoad.ReportTelemetry)
{
await _projectLoadTelemetryReporter.ReportProjectLoadTelemetryAsync(telemetryInfos, projectToLoad, cancellationToken);
}

diagnosticLogItems = await loadedFile.GetDiagnosticLogItemsAsync(cancellationToken);
if (diagnosticLogItems.Any())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace;
/// <summary>
/// The project path (and the guid if it game from a solution) of the project to load.
/// </summary>
internal record ProjectToLoad(string Path, string? ProjectGuid)
internal record ProjectToLoad(string Path, string? ProjectGuid, bool ReportTelemetry)
{
public static IEqualityComparer<ProjectToLoad> Comparer = new ProjectToLoadComparer();

Expand Down

0 comments on commit c098e96

Please sign in to comment.