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

Report telemetry event with LSP server capabilities #66334

Merged
merged 1 commit into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Newtonsoft.Json;

namespace Microsoft.CodeAnalysis.LanguageServer.Handler;

Expand Down Expand Up @@ -41,6 +43,14 @@ public Task<InitializeResult> HandleRequestAsync(InitializeParams request, Reque
var capabilitiesProvider = context.GetRequiredLspService<ICapabilitiesProvider>();
var serverCapabilities = capabilitiesProvider.GetCapabilities(clientCapabilities);

// Record a telemetry event indicating what capabilities are being provided by the server.
// Useful for figuring out if a particular session is opted into an LSP feature.
Logger.Log(FunctionId.LSP_Initialize, KeyValueLogMessage.Create(m =>
{
m["serverKind"] = context.ServerKind.ToTelemetryString();
m["capabilities"] = JsonConvert.SerializeObject(serverCapabilities);
}));

return Task.FromResult(new InitializeResult
{
Capabilities = serverCapabilities,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,5 +589,8 @@ internal enum FunctionId

// 670-680 for newer rename ids
Rename_TryApplyRename_WorkspaceChanged = 670,

// 680-690 LSP Initialization info ids.
LSP_Initialize = 680,
}
}