Skip to content

Move the project telemetry collection out of process.#42383

Merged
25 commits merged intodotnet:masterfrom
CyrusNajmabadi:telemetryOOP
Mar 16, 2020
Merged

Move the project telemetry collection out of process.#42383
25 commits merged intodotnet:masterfrom
CyrusNajmabadi:telemetryOOP

Conversation

@CyrusNajmabadi
Copy link
Contributor

No description provided.

@CyrusNajmabadi CyrusNajmabadi requested review from a team as code owners March 13, 2020 04:35
@CyrusNajmabadi
Copy link
Contributor Author

Tagging @tmat @jasonmalinowski

/// along to be worked on. Rounds of processing happen serially, only starting up after a
/// previous round has completed.
/// </summary>
internal class AsyncBatchingWorkQueue<TItem>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i extracted this into its own type as it's something i've replicated in a few OOP prs at this point. Might as well have a simple and common impl they can all use.

Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

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

Had one or two questions, but mainly looks good! Would recommend another pair of eyes though.


namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectTelemetry
{
internal class VisualStudioProjectTelemetryService
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any semantic changes in this file, or is it just moving existing code around?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah seems like mix of new code + moved code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there are semantic changes. this now calls into the OOP system and batches responses from it.

private const string TelemetryProjectReferencesCountName = PropertyPrefix + "ProjectReferences.Count";
private const string TelemetryMetadataReferencesCountName = PropertyPrefix + "MetadataReferences.Count";
private const string TelemetryDocumentsCountName = PropertyPrefix + "Documents.Count";
private const string TelemetryAdditionalDocumentsCountName = PropertyPrefix + "AdditionalDocuments.Count";
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also track AnalyzerConfigDocuments.Count?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. i can add that. (just preserving existing telemetry code). That won't break anything, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I am not sure - should be fine to do this in a follow-up PR as you are preserving existing semantics.

Copy link
Contributor Author

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

c

}
catch (Exception e)
{
// The telemetry service itself can throw.
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, is this the recommended pattern everywhere we log exceptions from telemetry logging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no idea. this part was entirely copy paste of the original logic. i didn't want to touch it.


namespace Microsoft.CodeAnalysis.ProjectTelemetry
{
internal struct ProjectTelemetryInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

IEquatable<ProjectTelemetryInfo>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No real point. This is just a basic serialization type.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

@ghost ghost merged commit 8935840 into dotnet:master Mar 16, 2020

private async Task StartAsync(CancellationToken cancellationToken)
{
_workQueue = new AsyncBatchingWorkQueue<DesignerInfo>(
Copy link
Member

Choose a reason for hiding this comment

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

_workQueue [](start = 12, length = 10)

Add Contract.ThrowIfNotNull(_qorkQueue)

}
}

_workQueue.AddWork(attributeInfos);
Copy link
Member

Choose a reason for hiding this comment

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

_workQueue [](start = 12, length = 10)

Contract.ThrowIfNull(_workQueue)

private bool _taskInFlight = false;

#endregion
private AsyncBatchingWorkQueue<DesignerInfo> _workQueue = null!;
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer not cheating here and keeping this nullable. Then add Contract.ThrowIfNull in entry points that need this to be initialized.

/// <summary>
/// Queue where we enqueue the information we get from OOP to process in batch in the future.
/// </summary>
private AsyncBatchingWorkQueue<ProjectTelemetryInfo> _workQueue = null!;
Copy link
Member

Choose a reason for hiding this comment

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

ProjectTelemetryInfo [](start = 39, length = 20)

The same comment as in designer attribute impl.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants