diff options
author | Ian Cottrell <iancottrell@google.com> | 2020-04-20 12:14:12 -0400 |
---|---|---|
committer | Ian Cottrell <iancottrell@google.com> | 2020-04-23 17:21:36 +0000 |
commit | 7b212d60a147f93d1af51bcc1a27181ba1f3f9f6 (patch) | |
tree | f757e6314724539a672abff9021d20735827b7d9 | |
parent | cf0cb92717bed0570dd0d024d51a0e39e1b2dd64 (diff) | |
download | golang-x-tools-7b212d60a147f93d1af51bcc1a27181ba1f3f9f6.tar.gz |
internal/event: renaming the main event API functions
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>
48 files changed, 153 insertions, 264 deletions
diff --git a/internal/event/bench_test.go b/internal/event/bench_test.go index f4fc72759..8db24e6ec 100644 --- a/internal/event/bench_test.go +++ b/internal/event/bench_test.go @@ -46,33 +46,33 @@ var ( Log = Hooks{ A: func(ctx context.Context, a int) (context.Context, func()) { - core.Print1(ctx, "A", aValue.Of(a)) + core.Log1(ctx, "A", aValue.Of(a)) return ctx, func() {} }, B: func(ctx context.Context, b string) (context.Context, func()) { - core.Print1(ctx, "B", bValue.Of(b)) + core.Log1(ctx, "B", bValue.Of(b)) return ctx, func() {} }, } Trace = Hooks{ A: func(ctx context.Context, a int) (context.Context, func()) { - return core.StartSpan1(ctx, "A", aValue.Of(a)) + return core.Start1(ctx, "A", aValue.Of(a)) }, B: func(ctx context.Context, b string) (context.Context, func()) { - return core.StartSpan1(ctx, "B", bValue.Of(b)) + return core.Start1(ctx, "B", bValue.Of(b)) }, } Stats = Hooks{ A: func(ctx context.Context, a int) (context.Context, func()) { - core.Record1(ctx, aStat.Of(a)) - core.Record1(ctx, aCount.Of(1)) + core.Metric1(ctx, aStat.Of(a)) + core.Metric1(ctx, aCount.Of(1)) return ctx, func() {} }, B: func(ctx context.Context, b string) (context.Context, func()) { - core.Record1(ctx, bLength.Of(len(b))) - core.Record1(ctx, bCount.Of(1)) + core.Metric1(ctx, bLength.Of(len(b))) + core.Metric1(ctx, bCount.Of(1)) return ctx, func() {} }, } diff --git a/internal/event/core/event.go b/internal/event/core/event.go index ef7276453..109456c38 100644 --- a/internal/event/core/event.go +++ b/internal/event/core/event.go @@ -104,7 +104,7 @@ func (ev Event) Find(key Key) Tag { return Tag{} } -func makeEvent(typ eventType, static sTags, tags []Tag) Event { +func MakeEvent(typ eventType, static [3]Tag, tags []Tag) Event { return Event{ typ: typ, static: static, diff --git a/internal/event/core/export.go b/internal/event/core/export.go index e4a914106..89783f31a 100644 --- a/internal/event/core/export.go +++ b/internal/event/core/export.go @@ -43,8 +43,8 @@ func deliver(ctx context.Context, exporter Exporter, ev Event) context.Context { return exporter(ctx, ev, ev) } -// dispatch is called to deliver an event to the global exporter if set. -func dispatch(ctx context.Context, ev Event) context.Context { +// Export is called to deliver an event to the global exporter if set. +func Export(ctx context.Context, ev Event) context.Context { // get the global exporter and abort early if there is not one exporterPtr := (*Exporter)(atomic.LoadPointer(&exporter)) if exporterPtr == nil { @@ -53,11 +53,11 @@ func dispatch(ctx context.Context, ev Event) context.Context { return deliver(ctx, *exporterPtr, ev) } -// dispatchPair is called to deliver a start event to the supplied exporter. +// ExportPair is called to deliver a start event to the supplied exporter. // It also returns a function that will deliver the end event to the same // exporter. // it will fill in the time and generate the basic tag source. -func dispatchPair(ctx context.Context, begin, end Event) (context.Context, func()) { +func ExportPair(ctx context.Context, begin, end Event) (context.Context, func()) { // get the global exporter and abort early if there is not one exporterPtr := (*Exporter)(atomic.LoadPointer(&exporter)) if exporterPtr == nil { diff --git a/internal/event/core/fast.go b/internal/event/core/fast.go new file mode 100644 index 000000000..427bec3df --- /dev/null +++ b/internal/event/core/fast.go @@ -0,0 +1,54 @@ +// Copyright 2019 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 core + +import ( + "context" +) + +// Log1 takes a message and one tag delivers a log event to the exporter. +// It is a customized version of Print that is faster and does no allocation. +func Log1(ctx context.Context, message string, t1 Tag) { + Export(ctx, MakeEvent(LogType, sTags{Msg.Of(message), t1}, nil)) +} + +// Log2 takes a message and two tags and delivers a log event to the exporter. +// It is a customized version of Print that is faster and does no allocation. +func Log2(ctx context.Context, message string, t1 Tag, t2 Tag) { + Export(ctx, MakeEvent(LogType, sTags{Msg.Of(message), t1, t2}, nil)) +} + +// Metric1 sends a label event to the exporter with the supplied tags. +func Metric1(ctx context.Context, t1 Tag) context.Context { + return Export(ctx, MakeEvent(RecordType, sTags{t1}, nil)) +} + +// Metric2 sends a label event to the exporter with the supplied tags. +func Metric2(ctx context.Context, t1, t2 Tag) context.Context { + return Export(ctx, MakeEvent(RecordType, sTags{t1, t2}, nil)) +} + +// Metric3 sends a label event to the exporter with the supplied tags. +func Metric3(ctx context.Context, t1, t2, t3 Tag) context.Context { + return Export(ctx, MakeEvent(RecordType, sTags{t1, t2, t3}, nil)) +} + +// Start1 sends a span start event with the supplied tag list to the exporter. +// It also returns a function that will end the span, which should normally be +// deferred. +func Start1(ctx context.Context, name string, t1 Tag) (context.Context, func()) { + return ExportPair(ctx, + MakeEvent(StartSpanType, sTags{Name.Of(name), t1}, nil), + MakeEvent(EndSpanType, sTags{}, nil)) +} + +// Start2 sends a span start event with the supplied tag list to the exporter. +// It also returns a function that will end the span, which should normally be +// deferred. +func Start2(ctx context.Context, name string, t1, t2 Tag) (context.Context, func()) { + return ExportPair(ctx, + MakeEvent(StartSpanType, sTags{Name.Of(name), t1, t2}, nil), + MakeEvent(EndSpanType, sTags{}, nil)) +} diff --git a/internal/event/core/label.go b/internal/event/core/label.go deleted file mode 100644 index 45725e7d0..000000000 --- a/internal/event/core/label.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019 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 core - -import ( - "context" -) - -// Label sends a label event to the exporter with the supplied tags. -func Label(ctx context.Context, tags ...Tag) context.Context { - return dispatch(ctx, makeEvent(LabelType, sTags{}, tags)) -} - -// Label1 sends a label event to the exporter with the supplied tags. -func Label1(ctx context.Context, t1 Tag) context.Context { - return dispatch(ctx, makeEvent(LabelType, sTags{t1}, nil)) -} - -// Label2 sends a label event to the exporter with the supplied tags. -func Label2(ctx context.Context, t1, t2 Tag) context.Context { - return dispatch(ctx, makeEvent(LabelType, sTags{t1, t2}, nil)) -} - -// Label3 sends a label event to the exporter with the supplied tags. -func Label3(ctx context.Context, t1, t2, t3 Tag) context.Context { - return dispatch(ctx, makeEvent(LabelType, sTags{t1, t2, t3}, nil)) -} diff --git a/internal/event/core/log.go b/internal/event/core/log.go deleted file mode 100644 index a6bdac82c..000000000 --- a/internal/event/core/log.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2019 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 core - -import ( - "context" - "errors" - "fmt" -) - -// Log sends a log event with the supplied tag list to the exporter. -func Log(ctx context.Context, tags ...Tag) { - dispatch(ctx, makeEvent(LogType, sTags{}, tags)) -} - -// Log1 sends a label event to the exporter with the supplied tags. -func Log1(ctx context.Context, t1 Tag) context.Context { - return dispatch(ctx, makeEvent(LogType, sTags{t1}, nil)) -} - -// Log2 sends a label event to the exporter with the supplied tags. -func Log2(ctx context.Context, t1, t2 Tag) context.Context { - return dispatch(ctx, makeEvent(LogType, sTags{t1, t2}, nil)) -} - -// Log3 sends a label event to the exporter with the supplied tags. -func Log3(ctx context.Context, t1, t2, t3 Tag) context.Context { - return dispatch(ctx, makeEvent(LogType, sTags{t1, t2, t3}, nil)) -} - -// Print takes a message and a tag list and combines them into a single event -// before delivering them to the exporter. -func Print(ctx context.Context, message string, tags ...Tag) { - dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message)}, tags)) -} - -// Print1 takes a message and one tag delivers a log event to the exporter. -// It is a customized version of Print that is faster and does no allocation. -func Print1(ctx context.Context, message string, t1 Tag) { - dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message), t1}, nil)) -} - -// Print2 takes a message and two tags and delivers a log event to the exporter. -// It is a customized version of Print that is faster and does no allocation. -func Print2(ctx context.Context, message string, t1 Tag, t2 Tag) { - dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message), t1, t2}, nil)) -} - -// Error takes a message and a tag list and combines them into a single event -// before delivering them to the exporter. It captures the error in the -// delivered event. -func Error(ctx context.Context, message string, err error, tags ...Tag) { - if err == nil { - err = errors.New(message) - message = "" - } - dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(message), Err.Of(err)}, tags)) -} - -// Debugf sends a log event with the supplied message to the exporter. -// This is intended only for temporary debugging lines, and usage should not -// normally be checked in, preffering structured log events for things -// that have to be used in production. -func Debugf(ctx context.Context, message string, args ...interface{}) { - dispatch(ctx, makeEvent(LogType, sTags{Msg.Of(fmt.Sprintf(message, args...))}, nil)) -} diff --git a/internal/event/core/metric.go b/internal/event/core/metric.go deleted file mode 100644 index c75f79b18..000000000 --- a/internal/event/core/metric.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2019 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 core - -import ( - "context" -) - -// Record sends a label event to the exporter with the supplied tags. -func Record(ctx context.Context, tags ...Tag) context.Context { - return dispatch(ctx, makeEvent(RecordType, sTags{}, tags)) -} - -// Record1 sends a label event to the exporter with the supplied tags. -func Record1(ctx context.Context, t1 Tag) context.Context { - return dispatch(ctx, makeEvent(RecordType, sTags{t1}, nil)) -} - -// Record2 sends a label event to the exporter with the supplied tags. -func Record2(ctx context.Context, t1, t2 Tag) context.Context { - return dispatch(ctx, makeEvent(RecordType, sTags{t1, t2}, nil)) -} - -// Record3 sends a label event to the exporter with the supplied tags. -func Record3(ctx context.Context, t1, t2, t3 Tag) context.Context { - return dispatch(ctx, makeEvent(RecordType, sTags{t1, t2, t3}, nil)) -} diff --git a/internal/event/core/trace.go b/internal/event/core/trace.go deleted file mode 100644 index 96354c50e..000000000 --- a/internal/event/core/trace.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2019 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 core - -import ( - "context" -) - -// StartSpan sends a span start event with the supplied tag list to the exporter. -// It also returns a function that will end the span, which should normally be -// deferred. -func StartSpan(ctx context.Context, name string, tags ...Tag) (context.Context, func()) { - return dispatchPair(ctx, - makeEvent(StartSpanType, sTags{Name.Of(name)}, tags), - makeEvent(EndSpanType, sTags{}, nil)) -} - -// StartSpan1 sends a span start event with the supplied tag list to the exporter. -// It also returns a function that will end the span, which should normally be -// deferred. -func StartSpan1(ctx context.Context, name string, t1 Tag) (context.Context, func()) { - return dispatchPair(ctx, - makeEvent(StartSpanType, sTags{Name.Of(name), t1}, nil), - makeEvent(EndSpanType, sTags{}, nil)) -} - -// StartSpan2 sends a span start event with the supplied tag list to the exporter. -// It also returns a function that will end the span, which should normally be -// deferred. -func StartSpan2(ctx context.Context, name string, t1, t2 Tag) (context.Context, func()) { - return dispatchPair(ctx, - makeEvent(StartSpanType, sTags{Name.Of(name), t1, t2}, nil), - makeEvent(EndSpanType, sTags{}, nil)) -} - -// Detach returns a context without an associated span. -// This allows the creation of spans that are not children of the current span. -func Detach(ctx context.Context) context.Context { - return dispatch(ctx, makeEvent(DetachType, sTags{}, nil)) -} diff --git a/internal/event/event.go b/internal/event/event.go index bb950f647..4ae08b38d 100644 --- a/internal/event/event.go +++ b/internal/event/event.go @@ -21,43 +21,45 @@ func SetExporter(e Exporter) { core.SetExporter(core.Exporter(e)) } -// Log sends a log event with the supplied tag list to the exporter. -func Log(ctx context.Context, tags ...core.Tag) { - core.Log(ctx, tags...) -} - -// Print takes a message and a tag list and combines them into a single event +// Log takes a message and a tag list and combines them into a single event // before delivering them to the exporter. -func Print(ctx context.Context, message string, tags ...core.Tag) { - core.Print(ctx, message, tags...) +func Log(ctx context.Context, message string, tags ...core.Tag) { + core.Export(ctx, core.MakeEvent(core.LogType, [3]core.Tag{ + core.Msg.Of(message), + }, tags)) } // Error takes a message and a tag list and combines them into a single event // before delivering them to the exporter. It captures the error in the // delivered event. func Error(ctx context.Context, message string, err error, tags ...core.Tag) { - core.Error(ctx, message, err, tags...) + core.Export(ctx, core.MakeEvent(core.LogType, [3]core.Tag{ + core.Msg.Of(message), + core.Err.Of(err), + }, tags)) } -// Record sends a label event to the exporter with the supplied tags. -func Record(ctx context.Context, tags ...core.Tag) context.Context { - return core.Record(ctx, tags...) +// Metric sends a label event to the exporter with the supplied tags. +func Metric(ctx context.Context, tags ...core.Tag) { + core.Export(ctx, core.MakeEvent(core.RecordType, [3]core.Tag{}, tags)) } // Label sends a label event to the exporter with the supplied tags. func Label(ctx context.Context, tags ...core.Tag) context.Context { - return core.Label(ctx, tags...) + return core.Export(ctx, core.MakeEvent(core.LabelType, [3]core.Tag{}, tags)) } -// StartSpan sends a span start event with the supplied tag list to the exporter. +// Start sends a span start event with the supplied tag list to the exporter. // It also returns a function that will end the span, which should normally be // deferred. -func StartSpan(ctx context.Context, name string, tags ...core.Tag) (context.Context, func()) { - return core.StartSpan(ctx, name, tags...) +func Start(ctx context.Context, name string, tags ...core.Tag) (context.Context, func()) { + return core.ExportPair(ctx, + core.MakeEvent(core.StartSpanType, [3]core.Tag{core.Name.Of(name)}, tags), + core.MakeEvent(core.EndSpanType, [3]core.Tag{}, nil)) } // Detach returns a context without an associated span. // This allows the creation of spans that are not children of the current span. func Detach(ctx context.Context) context.Context { - return core.Detach(ctx) + return core.Export(ctx, core.MakeEvent(core.DetachType, [3]core.Tag{}, nil)) } diff --git a/internal/event/export/log_test.go b/internal/event/export/log_test.go index 0864e9126..34029b644 100644 --- a/internal/event/export/log_test.go +++ b/internal/event/export/log_test.go @@ -20,7 +20,7 @@ func ExampleLog() { event.SetExporter(timeFixer(export.LogWriter(os.Stdout, false))) anInt := core.NewIntKey("myInt", "an integer") aString := core.NewStringKey("myString", "a string") - event.Print(ctx, "my event", anInt.Of(6)) + event.Log(ctx, "my event", anInt.Of(6)) event.Error(ctx, "error event", errors.New("an error"), aString.Of("some string value")) // Output: // 2020/03/05 14:27:48 my event diff --git a/internal/event/export/ocagent/metrics_test.go b/internal/event/export/ocagent/metrics_test.go index 84cec6c52..fde3334d3 100644 --- a/internal/event/export/ocagent/metrics_test.go +++ b/internal/event/export/ocagent/metrics_test.go @@ -23,9 +23,9 @@ func TestEncodeMetric(t *testing.T) { name: "HistogramFloat64, HistogramInt64", run: func(ctx context.Context) { ctx = event.Label(ctx, keyMethod.Of("godoc.ServeHTTP")) - event.Record(ctx, latencyMs.Of(96.58)) + event.Metric(ctx, latencyMs.Of(96.58)) ctx = event.Label(ctx, core.Err.Of(errors.New("panic: fatal signal"))) - event.Record(ctx, bytesIn.Of(97e2)) + event.Metric(ctx, bytesIn.Of(97e2)) }, want: prefix + ` { diff --git a/internal/event/export/ocagent/trace_test.go b/internal/event/export/ocagent/trace_test.go index 77df1d7d8..0f04bee4d 100644 --- a/internal/event/export/ocagent/trace_test.go +++ b/internal/event/export/ocagent/trace_test.go @@ -10,6 +10,7 @@ import ( "testing" "golang.org/x/tools/internal/event" + "golang.org/x/tools/internal/event/core" ) func TestTrace(t *testing.T) { @@ -38,7 +39,7 @@ func TestTrace(t *testing.T) { { name: "no tags", run: func(ctx context.Context) { - event.Log(ctx) + core.Export(ctx, core.MakeEvent(core.LogType, [3]core.Tag{}, nil)) }, want: prefix + ` "timeEvent":[{"time":"1970-01-01T00:00:40Z"}] @@ -47,7 +48,7 @@ func TestTrace(t *testing.T) { { name: "description no error", run: func(ctx context.Context) { - event.Print(ctx, "cache miss", keyDB.Of("godb")) + event.Log(ctx, "cache miss", keyDB.Of("godb")) }, want: prefix + `"timeEvent":[{"time":"1970-01-01T00:00:40Z","annotation":{ "description": { "value": "cache miss" }, @@ -97,7 +98,7 @@ func TestTrace(t *testing.T) { { name: "enumerate all attribute types", run: func(ctx context.Context) { - event.Print(ctx, "cache miss", + event.Log(ctx, "cache miss", key1DB.Of("godb"), key2aAge.Of(0.456), // Constant converted into "float64" @@ -148,7 +149,7 @@ func TestTrace(t *testing.T) { ctx := context.TODO() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - ctx, done := event.StartSpan(ctx, "event span") + ctx, done := event.Start(ctx, "event span") tt.run(ctx) done() got := exporter.Output("/v1/trace") diff --git a/internal/jsonrpc2/handler.go b/internal/jsonrpc2/handler.go index b861b1251..418bd6804 100644 --- a/internal/jsonrpc2/handler.go +++ b/internal/jsonrpc2/handler.go @@ -96,7 +96,7 @@ func AsyncHandler(handler Handler) Handler { close(unlockNext) return innerReply(ctx, result, err) } - _, queueDone := event.StartSpan(ctx, "queued") + _, queueDone := event.Start(ctx, "queued") go func() { <-waitForPrevious queueDone() diff --git a/internal/jsonrpc2/jsonrpc2.go b/internal/jsonrpc2/jsonrpc2.go index 5ee2c85a7..43cfccdb4 100644 --- a/internal/jsonrpc2/jsonrpc2.go +++ b/internal/jsonrpc2/jsonrpc2.go @@ -58,7 +58,7 @@ func (c *Conn) Notify(ctx context.Context, method string, params interface{}) (e if err != nil { return fmt.Errorf("marshaling notify parameters: %v", err) } - ctx, done := event.StartSpan(ctx, method, + ctx, done := event.Start(ctx, method, tag.Method.Of(method), tag.RPCDirection.Of(tag.Outbound), ) @@ -67,9 +67,9 @@ func (c *Conn) Notify(ctx context.Context, method string, params interface{}) (e done() }() - event.Record(ctx, tag.Started.Of(1)) + event.Metric(ctx, tag.Started.Of(1)) n, err := c.stream.Write(ctx, notify) - event.Record(ctx, tag.SentBytes.Of(n)) + event.Metric(ctx, tag.SentBytes.Of(n)) return err } @@ -83,7 +83,7 @@ func (c *Conn) Call(ctx context.Context, method string, params, result interface if err != nil { return id, fmt.Errorf("marshaling call parameters: %v", err) } - ctx, done := event.StartSpan(ctx, method, + ctx, done := event.Start(ctx, method, tag.Method.Of(method), tag.RPCDirection.Of(tag.Outbound), tag.RPCID.Of(fmt.Sprintf("%q", id)), @@ -92,7 +92,7 @@ func (c *Conn) Call(ctx context.Context, method string, params, result interface recordStatus(ctx, err) done() }() - event.Record(ctx, tag.Started.Of(1)) + event.Metric(ctx, tag.Started.Of(1)) // We have to add ourselves to the pending map before we send, otherwise we // are racing the response. Also add a buffer to rchan, so that if we get a // wire response between the time this call is cancelled and id is deleted @@ -108,7 +108,7 @@ func (c *Conn) Call(ctx context.Context, method string, params, result interface }() // now we are ready to send n, err := c.stream.Write(ctx, call) - event.Record(ctx, tag.SentBytes.Of(n)) + event.Metric(ctx, tag.SentBytes.Of(n)) if err != nil { // sending failed, we will never get a response, so don't leave it pending return id, err @@ -148,7 +148,7 @@ func replier(conn *Conn, req Request, spanDone func()) Replier { return err } n, err := conn.stream.Write(ctx, response) - event.Record(ctx, tag.SentBytes.Of(n)) + event.Metric(ctx, tag.SentBytes.Of(n)) if err != nil { // TODO(iancottrell): if a stream write fails, we really need to shut down // the whole stream @@ -183,8 +183,8 @@ func (c *Conn) Run(runCtx context.Context, handler Handler) error { } else { tags = tags[:len(tags)-1] } - reqCtx, spanDone := event.StartSpan(runCtx, msg.Method(), tags...) - event.Record(reqCtx, + reqCtx, spanDone := event.Start(runCtx, msg.Method(), tags...) + event.Metric(reqCtx, tag.Started.Of(1), tag.ReceivedBytes.Of(n)) if err := handler(reqCtx, replier(c, msg, spanDone), msg); err != nil { diff --git a/internal/lsp/cache/analysis.go b/internal/lsp/cache/analysis.go index 5868e7386..14d2bf63d 100644 --- a/internal/lsp/cache/analysis.go +++ b/internal/lsp/cache/analysis.go @@ -208,7 +208,7 @@ func runAnalysis(ctx context.Context, fset *token.FileSet, analyzer *analysis.An } defer func() { if r := recover(); r != nil { - event.Print(ctx, fmt.Sprintf("analysis panicked: %s", r), tag.Package.Of(pkg.PkgPath())) + event.Log(ctx, fmt.Sprintf("analysis panicked: %s", r), tag.Package.Of(pkg.PkgPath())) data.err = errors.Errorf("analysis %s for package %s panicked: %v", analyzer.Name, pkg.PkgPath(), r) } }() diff --git a/internal/lsp/cache/check.go b/internal/lsp/cache/check.go index bdde37e1e..4a8d3c2a3 100644 --- a/internal/lsp/cache/check.go +++ b/internal/lsp/cache/check.go @@ -262,7 +262,7 @@ func (s *snapshot) parseGoHandles(ctx context.Context, files []span.URI, mode so } func typeCheck(ctx context.Context, fset *token.FileSet, m *metadata, mode source.ParseMode, goFiles, compiledGoFiles []*parseGoHandle, deps map[packagePath]*packageHandle) (*pkg, error) { - ctx, done := event.StartSpan(ctx, "cache.importer.typeCheck", tag.Package.Of(string(m.id))) + ctx, done := event.Start(ctx, "cache.importer.typeCheck", tag.Package.Of(string(m.id))) defer done() var rawErrors []error diff --git a/internal/lsp/cache/external.go b/internal/lsp/cache/external.go index 1c46ea040..1f04d15a6 100644 --- a/internal/lsp/cache/external.go +++ b/internal/lsp/cache/external.go @@ -48,7 +48,7 @@ func (h *nativeFileHandle) Identity() source.FileIdentity { } func (h *nativeFileHandle) Read(ctx context.Context) ([]byte, string, error) { - ctx, done := event.StartSpan(ctx, "cache.nativeFileHandle.Read", tag.File.Of(h.identity.URI.Filename())) + ctx, done := event.Start(ctx, "cache.nativeFileHandle.Read", tag.File.Of(h.identity.URI.Filename())) _ = ctx defer done() diff --git a/internal/lsp/cache/load.go b/internal/lsp/cache/load.go index c53013747..4766910d0 100644 --- a/internal/lsp/cache/load.go +++ b/internal/lsp/cache/load.go @@ -80,7 +80,7 @@ func (s *snapshot) load(ctx context.Context, scopes ...interface{}) error { } sort.Strings(query) // for determinism - ctx, done := event.StartSpan(ctx, "cache.view.load", tag.Query.Of(query)) + ctx, done := event.Start(ctx, "cache.view.load", tag.Query.Of(query)) defer done() cfg := s.Config(ctx) @@ -93,13 +93,13 @@ func (s *snapshot) load(ctx context.Context, scopes ...interface{}) error { return ctx.Err() } - event.Print(ctx, "go/packages.Load", tag.Snapshot.Of(s.ID()), tag.Directory.Of(cfg.Dir), tag.Query.Of(query), tag.PackageCount.Of(len(pkgs))) + event.Log(ctx, "go/packages.Load", tag.Snapshot.Of(s.ID()), tag.Directory.Of(cfg.Dir), tag.Query.Of(query), tag.PackageCount.Of(len(pkgs))) if len(pkgs) == 0 { return err } for _, pkg := range pkgs { if !containsDir || s.view.Options().VerboseOutput { - event.Print(ctx, "go/packages.Load", tag.Snapshot.Of(s.ID()), tag.PackagePath.Of(pkg.PkgPath), tag.Files.Of(pkg.CompiledGoFiles)) + event.Log(ctx, "go/packages.Load", tag.Snapshot.Of(s.ID()), tag.PackagePath.Of(pkg.PkgPath), tag.Files.Of(pkg.CompiledGoFiles)) } // Ignore packages with no sources, since we will never be able to // correctly invalidate that metadata. diff --git a/internal/lsp/cache/mod.go b/internal/lsp/cache/mod.go index ae3670468..9f014512b 100644 --- a/internal/lsp/cache/mod.go +++ b/internal/lsp/cache/mod.go @@ -145,7 +145,7 @@ func (s *snapshot) ModHandle(ctx context.Context, fh source.FileHandle) source.M view: folder, } h := s.view.session.cache.store.Bind(key, func(ctx context.Context) interface{} { - ctx, done := event.StartSpan(ctx, "cache.ModHandle", tag.URI.Of(uri)) + ctx, done := event.Start(ctx, "cache.ModHandle", tag.URI.Of(uri)) defer done() contents, _, err := fh.Read(ctx) @@ -319,7 +319,7 @@ func (s *snapshot) ModTidyHandle(ctx context.Context, realfh source.FileHandle) return &modData{} } - ctx, done := event.StartSpan(ctx, "cache.ModTidyHandle", tag.URI.Of(realURI)) + ctx, done := event.Start(ctx, "cache.ModTidyHandle", tag.URI.Of(realURI)) defer done() realContents, _, err := realfh.Read(ctx) diff --git a/internal/lsp/cache/parse.go b/internal/lsp/cache/parse.go index 4f01fcbc9..0bfb7f6f8 100644 --- a/internal/lsp/cache/parse.go +++ b/internal/lsp/cache/parse.go @@ -124,7 +124,7 @@ func hashParseKeys(phs []*parseGoHandle) string { } func parseGo(ctx context.Context, fset *token.FileSet, fh source.FileHandle, mode source.ParseMode) *parseGoData { - ctx, done := event.StartSpan(ctx, "cache.parseGo", tag.File.Of(fh.Identity().URI.Filename())) + ctx, done := event.Start(ctx, "cache.parseGo", tag.File.Of(fh.Identity().URI.Filename())) defer done() if fh.Identity().Kind != source.Go { diff --git a/internal/lsp/cache/snapshot.go b/internal/lsp/cache/snapshot.go index 0648c80a3..e504dd1cd 100644 --- a/internal/lsp/cache/snapshot.go +++ b/internal/lsp/cache/snapshot.go @@ -113,7 +113,7 @@ func (s *snapshot) Config(ctx context.Context) *packages.Config { }, Logf: func(format string, args ...interface{}) { if verboseOutput { - event.Print(ctx, fmt.Sprintf(format, args...)) + event.Log(ctx, fmt.Sprintf(format, args...)) } }, Tests: true, diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go index 4a87d8291..ae2d1a89e 100644 --- a/internal/lsp/cache/view.go +++ b/internal/lsp/cache/view.go @@ -343,9 +343,9 @@ func (v *view) refreshProcessEnv() { v.importsMu.Unlock() // We don't have a context handy to use for logging, so use the stdlib for now. - event.Print(v.baseCtx, "background imports cache refresh starting") + event.Log(v.baseCtx, "background imports cache refresh starting") err := imports.PrimeCache(context.Background(), env) - event.Print(v.baseCtx, fmt.Sprintf("background refresh finished after %v", time.Since(start)), core.Err.Of(err)) + event.Log(v.baseCtx, fmt.Sprintf("background refresh finished after %v", time.Since(start)), core.Err.Of(err)) v.importsMu.Lock() v.cacheRefreshDuration = time.Since(start) @@ -366,7 +366,7 @@ func (v *view) buildProcessEnv(ctx context.Context) (*imports.ProcessEnv, error) } if verboseOutput { processEnv.Logf = func(format string, args ...interface{}) { - event.Print(ctx, fmt.Sprintf(format, args...)) + event.Log(ctx, fmt.Sprintf(format, args...)) } } for _, kv := range env { diff --git a/internal/lsp/debug/serve.go b/internal/lsp/debug/serve.go index 2a1c73614..3cdc914ce 100644 --- a/internal/lsp/debug/serve.go +++ b/internal/lsp/debug/serve.go @@ -462,7 +462,7 @@ func (i *Instance) Serve(ctx context.Context) error { if strings.HasSuffix(i.DebugAddress, ":0") { log.Printf("debug server listening on port %d", port) } - event.Print(ctx, "Debug serving", tag.Port.Of(port)) + event.Log(ctx, "Debug serving", tag.Port.Of(port)) go func() { mux := http.NewServeMux() mux.HandleFunc("/", render(mainTmpl, func(*http.Request) interface{} { return i })) @@ -493,7 +493,7 @@ func (i *Instance) Serve(ctx context.Context) error { event.Error(ctx, "Debug server failed", err) return } - event.Print(ctx, "Debug server finished") + event.Log(ctx, "Debug server finished") }() return nil } @@ -511,7 +511,7 @@ func (i *Instance) MonitorMemory(ctx context.Context) { continue } i.writeMemoryDebug(nextThresholdGiB) - event.Print(ctx, fmt.Sprintf("Wrote memory usage debug info to %v", os.TempDir())) + event.Log(ctx, fmt.Sprintf("Wrote memory usage debug info to %v", os.TempDir())) nextThresholdGiB++ } }() diff --git a/internal/lsp/diagnostics.go b/internal/lsp/diagnostics.go index 14ad61d34..6694b4795 100644 --- a/internal/lsp/diagnostics.go +++ b/internal/lsp/diagnostics.go @@ -40,7 +40,7 @@ func (s *Server) diagnoseSnapshot(snapshot source.Snapshot) { // diagnose is a helper function for running diagnostics with a given context. // Do not call it directly. func (s *Server) diagnose(ctx context.Context, snapshot source.Snapshot, alwaysAnalyze bool) map[diagnosticKey][]*source.Diagnostic { - ctx, done := event.StartSpan(ctx, "lsp:background-worker") + ctx, done := event.Start(ctx, "lsp:background-worker") defer done() // Wait for a free diagnostics slot. diff --git a/internal/lsp/general.go b/internal/lsp/general.go index 296966bd0..0b2e929bb 100644 --- a/internal/lsp/general.go +++ b/internal/lsp/general.go @@ -173,7 +173,7 @@ func (s *Server) initialized(ctx context.Context, params *protocol.InitializedPa // TODO: this event logging may be unnecessary. The version info is included in the initialize response. buf := &bytes.Buffer{} debug.PrintVersionInfo(ctx, buf, true, debug.PlainText) - event.Print(ctx, buf.String()) + event.Log(ctx, buf.String()) s.addFolders(ctx, s.pendingFolders) s.pendingFolders = nil @@ -198,7 +198,7 @@ func (s *Server) addFolders(ctx context.Context, folders []protocol.WorkspaceFol event.Error(ctx, "failed to write environment", err, tag.Directory.Of(view.Folder())) continue } - event.Print(ctx, buf.String()) + event.Log(ctx, buf.String()) // Diagnose the newly created view. go s.diagnoseDetached(snapshot) @@ -294,7 +294,7 @@ func (s *Server) shutdown(ctx context.Context) error { s.stateMu.Lock() defer s.stateMu.Unlock() if s.state < serverInitialized { - event.Print(ctx, "server shutdown without initialization") + event.Log(ctx, "server shutdown without initialization") } if s.state != serverShutDown { // drop all the active views diff --git a/internal/lsp/generate.go b/internal/lsp/generate.go index 054b7653a..e3cbcb841 100644 --- a/internal/lsp/generate.go +++ b/internal/lsp/generate.go @@ -61,7 +61,7 @@ type eventWriter struct { } func (ew *eventWriter) Write(p []byte) (n int, err error) { - event.Print(ew.ctx, string(p), tag.Operation.Of("generate")) + event.Log(ew.ctx, string(p), tag.Operation.Of("generate")) return len(p), nil } diff --git a/internal/lsp/lsprpc/lsprpc.go b/internal/lsp/lsprpc/lsprpc.go index 89cf894c7..47a1f1596 100644 --- a/internal/lsp/lsprpc/lsprpc.go +++ b/internal/lsp/lsprpc/lsprpc.go @@ -378,7 +378,7 @@ func (f *Forwarder) connectToRemote(ctx context.Context) (net.Conn, error) { if err == nil { return netConn, nil } - event.Print(ctx, fmt.Sprintf("failed attempt #%d to connect to remote: %v\n", retry+2, err)) + event.Log(ctx, fmt.Sprintf("failed attempt #%d to connect to remote: %v\n", retry+2, err)) // In case our failure was a fast-failure, ensure we wait at least // f.dialTimeout before trying again. if retry != f.retries-1 { diff --git a/internal/lsp/lsprpc/lsprpc_test.go b/internal/lsp/lsprpc/lsprpc_test.go index cc2a40fd6..466bef11a 100644 --- a/internal/lsp/lsprpc/lsprpc_test.go +++ b/internal/lsp/lsprpc/lsprpc_test.go @@ -34,7 +34,7 @@ func (c fakeClient) LogMessage(ctx context.Context, params *protocol.LogMessageP type pingServer struct{ protocol.Server } func (s pingServer) DidOpen(ctx context.Context, params *protocol.DidOpenTextDocumentParams) error { - event.Print(ctx, "ping") + event.Log(ctx, "ping") return nil } diff --git a/internal/lsp/mod/code_lens.go b/internal/lsp/mod/code_lens.go index 096bfba1f..3c4ada139 100644 --- a/internal/lsp/mod/code_lens.go +++ b/internal/lsp/mod/code_lens.go @@ -22,7 +22,7 @@ func CodeLens(ctx context.Context, snapshot source.Snapshot, uri span.URI) ([]pr if uri != realURI { return nil, nil } - ctx, done := event.StartSpan(ctx, "mod.CodeLens", tag.URI.Of(realURI)) + ctx, done := event.Start(ctx, "mod.CodeLens", tag.URI.Of(realURI)) defer done() fh, err := snapshot.GetFile(realURI) diff --git a/internal/lsp/mod/diagnostics.go b/internal/lsp/mod/diagnostics.go index 5b64fa900..0a5b30f63 100644 --- a/internal/lsp/mod/diagnostics.go +++ b/internal/lsp/mod/diagnostics.go @@ -24,7 +24,7 @@ func Diagnostics(ctx context.Context, snapshot source.Snapshot) (map[source.File if realURI == "" || tempURI == "" { return nil, nil, nil } - ctx, done := event.StartSpan(ctx, "mod.Diagnostics", tag.URI.Of(realURI)) + ctx, done := event.Start(ctx, "mod.Diagnostics", tag.URI.Of(realURI)) defer done() realfh, err := snapshot.GetFile(realURI) @@ -118,7 +118,7 @@ func SuggestedGoFixes(ctx context.Context, snapshot source.Snapshot) (map[string return nil, nil } - ctx, done := event.StartSpan(ctx, "mod.SuggestedGoFixes", tag.URI.Of(realURI)) + ctx, done := event.Start(ctx, "mod.SuggestedGoFixes", tag.URI.Of(realURI)) defer done() realfh, err := snapshot.GetFile(realURI) diff --git a/internal/lsp/mod/format.go b/internal/lsp/mod/format.go index 060877f09..d1c567ef6 100644 --- a/internal/lsp/mod/format.go +++ b/internal/lsp/mod/format.go @@ -9,7 +9,7 @@ import ( ) func Format(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle) ([]protocol.TextEdit, error) { - ctx, done := event.StartSpan(ctx, "mod.Format") + ctx, done := event.Start(ctx, "mod.Format") defer done() file, m, err := snapshot.ModHandle(ctx, fh).Parse(ctx) diff --git a/internal/lsp/mod/hover.go b/internal/lsp/mod/hover.go index bab9f5f00..2439002d9 100644 --- a/internal/lsp/mod/hover.go +++ b/internal/lsp/mod/hover.go @@ -20,7 +20,7 @@ func Hover(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle, if realURI == "" || fh.Identity().URI != realURI { return nil, nil } - ctx, done := event.StartSpan(ctx, "mod.Hover") + ctx, done := event.Start(ctx, "mod.Hover") defer done() file, m, why, err := snapshot.ModHandle(ctx, fh).Why(ctx) diff --git a/internal/lsp/protocol/protocol.go b/internal/lsp/protocol/protocol.go index 18e9181ae..28f9a1b36 100644 --- a/internal/lsp/protocol/protocol.go +++ b/internal/lsp/protocol/protocol.go @@ -69,7 +69,7 @@ func Call(ctx context.Context, conn *jsonrpc2.Conn, method string, params interf func cancelCall(ctx context.Context, conn *jsonrpc2.Conn, id jsonrpc2.ID) { ctx = xcontext.Detach(ctx) - ctx, done := event.StartSpan(ctx, "protocol.canceller") + ctx, done := event.Start(ctx, "protocol.canceller") defer done() // Note that only *jsonrpc2.ID implements json.Marshaler. conn.Notify(ctx, "$/cancelRequest", &CancelParams{ID: &id}) diff --git a/internal/lsp/signature_help.go b/internal/lsp/signature_help.go index fad317d14..974224e4e 100644 --- a/internal/lsp/signature_help.go +++ b/internal/lsp/signature_help.go @@ -21,7 +21,7 @@ func (s *Server) signatureHelp(ctx context.Context, params *protocol.SignatureHe } info, activeParameter, err := source.SignatureHelp(ctx, snapshot, fh, params.Position) if err != nil { - event.Print(ctx, "no signature help", tag.Position.Of(params.Position), core.Err.Of(err)) + event.Log(ctx, "no signature help", tag.Position.Of(params.Position), core.Err.Of(err)) return nil, nil } return &protocol.SignatureHelp{ diff --git a/internal/lsp/source/completion.go b/internal/lsp/source/completion.go index 39a757638..96db89bcb 100644 --- a/internal/lsp/source/completion.go +++ b/internal/lsp/source/completion.go @@ -425,7 +425,7 @@ func (e ErrIsDefinition) Error() string { // the client to score the quality of the completion. For instance, some clients // may tolerate imperfect matches as valid completion results, since users may make typos. func Completion(ctx context.Context, snapshot Snapshot, fh FileHandle, protoPos protocol.Position) ([]CompletionItem, *Selection, error) { - ctx, done := event.StartSpan(ctx, "source.Completion") + ctx, done := event.Start(ctx, "source.Completion") defer done() startTime := time.Now() diff --git a/internal/lsp/source/diagnostics.go b/internal/lsp/source/diagnostics.go index 869167439..6fafe28fa 100644 --- a/internal/lsp/source/diagnostics.go +++ b/internal/lsp/source/diagnostics.go @@ -168,7 +168,7 @@ type diagnosticSet struct { } func diagnostics(ctx context.Context, snapshot Snapshot, reports map[FileIdentity][]*Diagnostic, pkg Package, hasMissingDeps bool) (bool, bool, error) { - ctx, done := event.StartSpan(ctx, "source.diagnostics", tag.Package.Of(pkg.ID())) + ctx, done := event.Start(ctx, "source.diagnostics", tag.Package.Of(pkg.ID())) _ = ctx // circumvent SA4006 defer done() diff --git a/internal/lsp/source/format.go b/internal/lsp/source/format.go index 5b92ab6bf..17ed0a6f6 100644 --- a/internal/lsp/source/format.go +++ b/internal/lsp/source/format.go @@ -24,7 +24,7 @@ import ( // Format formats a file with a given range. func Format(ctx context.Context, snapshot Snapshot, fh FileHandle) ([]protocol.TextEdit, error) { - ctx, done := event.StartSpan(ctx, "source.Format") + ctx, done := event.Start(ctx, "source.Format") defer done() pgh := snapshot.View().Session().Cache().ParseGoHandle(fh, ParseFull) @@ -57,7 +57,7 @@ func Format(ctx context.Context, snapshot Snapshot, fh FileHandle) ([]protocol.T } func formatSource(ctx context.Context, fh FileHandle) ([]byte, error) { - ctx, done := event.StartSpan(ctx, "source.formatSource") + ctx, done := event.Start(ctx, "source.formatSource") defer done() data, _, err := fh.Read(ctx) @@ -77,7 +77,7 @@ type ImportFix struct { // it returns a list of fixes that could be applied to the file, with the // corresponding TextEdits that would be needed to apply that fix. func AllImportsFixes(ctx context.Context, snapshot Snapshot, fh FileHandle) (allFixEdits []protocol.TextEdit, editsPerFix []*ImportFix, err error) { - ctx, done := event.StartSpan(ctx, "source.AllImportsFixes") + ctx, done := event.Start(ctx, "source.AllImportsFixes") defer done() pgh := snapshot.View().Session().Cache().ParseGoHandle(fh, ParseFull) @@ -302,7 +302,7 @@ func trimToFirstNonImport(fset *token.FileSet, f *ast.File, src []byte, err erro } func computeTextEdits(ctx context.Context, view View, fh FileHandle, m *protocol.ColumnMapper, formatted string) ([]protocol.TextEdit, error) { - ctx, done := event.StartSpan(ctx, "source.computeTextEdits") + ctx, done := event.Start(ctx, "source.computeTextEdits") defer done() data, _, err := fh.Read(ctx) diff --git a/internal/lsp/source/highlight.go b/internal/lsp/source/highlight.go index 0917aeea2..aff6d826b 100644 --- a/internal/lsp/source/highlight.go +++ b/internal/lsp/source/highlight.go @@ -19,7 +19,7 @@ import ( ) func Highlight(ctx context.Context, snapshot Snapshot, fh FileHandle, pos protocol.Position) ([]protocol.Range, error) { - ctx, done := event.StartSpan(ctx, "source.Highlight") + ctx, done := event.Start(ctx, "source.Highlight") defer done() pkg, pgh, err := getParsedFile(ctx, snapshot, fh, WidestPackageHandle) diff --git a/internal/lsp/source/hover.go b/internal/lsp/source/hover.go index 9b85b6610..6dd0ab961 100644 --- a/internal/lsp/source/hover.go +++ b/internal/lsp/source/hover.go @@ -71,7 +71,7 @@ func Hover(ctx context.Context, snapshot Snapshot, fh FileHandle, position proto } func (i *IdentifierInfo) Hover(ctx context.Context) (*HoverInformation, error) { - ctx, done := event.StartSpan(ctx, "source.Hover") + ctx, done := event.Start(ctx, "source.Hover") defer done() h, err := i.Declaration.hover(ctx) @@ -201,7 +201,7 @@ func objectString(obj types.Object, qf types.Qualifier) string { } func (d Declaration) hover(ctx context.Context) (*HoverInformation, error) { - _, done := event.StartSpan(ctx, "source.hover") + _, done := event.Start(ctx, "source.hover") defer done() obj := d.obj diff --git a/internal/lsp/source/identifier.go b/internal/lsp/source/identifier.go index f11c4e561..68cc583b1 100644 --- a/internal/lsp/source/identifier.go +++ b/internal/lsp/source/identifier.go @@ -49,7 +49,7 @@ type Declaration struct { // Identifier returns identifier information for a position // in a file, accounting for a potentially incomplete selector. func Identifier(ctx context.Context, snapshot Snapshot, fh FileHandle, pos protocol.Position) (*IdentifierInfo, error) { - ctx, done := event.StartSpan(ctx, "source.Identifier") + ctx, done := event.Start(ctx, "source.Identifier") defer done() pkg, pgh, err := getParsedFile(ctx, snapshot, fh, NarrowestPackageHandle) diff --git a/internal/lsp/source/implementation.go b/internal/lsp/source/implementation.go index ddebb487d..9826d2333 100644 --- a/internal/lsp/source/implementation.go +++ b/internal/lsp/source/implementation.go @@ -17,7 +17,7 @@ import ( ) func Implementation(ctx context.Context, s Snapshot, f FileHandle, pp protocol.Position) ([]protocol.Location, error) { - ctx, done := event.StartSpan(ctx, "source.Implementation") + ctx, done := event.Start(ctx, "source.Implementation") defer done() impls, err := implementations(ctx, s, f, pp) diff --git a/internal/lsp/source/references.go b/internal/lsp/source/references.go index 0cc492233..74e2fe4d6 100644 --- a/internal/lsp/source/references.go +++ b/internal/lsp/source/references.go @@ -28,7 +28,7 @@ type ReferenceInfo struct { // References returns a list of references for a given identifier within the packages // containing i.File. Declarations appear first in the result. func References(ctx context.Context, s Snapshot, f FileHandle, pp protocol.Position, includeDeclaration bool) ([]*ReferenceInfo, error) { - ctx, done := event.StartSpan(ctx, "source.References") + ctx, done := event.Start(ctx, "source.References") defer done() qualifiedObjs, err := qualifiedObjsAtProtocolPos(ctx, s, f, pp) diff --git a/internal/lsp/source/rename.go b/internal/lsp/source/rename.go index c0026b653..5d8068fe9 100644 --- a/internal/lsp/source/rename.go +++ b/internal/lsp/source/rename.go @@ -42,7 +42,7 @@ type PrepareItem struct { } func PrepareRename(ctx context.Context, s Snapshot, f FileHandle, pp protocol.Position) (*PrepareItem, error) { - ctx, done := event.StartSpan(ctx, "source.PrepareRename") + ctx, done := event.Start(ctx, "source.PrepareRename") defer done() qos, err := qualifiedObjsAtProtocolPos(ctx, s, f, pp) @@ -70,7 +70,7 @@ func PrepareRename(ctx context.Context, s Snapshot, f FileHandle, pp protocol.Po // Rename returns a map of TextEdits for each file modified when renaming a given identifier within a package. func Rename(ctx context.Context, s Snapshot, f FileHandle, pp protocol.Position, newName string) (map[span.URI][]protocol.TextEdit, error) { - ctx, done := event.StartSpan(ctx, "source.Rename") + ctx, done := event.Start(ctx, "source.Rename") defer done() qos, err := qualifiedObjsAtProtocolPos(ctx, s, f, pp) diff --git a/internal/lsp/source/signature_help.go b/internal/lsp/source/signature_help.go index e6584929f..38e0edc19 100644 --- a/internal/lsp/source/signature_help.go +++ b/internal/lsp/source/signature_help.go @@ -19,7 +19,7 @@ import ( ) func SignatureHelp(ctx context.Context, snapshot Snapshot, fh FileHandle, pos protocol.Position) (*protocol.SignatureInformation, int, error) { - ctx, done := event.StartSpan(ctx, "source.SignatureHelp") + ctx, done := event.Start(ctx, "source.SignatureHelp") defer done() pkg, pgh, err := getParsedFile(ctx, snapshot, fh, NarrowestPackageHandle) diff --git a/internal/lsp/source/symbols.go b/internal/lsp/source/symbols.go index bc4e2b70f..e4d9a2080 100644 --- a/internal/lsp/source/symbols.go +++ b/internal/lsp/source/symbols.go @@ -15,7 +15,7 @@ import ( ) func DocumentSymbols(ctx context.Context, snapshot Snapshot, fh FileHandle) ([]protocol.DocumentSymbol, error) { - ctx, done := event.StartSpan(ctx, "source.DocumentSymbols") + ctx, done := event.Start(ctx, "source.DocumentSymbols") defer done() pkg, pgh, err := getParsedFile(ctx, snapshot, fh, NarrowestPackageHandle) diff --git a/internal/lsp/source/workspace_symbol.go b/internal/lsp/source/workspace_symbol.go index 70f730a1f..ae40b4a38 100644 --- a/internal/lsp/source/workspace_symbol.go +++ b/internal/lsp/source/workspace_symbol.go @@ -19,7 +19,7 @@ import ( const maxSymbols = 100 func WorkspaceSymbols(ctx context.Context, views []View, query string) ([]protocol.SymbolInformation, error) { - ctx, done := event.StartSpan(ctx, "source.WorkspaceSymbols") + ctx, done := event.Start(ctx, "source.WorkspaceSymbols") defer done() seen := make(map[string]struct{}) diff --git a/internal/lsp/symbols.go b/internal/lsp/symbols.go index 59eb52cfe..7848eee96 100644 --- a/internal/lsp/symbols.go +++ b/internal/lsp/symbols.go @@ -14,7 +14,7 @@ import ( ) func (s *Server) documentSymbol(ctx context.Context, params *protocol.DocumentSymbolParams) ([]interface{}, error) { - ctx, done := event.StartSpan(ctx, "lsp.Server.documentSymbol") + ctx, done := event.Start(ctx, "lsp.Server.documentSymbol") defer done() snapshot, fh, ok, err := s.beginFileRequest(params.TextDocument.URI, source.Go) diff --git a/internal/lsp/workspace_symbol.go b/internal/lsp/workspace_symbol.go index 07718f992..66282a267 100644 --- a/internal/lsp/workspace_symbol.go +++ b/internal/lsp/workspace_symbol.go @@ -13,7 +13,7 @@ import ( ) func (s *Server) symbol(ctx context.Context, params *protocol.WorkspaceSymbolParams) ([]protocol.SymbolInformation, error) { - ctx, done := event.StartSpan(ctx, "lsp.Server.symbol") + ctx, done := event.Start(ctx, "lsp.Server.symbol") defer done() return source.WorkspaceSymbols(ctx, s.session.Views(), params.Query) |