diff --git a/internal/lsp/diagnostics.go b/internal/lsp/diagnostics.go index 0319c08d24..de0e23e7f6 100644 --- a/internal/lsp/diagnostics.go +++ b/internal/lsp/diagnostics.go @@ -203,7 +203,7 @@ func (s *Server) publishReports(ctx context.Context, snapshot source.Snapshot, r Version: key.id.Version, }); err != nil { if ctx.Err() == nil { - log.Error(ctx, "publishReports: failed to deliver diagnostic", err, telemetry.File) + log.Error(ctx, "publishReports: failed to deliver diagnostic", err, telemetry.File.Tag(ctx)) } continue } diff --git a/internal/telemetry/log/log.go b/internal/telemetry/log/log.go index b4f2c70a21..0c57e8a24c 100644 --- a/internal/telemetry/log/log.go +++ b/internal/telemetry/log/log.go @@ -12,7 +12,6 @@ import ( "golang.org/x/tools/internal/telemetry" "golang.org/x/tools/internal/telemetry/export" - "golang.org/x/tools/internal/telemetry/tag" ) type Event telemetry.Event @@ -27,18 +26,18 @@ func With(ctx context.Context, tags ...telemetry.Tag) { // Print takes a message and a tag list and combines them into a single tag // list before delivering them to the loggers. -func Print(ctx context.Context, message string, tags ...tag.Tagger) { +func Print(ctx context.Context, message string, tags ...telemetry.Tag) { export.Log(ctx, telemetry.Event{ At: time.Now(), Message: message, - Tags: tag.Tags(ctx, tags...), + Tags: tags, }) } // Error takes a message and a tag list and combines them into a single tag // list before delivering them to the loggers. It captures the error in the // delivered event. -func Error(ctx context.Context, message string, err error, tags ...tag.Tagger) { +func Error(ctx context.Context, message string, err error, tags ...telemetry.Tag) { if err == nil { err = errorString(message) message = "" @@ -47,7 +46,7 @@ func Error(ctx context.Context, message string, err error, tags ...tag.Tagger) { At: time.Now(), Message: message, Error: err, - Tags: tag.Tags(ctx, tags...), + Tags: tags, }) } diff --git a/internal/telemetry/tag.go b/internal/telemetry/tag.go index 54c6102f48..4af028d6dc 100644 --- a/internal/telemetry/tag.go +++ b/internal/telemetry/tag.go @@ -5,7 +5,6 @@ package telemetry import ( - "context" "fmt" ) @@ -26,12 +25,6 @@ func (t Tag) Format(f fmt.State, r rune) { fmt.Fprintf(f, `%v="%v"`, t.Key, t.Value) } -// Tag returns the tag unmodified. -// It makes Key conform to the Tagger interface. -func (t Tag) Tag(ctx context.Context) Tag { - return t -} - // Get will get a single key's value from the list. func (l TagList) Get(k interface{}) interface{} { for _, t := range l { diff --git a/internal/telemetry/tag/tag.go b/internal/telemetry/tag/tag.go index c6192aba95..2c96aaadba 100644 --- a/internal/telemetry/tag/tag.go +++ b/internal/telemetry/tag/tag.go @@ -18,14 +18,6 @@ import ( //TODO: Do we need to do something more efficient than just store tags //TODO: directly on the context? -// Tagger is the interface to something that returns a Tag given a context. -// Both Tag itself and Key support this interface, allowing methods that can -// take either (and other implementations as well) -type Tagger interface { - // Tag returns a Tag potentially using information from the Context. - Tag(context.Context) telemetry.Tag -} - // With is roughly equivalent to context.WithValue except that it also notifies // registered observers. // Unlike WithValue, it takes a list of tags so that you can set many values @@ -48,12 +40,3 @@ func Get(ctx context.Context, keys ...interface{}) telemetry.TagList { } return tags } - -// Tags collects a list of tags for the taggers from the context. -func Tags(ctx context.Context, taggers ...Tagger) telemetry.TagList { - tags := make(telemetry.TagList, len(taggers)) - for i, t := range taggers { - tags[i] = t.Tag(ctx) - } - return tags -}