mirror of
https://github.com/golang/go
synced 2024-11-18 15:04:44 -07:00
internal/lsp: extra telemetry tagging of files and packages
Change-Id: Ia9a8fb5dcfb74e86b9366849810dd3edc1f898dd Reviewed-on: https://go-review.googlesource.com/c/tools/+/186918 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
dddb761723
commit
c001e47e7f
2
internal/lsp/cache/check.go
vendored
2
internal/lsp/cache/check.go
vendored
@ -95,7 +95,7 @@ func (imp *importer) getPkg(ctx context.Context, id packageID) (*pkg, error) {
|
||||
}
|
||||
|
||||
func (imp *importer) typeCheck(ctx context.Context, id packageID) (*pkg, error) {
|
||||
ctx, done := trace.StartSpan(ctx, "cache.importer.typeCheck")
|
||||
ctx, done := trace.StartSpan(ctx, "cache.importer.typeCheck", telemetry.Package.Of(id))
|
||||
defer done()
|
||||
meta, ok := imp.view.mcache.packages[id]
|
||||
if !ok {
|
||||
|
3
internal/lsp/cache/external.go
vendored
3
internal/lsp/cache/external.go
vendored
@ -10,6 +10,7 @@ import (
|
||||
"os"
|
||||
|
||||
"golang.org/x/tools/internal/lsp/source"
|
||||
"golang.org/x/tools/internal/lsp/telemetry"
|
||||
"golang.org/x/tools/internal/lsp/telemetry/trace"
|
||||
"golang.org/x/tools/internal/span"
|
||||
)
|
||||
@ -51,7 +52,7 @@ func (h *nativeFileHandle) Kind() source.FileKind {
|
||||
}
|
||||
|
||||
func (h *nativeFileHandle) Read(ctx context.Context) ([]byte, string, error) {
|
||||
ctx, done := trace.StartSpan(ctx, "cache.nativeFileHandle.Read")
|
||||
ctx, done := trace.StartSpan(ctx, "cache.nativeFileHandle.Read", telemetry.File.Of(h.identity.URI.Filename()))
|
||||
defer done()
|
||||
//TODO: this should fail if the version is not the same as the handle
|
||||
data, err := ioutil.ReadFile(h.identity.URI.Filename())
|
||||
|
3
internal/lsp/cache/load.go
vendored
3
internal/lsp/cache/load.go
vendored
@ -13,6 +13,7 @@ import (
|
||||
"golang.org/x/tools/internal/lsp/telemetry"
|
||||
"golang.org/x/tools/internal/lsp/telemetry/log"
|
||||
"golang.org/x/tools/internal/lsp/telemetry/tag"
|
||||
"golang.org/x/tools/internal/lsp/telemetry/trace"
|
||||
"golang.org/x/tools/internal/span"
|
||||
)
|
||||
|
||||
@ -87,6 +88,8 @@ func (v *view) checkMetadata(ctx context.Context, f *goFile) (map[packageID]*met
|
||||
return nil, nil, ctx.Err()
|
||||
}
|
||||
|
||||
ctx, done := trace.StartSpan(ctx, "packages.Load", telemetry.File.Of(f.filename()))
|
||||
defer done()
|
||||
pkgs, err := packages.Load(v.Config(ctx), fmt.Sprintf("file=%s", f.filename()))
|
||||
if len(pkgs) == 0 {
|
||||
if err == nil {
|
||||
|
3
internal/lsp/cache/parse.go
vendored
3
internal/lsp/cache/parse.go
vendored
@ -13,6 +13,7 @@ import (
|
||||
"go/token"
|
||||
|
||||
"golang.org/x/tools/internal/lsp/source"
|
||||
"golang.org/x/tools/internal/lsp/telemetry"
|
||||
"golang.org/x/tools/internal/lsp/telemetry/trace"
|
||||
"golang.org/x/tools/internal/memoize"
|
||||
)
|
||||
@ -74,7 +75,7 @@ func (h *parseGoHandle) Parse(ctx context.Context) (*ast.File, error) {
|
||||
}
|
||||
|
||||
func parseGo(ctx context.Context, c *cache, fh source.FileHandle, mode source.ParseMode) (*ast.File, error) {
|
||||
ctx, done := trace.StartSpan(ctx, "cache.parseGo")
|
||||
ctx, done := trace.StartSpan(ctx, "cache.parseGo", telemetry.File.Of(fh.Identity().URI.Filename()))
|
||||
defer done()
|
||||
buf, _, err := fh.Read(ctx)
|
||||
if err != nil {
|
||||
|
@ -124,12 +124,13 @@ type handler struct {
|
||||
}
|
||||
|
||||
type rpcStats struct {
|
||||
method string
|
||||
direction jsonrpc2.Direction
|
||||
id *jsonrpc2.ID
|
||||
payload *json.RawMessage
|
||||
start time.Time
|
||||
close func()
|
||||
method string
|
||||
direction jsonrpc2.Direction
|
||||
id *jsonrpc2.ID
|
||||
payload *json.RawMessage
|
||||
start time.Time
|
||||
delivering func()
|
||||
close func()
|
||||
}
|
||||
|
||||
type statsKeyType int
|
||||
@ -137,6 +138,10 @@ type statsKeyType int
|
||||
const statsKey = statsKeyType(0)
|
||||
|
||||
func (h *handler) Deliver(ctx context.Context, r *jsonrpc2.Request, delivered bool) bool {
|
||||
stats := h.getStats(ctx)
|
||||
if stats != nil {
|
||||
stats.delivering()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@ -165,6 +170,7 @@ func (h *handler) Request(ctx context.Context, direction jsonrpc2.Direction, r *
|
||||
tag.Tag{Key: telemetry.RPCID, Value: r.ID},
|
||||
)
|
||||
telemetry.Started.Record(ctx, 1)
|
||||
_, stats.delivering = trace.StartSpan(ctx, "queued")
|
||||
return ctx
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ import (
|
||||
"golang.org/x/tools/go/packages"
|
||||
"golang.org/x/tools/internal/lsp/telemetry"
|
||||
"golang.org/x/tools/internal/lsp/telemetry/log"
|
||||
"golang.org/x/tools/internal/lsp/telemetry/trace"
|
||||
"golang.org/x/tools/internal/span"
|
||||
)
|
||||
|
||||
@ -61,7 +62,8 @@ const (
|
||||
)
|
||||
|
||||
func Diagnostics(ctx context.Context, view View, f GoFile, disabledAnalyses map[string]struct{}) (map[span.URI][]Diagnostic, error) {
|
||||
ctx = telemetry.File.With(ctx, f.URI())
|
||||
ctx, done := trace.StartSpan(ctx, "source.Diagnostics", telemetry.File.Of(f.URI()))
|
||||
defer done()
|
||||
pkg := f.GetPackage(ctx)
|
||||
if pkg == nil {
|
||||
return singleDiagnostic(f.URI(), "%s is not part of a package", f.URI()), nil
|
||||
@ -107,6 +109,8 @@ type diagnosticSet struct {
|
||||
}
|
||||
|
||||
func diagnostics(ctx context.Context, v View, pkg Package, reports map[span.URI][]Diagnostic) bool {
|
||||
ctx, done := trace.StartSpan(ctx, "source.diagnostics", telemetry.Package.Of(pkg.ID()))
|
||||
defer done()
|
||||
diagSets := make(map[span.URI]*diagnosticSet)
|
||||
for _, err := range pkg.GetErrors() {
|
||||
diag := Diagnostic{
|
||||
|
Loading…
Reference in New Issue
Block a user