From 5293a7404a7396643fc61adb0154f762a4f80b66 Mon Sep 17 00:00:00 2001 From: Todd Grunke Date: Fri, 19 Jan 2024 16:48:28 -0800 Subject: [PATCH 1/2] This source links a couple files into devkit that use VSTelemetry to enable our TelemetryLogger API. Additionally, it adds a TelemetryLogger.Create call into VSCodeTelemetryLogger to actually create the TelemetryLogProvider --- .../Telemetry/{ => Shared}/AggregatingTelemetryLog.cs | 0 .../{ => Shared}/AggregatingTelemetryLogManager.cs | 0 .../Def/Telemetry/{ => Shared}/TelemetryLogProvider.cs | 0 .../Core/Def/Telemetry/{ => Shared}/TelemetryLogger.cs | 0 .../Telemetry/{ => Shared}/VisualStudioTelemetryLog.cs | 0 .../{ => Shared}/VisualStudioTelemetryLogManager.cs | 0 .../DevKit/Impl/Logging/VSCodeTelemetryLogger.cs | 9 ++++++++- ...Microsoft.VisualStudio.LanguageServices.DevKit.csproj | 1 + .../Microsoft.CodeAnalysis.Remote.ServiceHub.csproj | 8 +------- 9 files changed, 10 insertions(+), 8 deletions(-) rename src/VisualStudio/Core/Def/Telemetry/{ => Shared}/AggregatingTelemetryLog.cs (100%) rename src/VisualStudio/Core/Def/Telemetry/{ => Shared}/AggregatingTelemetryLogManager.cs (100%) rename src/VisualStudio/Core/Def/Telemetry/{ => Shared}/TelemetryLogProvider.cs (100%) rename src/VisualStudio/Core/Def/Telemetry/{ => Shared}/TelemetryLogger.cs (100%) rename src/VisualStudio/Core/Def/Telemetry/{ => Shared}/VisualStudioTelemetryLog.cs (100%) rename src/VisualStudio/Core/Def/Telemetry/{ => Shared}/VisualStudioTelemetryLogManager.cs (100%) diff --git a/src/VisualStudio/Core/Def/Telemetry/AggregatingTelemetryLog.cs b/src/VisualStudio/Core/Def/Telemetry/Shared/AggregatingTelemetryLog.cs similarity index 100% rename from src/VisualStudio/Core/Def/Telemetry/AggregatingTelemetryLog.cs rename to src/VisualStudio/Core/Def/Telemetry/Shared/AggregatingTelemetryLog.cs diff --git a/src/VisualStudio/Core/Def/Telemetry/AggregatingTelemetryLogManager.cs b/src/VisualStudio/Core/Def/Telemetry/Shared/AggregatingTelemetryLogManager.cs similarity index 100% rename from src/VisualStudio/Core/Def/Telemetry/AggregatingTelemetryLogManager.cs rename to src/VisualStudio/Core/Def/Telemetry/Shared/AggregatingTelemetryLogManager.cs diff --git a/src/VisualStudio/Core/Def/Telemetry/TelemetryLogProvider.cs b/src/VisualStudio/Core/Def/Telemetry/Shared/TelemetryLogProvider.cs similarity index 100% rename from src/VisualStudio/Core/Def/Telemetry/TelemetryLogProvider.cs rename to src/VisualStudio/Core/Def/Telemetry/Shared/TelemetryLogProvider.cs diff --git a/src/VisualStudio/Core/Def/Telemetry/TelemetryLogger.cs b/src/VisualStudio/Core/Def/Telemetry/Shared/TelemetryLogger.cs similarity index 100% rename from src/VisualStudio/Core/Def/Telemetry/TelemetryLogger.cs rename to src/VisualStudio/Core/Def/Telemetry/Shared/TelemetryLogger.cs diff --git a/src/VisualStudio/Core/Def/Telemetry/VisualStudioTelemetryLog.cs b/src/VisualStudio/Core/Def/Telemetry/Shared/VisualStudioTelemetryLog.cs similarity index 100% rename from src/VisualStudio/Core/Def/Telemetry/VisualStudioTelemetryLog.cs rename to src/VisualStudio/Core/Def/Telemetry/Shared/VisualStudioTelemetryLog.cs diff --git a/src/VisualStudio/Core/Def/Telemetry/VisualStudioTelemetryLogManager.cs b/src/VisualStudio/Core/Def/Telemetry/Shared/VisualStudioTelemetryLogManager.cs similarity index 100% rename from src/VisualStudio/Core/Def/Telemetry/VisualStudioTelemetryLogManager.cs rename to src/VisualStudio/Core/Def/Telemetry/Shared/VisualStudioTelemetryLogManager.cs diff --git a/src/VisualStudio/DevKit/Impl/Logging/VSCodeTelemetryLogger.cs b/src/VisualStudio/DevKit/Impl/Logging/VSCodeTelemetryLogger.cs index c28adc1aacbe1..6c5ce2adf2242 100644 --- a/src/VisualStudio/DevKit/Impl/Logging/VSCodeTelemetryLogger.cs +++ b/src/VisualStudio/DevKit/Impl/Logging/VSCodeTelemetryLogger.cs @@ -11,6 +11,8 @@ using System.Threading; using Microsoft.CodeAnalysis.Contracts.Telemetry; using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Shared.TestHooks; +using Microsoft.CodeAnalysis.Telemetry; using Microsoft.VisualStudio.Telemetry; namespace Microsoft.CodeAnalysis.LanguageServer.Logging; @@ -19,6 +21,8 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Logging; internal sealed class VSCodeTelemetryLogger : ITelemetryReporter { private TelemetrySession? _telemetrySession; + private readonly IAsynchronousOperationListenerProvider _asyncListenerProvider; + private const string CollectorApiKey = "0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255"; private static int _dumpsSubmitted = 0; @@ -26,8 +30,9 @@ internal sealed class VSCodeTelemetryLogger : ITelemetryReporter [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public VSCodeTelemetryLogger() + public VSCodeTelemetryLogger(IAsynchronousOperationListenerProvider asyncListenerProvider) { + _asyncListenerProvider = asyncListenerProvider; } public void InitializeSession(string telemetryLevel, string? sessionId, bool isDefaultSession) @@ -46,6 +51,8 @@ public void InitializeSession(string telemetryLevel, string? sessionId, bool isD session.RegisterForReliabilityEvent(); _telemetrySession = session; + + TelemetryLogger.Create(_telemetrySession, logDelta: false, _asyncListenerProvider); } public void Log(string name, List> properties) diff --git a/src/VisualStudio/DevKit/Impl/Microsoft.VisualStudio.LanguageServices.DevKit.csproj b/src/VisualStudio/DevKit/Impl/Microsoft.VisualStudio.LanguageServices.DevKit.csproj index 81afe558ddda7..339b5d2a742e6 100644 --- a/src/VisualStudio/DevKit/Impl/Microsoft.VisualStudio.LanguageServices.DevKit.csproj +++ b/src/VisualStudio/DevKit/Impl/Microsoft.VisualStudio.LanguageServices.DevKit.csproj @@ -17,6 +17,7 @@ + diff --git a/src/Workspaces/Remote/ServiceHub/Microsoft.CodeAnalysis.Remote.ServiceHub.csproj b/src/Workspaces/Remote/ServiceHub/Microsoft.CodeAnalysis.Remote.ServiceHub.csproj index dc17be6ae5811..2e6ce22a7645f 100644 --- a/src/Workspaces/Remote/ServiceHub/Microsoft.CodeAnalysis.Remote.ServiceHub.csproj +++ b/src/Workspaces/Remote/ServiceHub/Microsoft.CodeAnalysis.Remote.ServiceHub.csproj @@ -39,13 +39,7 @@ - - - - - - - + From f5ef0a247295c1ab02f958b98ae853a4552934ad Mon Sep 17 00:00:00 2001 From: Todd Grunke Date: Fri, 19 Jan 2024 16:53:22 -0800 Subject: [PATCH 2/2] Fix merge issue --- .../Core/Def/Telemetry/{ => Shared}/TimedTelemetryLogBlock.cs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/VisualStudio/Core/Def/Telemetry/{ => Shared}/TimedTelemetryLogBlock.cs (100%) diff --git a/src/VisualStudio/Core/Def/Telemetry/TimedTelemetryLogBlock.cs b/src/VisualStudio/Core/Def/Telemetry/Shared/TimedTelemetryLogBlock.cs similarity index 100% rename from src/VisualStudio/Core/Def/Telemetry/TimedTelemetryLogBlock.cs rename to src/VisualStudio/Core/Def/Telemetry/Shared/TimedTelemetryLogBlock.cs