提交 e4679ec3 编写于 作者: W Wonseok Chae

Merge pull request #4420 from wschae/telemetry

Initial work to add telemetry to Interactive Windows

- add telemetry for create/open/close Interactive Windows.
......@@ -5,11 +5,11 @@
using System.IO;
using Microsoft.CodeAnalysis.Editor.CSharp.Interactive;
using Microsoft.CodeAnalysis.Editor.Interactive;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.VisualStudio.LanguageServices.Interactive;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Utilities;
using Microsoft.VisualStudio.InteractiveWindow;
using Microsoft.VisualStudio.InteractiveWindow.Commands;
using Microsoft.VisualStudio.InteractiveWindow.Shell;
using LanguageServiceGuids = Microsoft.VisualStudio.LanguageServices.Guids;
......@@ -63,5 +63,10 @@ protected override string Title
Path.GetDirectoryName(typeof(CSharpVsInteractiveWindowPackage).Assembly.Location),
CommonVsUtils.GetWorkingDirectory());
}
protected override void LogSession(string key, string value)
{
Logger.Log(FunctionId.CSharp_Interactive_Window, KeyValueLogMessage.Create(m => m.Add(key, value)));
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.VisualStudio.LanguageServices.Interactive
{
internal static class LogMessage
{
public const string Window = "InteractiveWindow";
public const string Create = "Create";
public const string Open = "Open";
public const string Close = "Close";
}
}
......@@ -6,6 +6,7 @@
using EnvDTE;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.LanguageServices.Setup;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
......@@ -38,6 +39,12 @@ protected override void Initialize()
var menuCommandService = (OleMenuCommandService)GetService(typeof(IMenuCommandService));
InitializeMenuCommands(menuCommandService);
InitializeResetInteractiveFromProjectCommand(menuCommandService);
var telemetrySetupExtensions = _componentModel.GetExtensions<IRoslynTelemetrySetup>();
foreach (var telemetrySetup in telemetrySetupExtensions)
{
telemetrySetup.Initialize(this);
}
}
protected TVsInteractiveWindowProvider InteractiveWindowProvider
......
......@@ -54,6 +54,7 @@ internal abstract class VsInteractiveWindowProvider
protected abstract Guid LanguageServiceGuid { get; }
protected abstract Guid Id { get; }
protected abstract string Title { get; }
protected abstract void LogSession(string key, string value);
protected IInteractiveWindowCommandsFactory CommandsFactory
{
......@@ -79,7 +80,11 @@ public IVsInteractiveWindow Create(int instanceId)
vsWindow.SetLanguage(LanguageServiceGuid, evaluator.ContentType);
// the tool window now owns the engine:
vsWindow.InteractiveWindow.TextView.Closed += new EventHandler((_, __) => evaluator.Dispose());
vsWindow.InteractiveWindow.TextView.Closed += new EventHandler((_, __) =>
{
LogSession(LogMessage.Window, LogMessage.Close);
evaluator.Dispose();
});
// vsWindow.AutoSaveOptions = true;
var window = vsWindow.InteractiveWindow;
......@@ -87,6 +92,8 @@ public IVsInteractiveWindow Create(int instanceId)
// fire and forget:
window.InitializeAsync();
LogSession(LogMessage.Window, LogMessage.Create);
return vsWindow;
}
......@@ -102,6 +109,8 @@ public IVsInteractiveWindow Open(int instanceId, bool focus)
_vsInteractiveWindow.Show(focus);
LogSession(LogMessage.Window, LogMessage.Open);
return _vsInteractiveWindow;
}
......
......@@ -196,6 +196,7 @@
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="Interactive\LogMessage.cs" />
<Compile Include="Interactive\VsInteractiveWindowPackage.cs" />
<Compile Include="Interactive\VsInteractiveWindowProvider.cs" />
<Compile Include="Interactive\CommonVsUtils.cs" />
......
......@@ -4,6 +4,7 @@ Imports System.ComponentModel.Composition
Imports System.IO
Imports Microsoft.CodeAnalysis.Editor.Interactive
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.Interactive
Imports Microsoft.CodeAnalysis.Internal.Log
Imports Microsoft.VisualStudio.LanguageServices.Interactive
Imports Microsoft.VisualStudio.Shell
Imports Microsoft.VisualStudio.Text.Classification
......@@ -63,6 +64,10 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Interactive
Path.GetDirectoryName(GetType(VisualBasicVsInteractiveWindowPackage).Assembly.Location),
CommonVsUtils.GetWorkingDirectory())
End Function
Protected Overrides Sub LogSession(key As String, value As String)
Logger.Log(FunctionId.VisualBasic_Interactive_Window, KeyValueLogMessage.Create(Sub(m) m.Add(key, value)))
End Sub
End Class
End Namespace
......@@ -304,6 +304,9 @@ internal enum FunctionId
VirtualMemory_MemoryLow,
Extension_Exception,
WorkCoordinator_WaitForHigherPriorityOperationsAsync
WorkCoordinator_WaitForHigherPriorityOperationsAsync,
CSharp_Interactive_Window,
VisualBasic_Interactive_Window
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册