aboutsummaryrefslogtreecommitdiff
path: root/internal/lsp/debug
AgeCommit message (Collapse)Author
2022-02-07internal/lsp/debug: add go version to gopls version outputHana
Add -json flag to output in JSON format. Include the Go version info - go1.18: runtime/debug.BuildInfo.GoVersion - pre go1.18: runtime.Version Restructure ServiceVersion so we embed info from runtime/debug.BuildInfo. Instead of directly using runtime/debug.BuildInfo, we use our own BuildInfo type. That allows: for go1.17 or older versions, we can add GoVersion. for go1.18, we can drop MarshalText that prevents JSON encoding other languages and human can understand (golang/go#51026) For golang/go#49783 Change-Id: Ia5ab50ce1f5e6c3a912654834785ecea7f5034e2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/382274 Trust: Hyang-Ah Hana Kim <hyangah@gmail.com> Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-28internal/lsp/debug: improve readability of session optionsPontus Leitzler
I find the session options page in gopls debug a bit hard to read. This change aims to improve readability by: - Sorting non-default options first (and alphabetically by name) - Use bold text for option name - Hide the "current value" if it's string representation equals the default value's string representation Change-Id: I93606ae788b97e46dc1d3aff420bb58f4c4d9674 Reviewed-on: https://go-review.googlesource.com/c/tools/+/352130 Trust: Pontus Leitzler <leitzler@gmail.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2021-05-10internal/lsp/source/completion: avoid a panic in package completionRob Findley
For golang/vscode-go#1486 Change-Id: I48939224778155964712192faf5a437ee10cd2e1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/318370 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2021-05-10internal/lsp/debug: add a facility to track known bugsRob Findley
Sometimes users report issues related to edge cases in Gopls that aren't reproducible. In some of these cases, we end up guarding against conditions that shouldn't be possible, which is an unfortunately fragile solution. Add a new debug.Bug function to both annotate such branches as known bugs, and help find them when they reoccur. For now this just records them in the debug server, but in the future we could send the user a message to the effect of "hey, a known bug has occurred" for debug builds of gopls. Also included are some minor cosmetic fixes. Change-Id: I95df0caf2c81f430661cabd573ce8e338fa69934 Reviewed-on: https://go-review.googlesource.com/c/tools/+/318369 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2021-04-27internal/lsp/debug: splice in updated servers rather than overwriteRob Findley
Updating server info was racing with rendering debug templates, because the state mutex only guards the servers slice, not the values contained in that slice. Switch to splicing in updated server data, rather than updating in-place, to avoid the race. Change-Id: Ia69895b49cf3f961c58db8e6512ce8b1f5911fd3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/314169 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2021-04-26internal/lsp: add a command to start the debug serverRob Findley
The utility of the debug server is limited by the requirement to start gopls with the `-debug` flag and then look in the logs to see which port the debug server is bound to. This CL adds a new custom command `gopls.startDebugging` to start the debug server on demand if it isn't already running, and return its debug address. It also does some gymnastics to make this turn on debugging for any intermediate gopls forwarders, when using daemon mode. For golang/go#45518 Change-Id: I48a90088f96aca54f34f93bedbfe864515320f61 Reviewed-on: https://go-review.googlesource.com/c/tools/+/309409 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2021-01-22internal/lsp: display current diagnostics in the debug serverpjw
The change displays outstanding diagnostics on the Client page of the debug server. Very occasionally gopls displays incorrect diagnostics or diagnositics that won't go away. It is possible that providing more complete information will help us find the causes, at least when the debug server is running. Change-Id: I01f2bbbfeac86e7296f57f4a9aad8e1e658babfa Reviewed-on: https://go-review.googlesource.com/c/tools/+/285252 Run-TryBot: Peter Weinberger <pjw@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Peter Weinberger <pjw@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-24gopls/release: add a command to validate the gopls release processRebecca Stambler
The gopls release process has a number of steps which can be easily forgotten, but they are also easy enough to check. In the future, we can certainly automate this process further, but this basic program will validate that mistakes like golang/go#43256 are not made again in the future. Change-Id: I04641ae202bc6615f2e4c8810b5dab4885d37fd4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/279715 Trust: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-23internal/lsp/cache: fix some package event tagsRob Findley
Package.ID() is far more useful to tag on events, as it disambiguates multiple packages with the same path. Change-Id: I03fd69f64641eb17155ca72ed2ef19641b75f004 Reviewed-on: https://go-review.googlesource.com/c/tools/+/279722 Run-TryBot: Robert Findley <rfindley@google.com> Trust: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-12-22gopls/test: add type checking for debug server templatesPeter Weinbergr
When internal data structures in gopls changed, the templates driving the debug server failed because fields or methods they relied on had gone away. At some cost, this change adds tests that all the fields and methods in the templates can be satisfied. The test assumes that all the template uses are through render() in debug/serve.go. It checks that is list of templates is the same as the server's, and then type checks each template. The costs are 1. the template type checking is done by a new external dependency, github.com/jba/templatecheck 2. To avoid adding a new dependency to x/tools, the test is in the gopls module, not the debug package, so variables from the debug package have to be exported In an ideal world the debug package, and much of internal/lsp, would be in the gopls package. In that case the cost 2 about could be avoided. In an ideal world, the core runtime template packages would contain template checking code, and cost 1 would be unnecessary. In a more likely (or not so distant) world, perhaps jba would move (or allow us to move) the template check package into x/tools. Change-Id: I36b509a00cbdcb5323ee1af3c1193b603c7a907f Reviewed-on: https://go-review.googlesource.com/c/tools/+/277292 Run-TryBot: Peter Weinberger <pjw@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> Trust: Peter Weinberger <pjw@google.com>
2020-12-11internal/lsp/debug: hook runtime/trace into event spansRob Findley
Existing spans defined within gopls are leveraged to add runtime/trace tasks, regions, and logging. This made it easier to understand gopls' execution, though we still have relatively sparse logging (arguably because we're conscious of the fact that logs are reflected back to the LSP client). Add a new log package with the concept of log level to facilitate excluding trace logs from the LSP. Add a little bit of additional instrumentation to demonstrate the usage of the new package. Change-Id: Id337be806484201103e30bfe2c8c62c7d7c363c7 Reviewed-on: https://go-review.googlesource.com/c/tools/+/275252 Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Trust: Robert Findley <rfindley@google.com>
2020-12-10internal/lsp/debug: show Options in gopls debug serverPeter Weinbergr
Provide both the current values and default values of Options. These are in the Sessions tabs. Display in the debug server, including the Options, needs work. Change-Id: I970fa65631702b79f6e5f8089a5b1cc5daa8334e Reviewed-on: https://go-review.googlesource.com/c/tools/+/275540 Trust: Peter Weinberger <pjw@google.com> Run-TryBot: Peter Weinberger <pjw@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-11-16internal/lsp: get debug pages limping along againPeter Weinbergr
Changes to the cache data structure broke the templates displaying information in the debug server. This CL makes small changes to get the pages working again. it adds a link to the command line on the Info page. More work is needed. For instance, only the memory page refreshes automatically; options could be displayed; information about diagnostics could be displayed, as could be information about modules, and no doubt there's more. I'm working on a test to typecheck the templates. Fixes golang/go#41343 Change-Id: I98538a8673de1a9589d09660eab47ad04eb2cc14 Reviewed-on: https://go-review.googlesource.com/c/tools/+/270099 Run-TryBot: Peter Weinberger <pjw@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Trust: Peter Weinberger <pjw@google.com>
2020-11-13internal/lsp: make log message for debug server clickablePeter Weinbergr
When the debug server by -debug=localhost:0, a log message says on which port to find the server. The new message gives a full URL for the debug server. Change-Id: I08fcaacbaf8de3591fce7854e373ba7d58931470 Reviewed-on: https://go-review.googlesource.com/c/tools/+/269921 Run-TryBot: Peter Weinberger <pjw@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Trust: Peter Weinberger <pjw@google.com>
2020-11-09internal/lsp: use a structured format for the server's versionRebecca Stambler
The server reports its version to the client--add some structure to this report so that the client can parse and use it. Fixes golang/go#42171 Change-Id: I00bff3615391cbeede89e4be6b0d028fed67989e Reviewed-on: https://go-review.googlesource.com/c/tools/+/266198 Trust: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-09-30internal/lsp: print the go version only once the view is createdRebecca Stambler
Printing the Go version without the session's go command runner means that we may not find the right Go version. Also, panicking when we cannot find a go command is not useful to the user--show the error as a view initialization error instead. Fixes golang/go#41701 Change-Id: I0e0753da9795b1c78331db1faecd27c2bfcee9b4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/258312 Trust: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-08-27internal/lsp: fix builds and tests for go1.12+Rob Findley
Seems we've drifted a bit from go1.12 support, mostly due to error wrapping. Fix this, as well as some assorted other failures. I haven't tested 1.12 interactively. For golang/go#39146 Change-Id: Id347ead2a13e89b76d2ae0047750e6b6b49911eb Reviewed-on: https://go-review.googlesource.com/c/tools/+/250941 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-08-03internal/lsp: separate LSP files from FS filesHeschi Kreinick
FileHandle currently includes LSP-level information about Version and Session. That's dangerous, because the cache operates in terms of URIs and content only -- we explicitly want to share results across sessions and versions if they happen to be the same. Split the LSP information into separate types, VersionedFileHandle and VersionedFileIdentity. Change-Id: I158646b783375b58245468599301e2a29c657e71 Reviewed-on: https://go-review.googlesource.com/c/tools/+/245058 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-07-16internal/lsp/lsprpc: improvements to daemon loggingRob Findley
The gopls daemon had different default logging behavior than the sidecar gopls: by default, the daemon was started with -logfile=auto. Additionally, because most logs are reflected back to the forwarder, the actual daemon logs have very little (if any) information. This means that if you simply start gopls with -remote=auto, you'll get a single logfile named /tmp/gopls-<pid>.log, which is mostly empty. This is not a delightful experience. Fix this via several improvements: + Log lifecycle events in the Daemon, to give the log a purpose. + Give the daemon a new default log location: /tmp/gopls-daemon-<pid>.log. + Don't pass -logfile=auto to the daemon by default. Fixes golang/go#40105 Change-Id: I5e91ea98b4968c512bce76a596bbae441f461a66 Reviewed-on: https://go-review.googlesource.com/c/tools/+/241440 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-06-19internal/lsp/debug: save per-package stats in memory debug filesHeschi Kreinick
The per-package stats have proven pretty useful, and I don't want to have to teach users how to save them. Create zip files and add them in. Since some users may be sensitive about revealing any information about the code, generate two variants: one with package names, and one without. Change-Id: Icc5631b4cebbbabfdd2fcea4a4cdf4f205dbcab9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/239037 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
2020-06-12internal/lsp/debug: show per-package memory usageHeschi Kreinick
Calculate and display very crude memory usage statistics. This is complicated by various levels of sharing and indirection, so the numbers should be taken with *large* grains of salt and interpreted mostly by experts. Still, the results are interesting and helpful. Change-Id: Ia9aff974c7d5fddd63df0cfd5cecc08ead33cf84 Reviewed-on: https://go-review.googlesource.com/c/tools/+/236163 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-06-12internal/lsp: fix the cache debug pageIan Cottrell
The cache does not know the sessions associated with it, so the debug template cannot display them. Change-Id: I9b043592351ddce097f4e74f3e9aa7a6ad24e613 Reviewed-on: https://go-review.googlesource.com/c/tools/+/237618 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
2020-06-11internal/lsp: decouple client and server debugIan Cottrell
This uses log messages to convey information to the debug system, which has the benefit of logging even if the debug pages are not active and also not requiring systems to reach into the debug system or require extra lifetime tracking Not all things are decoupled yet as there are a couple of places (notably the handshaker) that read information out of the debug system. Change-Id: Iec1f81c34ab3b11b3e3d6e6eb39b98ee5ed0d849 Reviewed-on: https://go-review.googlesource.com/c/tools/+/236337 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-06-06internal/lsp: minor cleanup of the client and server debugIan Cottrell
This removes the interfaces and the debug structs in the lsprpc package in favour of just having the debug structs in the debug package. Change-Id: I67541688444f4ef367007740c5446dcd7be6575f Reviewed-on: https://go-review.googlesource.com/c/tools/+/236198 Reviewed-by: Robert Findley <rfindley@google.com>
2020-06-06internal/lsp: clean out the debug handlingIan Cottrell
This removes all the cache/session/view hooks from the lsp and instead uses normal introspection from the client to find all the entities rather than keeping shadow copies of the object graph in the debug page handler. This required the addition only of the ability to view the sessions open on a cache and exposing the unique identifier for all the objects, both of which are useful and reasonable things to have in the API anyway. Change-Id: Ic19903e7b19832ca79290954ec373d4177789742 Reviewed-on: https://go-review.googlesource.com/c/tools/+/236197 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-05-30internal/lsp: fix typo in code commentyuichi kishimoto
Change-Id: I1120517383d0d3d314984ae7ba49cafbee34820d GitHub-Last-Rev: ed8df77aaa108ef079340718685727f413f2e9d5 GitHub-Pull-Request: golang/tools#230 Reviewed-on: https://go-review.googlesource.com/c/tools/+/235837 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-05-11internal/event: improve the logging of eventsIan Cottrell
This extracts the printing code from the log writer so it can be re-used and then changes the loggers in the lsp to use it. This means that messages that used to look like date: message=text now print as date: text which makes the logs a lot easier to read. Change-Id: I9dfbae47cdc9aeb7d3ca3279e445f39f2e590827 Reviewed-on: https://go-review.googlesource.com/c/tools/+/232989 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-05-04internal/lsp: use %w in error wrappersIan Cottrell
This fixes a bunch of fmt.Errorf calls to use %w rather than %v when wrapping an error with additional context. Change-Id: I03088376fbf89aa537555e825e5d02544d813ed2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/231477 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2020-04-27internal/event: remove the event.eventType typeIan Cottrell
Instead of tagging events with their type, instead we infer the type from the label pattern. The standard event creators all have a matching test that returns true if the the labels pattern matches the ones that would be built by the creator. Spans and logs already have a unique label pattern, other event types required a special label marker. This makes the system much more extensible, and also cleans up some the API. Change-Id: I1fbc9ec07aa84ead6c12bbd5ca65b13b605bfa4a Reviewed-on: https://go-review.googlesource.com/c/tools/+/229242 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-23internal/event: change event.At to be a private fieldIan Cottrell
This was the last piece of Event that was public, and it was only public to allow mutation in tests. Adding CloneEvent allows tests to create an updated copy rather than update the event in place. Change-Id: I2215d1eb0317063948ef0fac955fa768a209564d Reviewed-on: https://go-review.googlesource.com/c/tools/+/229241 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-04-23internal/event: extract keys to their own packageIan Cottrell
Now key types can be implemented outside the package that holds labels or events, they should be. This prevents the large list of types from poluting the public interface of the core packages. Change-Id: I927f31cb5e4e1d0c29619681015962f890623e5c Reviewed-on: https://go-review.googlesource.com/c/tools/+/229240 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
2020-04-23internal/event: move event/core.Tag to event/label.LabelIan Cottrell
Also moves core.Key to label.Key, but leaves the implementations behind for now. After using for a while, the word Tag conveys slightly the wrong concept, tagging implies the entire set of information, label maps better to a single named piece of information. A label is just a named key/value pair, it is not really tied to the event package, separating it makes it much easier to understand the public symbols of the event and core packages, and allows us to also move the key implementations somewhere else, which otherwise dominate the API. Change-Id: I46275d531cec91e28af6ab1e74a2713505d52533 Reviewed-on: https://go-review.googlesource.com/c/tools/+/229239 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23internal/event: renaming the main event API functionsIan Cottrell
event.Log removed event.Print -> event.Log event.Record -> event.Metric event.StartSpan -> event.Start In order to support this core now exposes the MakeEvent and Export functions. Change-Id: Ic7550d88dbf400e32c419adbb61d1546c471841e Reviewed-on: https://go-review.googlesource.com/c/tools/+/229238 Reviewed-by: Robert Findley <rfindley@google.com>
2020-04-23internal/telemetry: renaming to internal/eventIan Cottrell
internal/telemetry/event was renamed to internal/event/core Some things were partly moved from internal/telemetry/event straight to internal/event to minimize churn in the following restructuring. Change-Id: I8511241c68d2d05f64c52dbe04748086dd325158 Reviewed-on: https://go-review.googlesource.com/c/tools/+/229237 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-04-08internal/lsp: make tag iteration allocation-freeIan Cottrell
Change the tag iteration api to something less flexible that allows for event iteration without allocation. Change-Id: I212d45ebceea0183d1a61e6b611e0558649be60a Reviewed-on: https://go-review.googlesource.com/c/tools/+/227301 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-08internal/lsp/cache: add concurrency error check for go cmdsRohan Challa
This change attempts to fix a concurrency error that would cause textDocument/CodeLens, textDocument/Formatting, textDocument/DocumentLink, and textDocument/Hover from failing on go.mod files. The issue was that the go command would return a potential concurrency error since the ModHandle and the ModTidyHandle are both using the temporary go.mod file. Updates golang/go#37824 Change-Id: I6cd63c1f75817c7308e033aec473966536a2a3bd Reviewed-on: https://go-review.googlesource.com/c/tools/+/224917 Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-06internal/lsp: make event directly implement TagMapIan Cottrell
Makes Event implement TagMap directly, instead of having to build an entirely new object. Change-Id: I0c1e8638de3dc3347f60fd93af3df6b7f8387751 Reviewed-on: https://go-review.googlesource.com/c/tools/+/227300 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-06internal/lsp: rewrite the rpc debug pageIan Cottrell
Now it only uses the telemetry messages directly rather than the metric system. This is much faster and more direct, and removes a blocker on improving the metrics support. Also fixes the fact that recieced and sent were the wrong way round before, probably as an artifact of the old protocol logging code, and also removes the bytes histogram which was a lie (it was a histogram of write sizes that was presented as a histogram of message sizes) fixes golang/go#38168 Change-Id: Ib1c3459c0ff1cf0c6087a828981e80c1ce1c5c1b Reviewed-on: https://go-review.googlesource.com/c/tools/+/227139 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
2020-04-03internal/lsp, go/packages: don't log context cancellation errorsRebecca Stambler
Instead of checking the context, check the error. This may expose some errors that are not wrapped correctly. Replaced all uses of errors with golang.org/x/xerrors. Change-Id: Ia40160f8ea352e02618765f2a9415a4ece0dcd94 Reviewed-on: https://go-review.googlesource.com/c/tools/+/227036 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-31internal/lsp: rewrite the stats using the newer telemetry featuresIan Cottrell
This allows us to reduce the handler interface and delete the telemetry handler. It is also safer and faster, and can be easily disabled along with the rest of the telemetry system. Change-Id: Ia4961d7f2e374f7dc22360d6a4020a065bfeae6f Reviewed-on: https://go-review.googlesource.com/c/tools/+/225957 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-30internal/telemetry: add a synchronization to telemetryIan Cottrell
Some things that used to be safe due to the global lock now need ther own synchronization primitives. Fixes golang/go#38102 Change-Id: I03c692682d57620d96fe84b7dc74efae0d3f8f09 Reviewed-on: https://go-review.googlesource.com/c/tools/+/226317 Run-TryBot: Ian Cottrell <iancottrell@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-29internal/telemetry: use tags instead of special event fields.Ian Cottrell
Change-Id: I0e6a26c62bd1f6eaa07c38a06152cb7a0f2eedc2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/225579 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-26internal/telemetry: render trace tags using typed keysIan Cottrell
Type switch on the key and use it to get the value and decide how to render it. Use the same render for all debug tag printing. Change-Id: Ia305fded7dcf05b57c5805f48bb5c22fa7def71f Reviewed-on: https://go-review.googlesource.com/c/tools/+/225380 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-26internal/telemetry: make metrics take a strongly typed keyIan Cottrell
Now that keys are solidly typed, we can use them for the metrics. This prevents accidentally using the wrong type of key, and allows us to use the typed accesorrs rather than the raw value. Change-Id: I553bd8e12128d3f00a3e926dbd3bfd420cd3f135 Reviewed-on: https://go-review.googlesource.com/c/tools/+/225378 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-25internal/telemetry: replace TagSet with TagMap and TagPointerIan Cottrell
This separates the concerns of tag collections that have to be iterated and tag collections that need lookup by key. Also make it so that events just carry a plain slice of tags. We pass a TagMap down through the exporters and allow it to be extended on the way. We no longer need the event.Query method (or the event type) We now exclusivley use Key as the identity, and no longer have a common core implementation but just implement it directly in each type. This removes some confusion that was causing the same key through different paths to end up with a different identity. Change-Id: I61e47adcb397f4ca83dd90342b021dd8e9571ed3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/224278 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-25internal/telemetry: change Exporter to be a function type.Ian Cottrell
Change-Id: Id410da20310baf4da6875de08e4449c7a6fb0250 Reviewed-on: https://go-review.googlesource.com/c/tools/+/224277 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-24internal/lsp: print view-specific environmentRebecca Stambler
For debugging purposes, we print the output of `go env` on start. Now, we print a view-specific `go env`, which will helps us when debugging multi-project workspaces. Additional information included: the folder of the view, if the view has a valid build configuration, and the build flags for the view. Updates golang/go#37978 Change-Id: Iadffd46f8ac5410971558a304b8bbcb2f9bdbcc3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/225137 Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-03-23internal/telemetry: switch metrics to use the event systemIan Cottrell
Change-Id: If036530ffe47e7df925bcf6592f664d6020a3d65 Reviewed-on: https://go-review.googlesource.com/c/tools/+/223997 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-23internal/telemetry: replace event.TagList with event.TagSetIan Cottrell
This allows us to hide the implementation details of how tags are stored on a context from the normal interface, to allow us to explore more efficient mechanisms. The current storage is not intended as the most efficient choice, this cl is about isolating the API so we can experiment with benchmarks in the future. Change-Id: Ib101416bccd8ecdee269cee636b1564d51e1da8a Reviewed-on: https://go-review.googlesource.com/c/tools/+/222854 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-19internal/lsp: fix errors found by staticcheckRob Findley
While experimenting with different static analysis on x/tools, I noticed that there are many actionable diagnostics found by staticcheck. Fix the ones that were not false positives. Change-Id: I0b68cf1f636b57b557db879fad84fff9b7237a89 Reviewed-on: https://go-review.googlesource.com/c/tools/+/222248 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>