-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gopls: add gopls/client telemetry counters
These counters are incremented once per session when the LSP initialize message is received. This cl adds a new dependency on x/telemetry. Note that writing to the disk will be enabled when GOPLS_TELEMETRY_EXP is set. We plan to remove this condition once we are ready. Updates golang/go#61038 Change-Id: Ibb8ebbd039ab5ffbaa869dee01bee0ba5450f350 Reviewed-on: https://go-review.googlesource.com/c/tools/+/506635 Reviewed-by: Jamal Carvalho <jamal@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
- Loading branch information
Showing
5 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2023 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package telemetry | ||
|
||
import ( | ||
"os" | ||
|
||
"golang.org/x/telemetry/counter" | ||
"golang.org/x/tools/gopls/internal/lsp/protocol" | ||
) | ||
|
||
// Start starts telemetry instrumentation. | ||
func Start() { | ||
if os.Getenv("GOPLS_TELEMETRY_EXP") != "" { | ||
counter.Open() | ||
// TODO: add upload logic. | ||
} | ||
} | ||
|
||
// RecordClientInfo records gopls client info. | ||
func RecordClientInfo(params *protocol.ParamInitialize) { | ||
client := "gopls/client:other" | ||
if params != nil && params.ClientInfo != nil { | ||
switch params.ClientInfo.Name { | ||
case "Visual Studio Code": | ||
client = "gopls/client:vscode" | ||
case "VSCodium": | ||
client = "gopls/client:vscodium" | ||
case "code-server": | ||
// https://github.com/coder/code-server/blob/3cb92edc76ecc2cfa5809205897d93d4379b16a6/ci/build/build-vscode.sh#L19 | ||
client = "gopls/client:code-server" | ||
case "Eglot": | ||
// https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-03/msg00954.html | ||
client = "gopls/client:eglot" | ||
case "govim": | ||
// https://github.com/govim/govim/pull/1189 | ||
client = "gopls/client:govim" | ||
case "Neovim": | ||
// https://github.com/neovim/neovim/blob/42333ea98dfcd2994ee128a3467dfe68205154cd/runtime/lua/vim/lsp.lua#L1361 | ||
client = "gopls/client:neovim" | ||
case "coc.nvim": | ||
// https://github.com/neoclide/coc.nvim/blob/3dc6153a85ed0f185abec1deb972a66af3fbbfb4/src/language-client/client.ts#L994 | ||
client = "gopls/client:coc.nvim" | ||
case "Sublime Text LSP": | ||
// https://github.com/sublimelsp/LSP/blob/e608f878e7e9dd34aabe4ff0462540fadcd88fcc/plugin/core/sessions.py#L493 | ||
client = "gopls/client:sublimetext" | ||
} | ||
} | ||
counter.Inc(client) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters