internal/lsp: move the telemetry package

Move the lsp specific telemetry package that just declares the labels under the
debug package and call it tag, to make all the usages much more readable.

Change-Id: Ic89b3408dd3b8b3d914cc69d81f41b8919aaf424
Reviewed-on: https://go-review.googlesource.com/c/tools/+/222850
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
diff --git a/internal/lsp/cache/analysis.go b/internal/lsp/cache/analysis.go
index 1fb346a..a517223 100644
--- a/internal/lsp/cache/analysis.go
+++ b/internal/lsp/cache/analysis.go
@@ -15,8 +15,8 @@
 
 	"golang.org/x/sync/errgroup"
 	"golang.org/x/tools/go/analysis"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/memoize"
 	"golang.org/x/tools/internal/telemetry/event"
 	errors "golang.org/x/xerrors"
@@ -207,7 +207,7 @@
 	}
 	defer func() {
 		if r := recover(); r != nil {
-			event.Print(ctx, fmt.Sprintf("analysis panicked: %s", r), telemetry.Package.Of(pkg.PkgPath))
+			event.Print(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)
 		}
 	}()
@@ -343,7 +343,7 @@
 	for _, diag := range diagnostics {
 		srcErr, err := sourceError(ctx, fset, pkg, diag)
 		if err != nil {
-			event.Error(ctx, "unable to compute analysis error position", err, event.TagOf("category", diag.Category), telemetry.Package.Of(pkg.ID()))
+			event.Error(ctx, "unable to compute analysis error position", err, event.TagOf("category", diag.Category), tag.Package.Of(pkg.ID()))
 			continue
 		}
 		data.diagnostics = append(data.diagnostics, srcErr)
diff --git a/internal/lsp/cache/check.go b/internal/lsp/cache/check.go
index c472b2b..801c661 100644
--- a/internal/lsp/cache/check.go
+++ b/internal/lsp/cache/check.go
@@ -17,8 +17,8 @@
 	"sync"
 
 	"golang.org/x/tools/go/packages"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/memoize"
 	"golang.org/x/tools/internal/span"
 	"golang.org/x/tools/internal/telemetry/event"
@@ -143,7 +143,7 @@
 		}
 		depHandle, err := s.buildPackageHandle(ctx, depID, mode)
 		if err != nil {
-			event.Error(ctx, "no dep handle", err, telemetry.Package.Of(depID))
+			event.Error(ctx, "no dep handle", err, tag.Package.Of(depID))
 
 			// One bad dependency should not prevent us from checking the entire package.
 			// Add a special key to mark a bad dependency.
@@ -259,7 +259,7 @@
 }
 
 func typeCheck(ctx context.Context, fset *token.FileSet, m *metadata, mode source.ParseMode, goFiles []source.ParseGoHandle, compiledGoFiles []source.ParseGoHandle, deps map[packagePath]*packageHandle) (*pkg, error) {
-	ctx, done := event.StartSpan(ctx, "cache.importer.typeCheck", telemetry.Package.Of(m.id))
+	ctx, done := event.StartSpan(ctx, "cache.importer.typeCheck", tag.Package.Of(m.id))
 	defer done()
 
 	var rawErrors []error
@@ -393,7 +393,7 @@
 		for _, e := range rawErrors {
 			srcErr, err := sourceError(ctx, fset, pkg, e)
 			if err != nil {
-				event.Error(ctx, "unable to compute error positions", err, telemetry.Package.Of(pkg.ID()))
+				event.Error(ctx, "unable to compute error positions", err, tag.Package.Of(pkg.ID()))
 				continue
 			}
 			pkg.errors = append(pkg.errors, srcErr)
diff --git a/internal/lsp/cache/errors.go b/internal/lsp/cache/errors.go
index 2390608..72b6e22 100644
--- a/internal/lsp/cache/errors.go
+++ b/internal/lsp/cache/errors.go
@@ -16,9 +16,9 @@
 
 	"golang.org/x/tools/go/analysis"
 	"golang.org/x/tools/go/packages"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/protocol"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/span"
 	"golang.org/x/tools/internal/telemetry/event"
 	errors "golang.org/x/xerrors"
@@ -60,7 +60,7 @@
 		kind = source.ParseError
 		spn, err = scannerErrorRange(ctx, fset, pkg, e.Pos)
 		if err != nil {
-			event.Error(ctx, "no span for scanner.Error pos", err, telemetry.Package.Of(pkg.ID()))
+			event.Error(ctx, "no span for scanner.Error pos", err, tag.Package.Of(pkg.ID()))
 			spn = span.Parse(e.Pos.String())
 		}
 
@@ -73,7 +73,7 @@
 		kind = source.ParseError
 		spn, err = scannerErrorRange(ctx, fset, pkg, e[0].Pos)
 		if err != nil {
-			event.Error(ctx, "no span for scanner.Error pos", err, telemetry.Package.Of(pkg.ID()))
+			event.Error(ctx, "no span for scanner.Error pos", err, tag.Package.Of(pkg.ID()))
 			spn = span.Parse(e[0].Pos.String())
 		}
 	case types.Error:
diff --git a/internal/lsp/cache/external.go b/internal/lsp/cache/external.go
index 9f5d970..806499a 100644
--- a/internal/lsp/cache/external.go
+++ b/internal/lsp/cache/external.go
@@ -9,8 +9,8 @@
 	"io/ioutil"
 	"os"
 
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/span"
 	"golang.org/x/tools/internal/telemetry/event"
 	errors "golang.org/x/xerrors"
@@ -48,7 +48,7 @@
 }
 
 func (h *nativeFileHandle) Read(ctx context.Context) ([]byte, string, error) {
-	ctx, done := event.StartSpan(ctx, "cache.nativeFileHandle.Read", telemetry.File.Of(h.identity.URI.Filename()))
+	ctx, done := event.StartSpan(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 380c4fe..d7b5b58 100644
--- a/internal/lsp/cache/load.go
+++ b/internal/lsp/cache/load.go
@@ -12,8 +12,8 @@
 	"strings"
 
 	"golang.org/x/tools/go/packages"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/packagesinternal"
 	"golang.org/x/tools/internal/span"
 	"golang.org/x/tools/internal/telemetry/event"
@@ -77,7 +77,7 @@
 	}
 	sort.Strings(query) // for determinism
 
-	ctx, done := event.StartSpan(ctx, "cache.view.load", telemetry.Query.Of(query))
+	ctx, done := event.StartSpan(ctx, "cache.view.load", tag.Query.Of(query))
 	defer done()
 
 	cfg := s.Config(ctx)
diff --git a/internal/lsp/cache/mod.go b/internal/lsp/cache/mod.go
index 18ab91a..a5bff23 100644
--- a/internal/lsp/cache/mod.go
+++ b/internal/lsp/cache/mod.go
@@ -16,9 +16,9 @@
 	"golang.org/x/mod/modfile"
 	"golang.org/x/tools/go/packages"
 	"golang.org/x/tools/internal/gocommand"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/protocol"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/memoize"
 	"golang.org/x/tools/internal/span"
 	"golang.org/x/tools/internal/telemetry/event"
@@ -144,7 +144,7 @@
 		view:      folder,
 	}
 	h := s.view.session.cache.store.Bind(key, func(ctx context.Context) interface{} {
-		ctx, done := event.StartSpan(ctx, "cache.ModHandle", telemetry.File.Of(uri))
+		ctx, done := event.StartSpan(ctx, "cache.ModHandle", tag.File.Of(uri))
 		defer done()
 
 		contents, _, err := fh.Read(ctx)
@@ -317,7 +317,7 @@
 			return &modData{}
 		}
 
-		ctx, done := event.StartSpan(ctx, "cache.ModTidyHandle", telemetry.File.Of(realURI))
+		ctx, done := event.StartSpan(ctx, "cache.ModTidyHandle", tag.File.Of(realURI))
 		defer done()
 
 		realContents, _, err := realfh.Read(ctx)
diff --git a/internal/lsp/cache/parse.go b/internal/lsp/cache/parse.go
index 6641d99..9b52f9e 100644
--- a/internal/lsp/cache/parse.go
+++ b/internal/lsp/cache/parse.go
@@ -13,9 +13,9 @@
 	"go/token"
 	"reflect"
 
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/protocol"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/memoize"
 	"golang.org/x/tools/internal/span"
 	"golang.org/x/tools/internal/telemetry/event"
@@ -106,7 +106,7 @@
 }
 
 func parseGo(ctx context.Context, fset *token.FileSet, fh source.FileHandle, mode source.ParseMode) *parseGoData {
-	ctx, done := event.StartSpan(ctx, "cache.parseGo", telemetry.File.Of(fh.Identity().URI.Filename()))
+	ctx, done := event.StartSpan(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 78d8389..911cecf 100644
--- a/internal/lsp/cache/snapshot.go
+++ b/internal/lsp/cache/snapshot.go
@@ -17,8 +17,8 @@
 
 	"golang.org/x/tools/go/analysis"
 	"golang.org/x/tools/go/packages"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/span"
 	"golang.org/x/tools/internal/telemetry/event"
 	errors "golang.org/x/xerrors"
@@ -151,7 +151,7 @@
 		panic("called PackageHandles on a non-Go FileHandle")
 	}
 
-	ctx = event.Label(ctx, telemetry.File.Of(fh.Identity().URI))
+	ctx = event.Label(ctx, tag.File.Of(fh.Identity().URI))
 
 	// Check if we should reload metadata for the file. We don't invalidate IDs
 	// (though we should), so the IDs will be a better source of truth than the
diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go
index 351b138..933ec40 100644
--- a/internal/lsp/cache/view.go
+++ b/internal/lsp/cache/view.go
@@ -24,8 +24,8 @@
 	"golang.org/x/tools/internal/gocommand"
 	"golang.org/x/tools/internal/imports"
 	"golang.org/x/tools/internal/lsp/debug"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/memoize"
 	"golang.org/x/tools/internal/span"
 	"golang.org/x/tools/internal/telemetry/event"
@@ -792,7 +792,7 @@
 	// If the output is not go1.14 or an empty string, then it could be an error.
 	lines := strings.Split(stdout.String(), "\n")
 	if len(lines) < 2 && stdout.String() != "" {
-		event.Error(ctx, "unexpected stdout when checking for go1.14", errors.Errorf("%q", stdout), telemetry.Directory.Of(folder))
+		event.Error(ctx, "unexpected stdout when checking for go1.14", errors.Errorf("%q", stdout), tag.Directory.Of(folder))
 		return false, nil
 	}
 	return lines[0] == "go1.14", nil
diff --git a/internal/lsp/code_action.go b/internal/lsp/code_action.go
index ebf2e33..7cb16c8 100644
--- a/internal/lsp/code_action.go
+++ b/internal/lsp/code_action.go
@@ -11,10 +11,10 @@
 	"strings"
 
 	"golang.org/x/tools/internal/imports"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/mod"
 	"golang.org/x/tools/internal/lsp/protocol"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/telemetry/event"
 	errors "golang.org/x/xerrors"
 )
@@ -73,7 +73,7 @@
 			// First, add the quick fixes reported by go/analysis.
 			qf, err := quickFixes(ctx, snapshot, fh, diagnostics)
 			if err != nil {
-				event.Error(ctx, "quick fixes failed", err, telemetry.File.Of(uri))
+				event.Error(ctx, "quick fixes failed", err, tag.File.Of(uri))
 			}
 			codeActions = append(codeActions, qf...)
 
@@ -97,7 +97,7 @@
 			}
 			actions, err := mod.SuggestedGoFixes(ctx, snapshot, fh, diagnostics)
 			if err != nil {
-				event.Error(ctx, "quick fixes failed", err, telemetry.File.Of(uri))
+				event.Error(ctx, "quick fixes failed", err, tag.File.Of(uri))
 			}
 			if len(actions) > 0 {
 				codeActions = append(codeActions, actions...)
@@ -234,7 +234,7 @@
 			for uri, edits := range fix.Edits {
 				fh, err := snapshot.GetFile(uri)
 				if err != nil {
-					event.Error(ctx, "no file", err, telemetry.URI.Of(uri))
+					event.Error(ctx, "no file", err, tag.URI.Of(uri))
 					continue
 				}
 				action.Edit.DocumentChanges = append(action.Edit.DocumentChanges, documentChanges(fh, edits)...)
diff --git a/internal/lsp/debug/metrics.go b/internal/lsp/debug/metrics.go
index 7da805f..19ac0a1 100644
--- a/internal/lsp/debug/metrics.go
+++ b/internal/lsp/debug/metrics.go
@@ -5,7 +5,7 @@
 package debug
 
 import (
-	"golang.org/x/tools/internal/lsp/telemetry"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/telemetry/event"
 	"golang.org/x/tools/internal/telemetry/metric"
 )
@@ -18,33 +18,33 @@
 	receivedBytes = metric.HistogramInt64{
 		Name:        "received_bytes",
 		Description: "Distribution of received bytes, by method.",
-		Keys:        []*event.Key{telemetry.RPCDirection, telemetry.Method},
+		Keys:        []*event.Key{tag.RPCDirection, tag.Method},
 		Buckets:     bytesDistribution,
-	}.Record(telemetry.ReceivedBytes)
+	}.Record(tag.ReceivedBytes)
 
 	sentBytes = metric.HistogramInt64{
 		Name:        "sent_bytes",
 		Description: "Distribution of sent bytes, by method.",
-		Keys:        []*event.Key{telemetry.RPCDirection, telemetry.Method},
+		Keys:        []*event.Key{tag.RPCDirection, tag.Method},
 		Buckets:     bytesDistribution,
-	}.Record(telemetry.SentBytes)
+	}.Record(tag.SentBytes)
 
 	latency = metric.HistogramFloat64{
 		Name:        "latency",
 		Description: "Distribution of latency in milliseconds, by method.",
-		Keys:        []*event.Key{telemetry.RPCDirection, telemetry.Method},
+		Keys:        []*event.Key{tag.RPCDirection, tag.Method},
 		Buckets:     millisecondsDistribution,
-	}.Record(telemetry.Latency)
+	}.Record(tag.Latency)
 
 	started = metric.Scalar{
 		Name:        "started",
 		Description: "Count of RPCs started by method.",
-		Keys:        []*event.Key{telemetry.RPCDirection, telemetry.Method},
-	}.CountInt64(telemetry.Started)
+		Keys:        []*event.Key{tag.RPCDirection, tag.Method},
+	}.CountInt64(tag.Started)
 
 	completed = metric.Scalar{
 		Name:        "completed",
 		Description: "Count of RPCs completed by method and status.",
-		Keys:        []*event.Key{telemetry.RPCDirection, telemetry.Method, telemetry.StatusCode},
-	}.CountFloat64(telemetry.Latency)
+		Keys:        []*event.Key{tag.RPCDirection, tag.Method, tag.StatusCode},
+	}.CountFloat64(tag.Latency)
 )
diff --git a/internal/lsp/debug/rpc.go b/internal/lsp/debug/rpc.go
index dd14b9d..07aed82 100644
--- a/internal/lsp/debug/rpc.go
+++ b/internal/lsp/debug/rpc.go
@@ -13,7 +13,7 @@
 	"sort"
 	"sync"
 
-	tlm "golang.org/x/tools/internal/lsp/telemetry"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/telemetry/event"
 	"golang.org/x/tools/internal/telemetry/metric"
 )
@@ -97,10 +97,10 @@
 	defer r.mu.Unlock()
 	for i, group := range data.Groups() {
 		set := &r.Inbound
-		if group.Get(tlm.RPCDirection) == tlm.Outbound {
+		if group.Get(tag.RPCDirection) == tag.Outbound {
 			set = &r.Outbound
 		}
-		method, ok := group.Get(tlm.Method).(string)
+		method, ok := group.Get(tag.Method).(string)
 		if !ok {
 			continue
 		}
@@ -119,7 +119,7 @@
 		case started:
 			stats.Started = data.(*metric.Int64Data).Rows[i]
 		case completed:
-			status, ok := group.Get(tlm.StatusCode).(string)
+			status, ok := group.Get(tag.StatusCode).(string)
 			if !ok {
 				log.Printf("Not status... %v", group)
 				continue
diff --git a/internal/lsp/telemetry/telemetry.go b/internal/lsp/debug/tag/tag.go
similarity index 91%
rename from internal/lsp/telemetry/telemetry.go
rename to internal/lsp/debug/tag/tag.go
index 32d92a3..d4e9219 100644
--- a/internal/lsp/telemetry/telemetry.go
+++ b/internal/lsp/debug/tag/tag.go
@@ -2,9 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Package telemetry provides the hooks and adapters to allow use of telemetry
-// throughout gopls.
-package telemetry
+// Package tag provides the labels used for telemetry throughout gopls.
+package tag
 
 import (
 	"golang.org/x/tools/internal/telemetry/event"
diff --git a/internal/lsp/diagnostics.go b/internal/lsp/diagnostics.go
index 44e7b8e..5b9b5b9 100644
--- a/internal/lsp/diagnostics.go
+++ b/internal/lsp/diagnostics.go
@@ -10,10 +10,10 @@
 	"strings"
 	"sync"
 
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/mod"
 	"golang.org/x/tools/internal/lsp/protocol"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/telemetry/event"
 	"golang.org/x/tools/internal/xcontext"
 )
@@ -98,7 +98,7 @@
 		}
 		s.showedInitialErrorMu.Unlock()
 
-		event.Error(ctx, "diagnose: no workspace packages", err, telemetry.Snapshot.Of(snapshot.ID()), telemetry.Directory.Of(snapshot.View().Folder))
+		event.Error(ctx, "diagnose: no workspace packages", err, tag.Snapshot.Of(snapshot.ID()), tag.Directory.Of(snapshot.View().Folder))
 		return nil
 	}
 	for _, ph := range wsPackages {
@@ -124,7 +124,7 @@
 				return
 			}
 			if err != nil {
-				event.Error(ctx, "diagnose: could not generate diagnostics for package", err, telemetry.Snapshot.Of(snapshot.ID()), telemetry.Package.Of(ph.ID()))
+				event.Error(ctx, "diagnose: could not generate diagnostics for package", err, tag.Snapshot.Of(snapshot.ID()), tag.Package.Of(ph.ID()))
 				return
 			}
 			reportsMu.Lock()
@@ -201,7 +201,7 @@
 			Version:     key.id.Version,
 		}); err != nil {
 			if ctx.Err() == nil {
-				event.Error(ctx, "publishReports: failed to deliver diagnostic", err, telemetry.URI.Of(key.id.URI))
+				event.Error(ctx, "publishReports: failed to deliver diagnostic", err, tag.URI.Of(key.id.URI))
 			}
 			continue
 		}
diff --git a/internal/lsp/generate.go b/internal/lsp/generate.go
index 440ab28..08840aa 100644
--- a/internal/lsp/generate.go
+++ b/internal/lsp/generate.go
@@ -12,8 +12,8 @@
 	"strconv"
 
 	"golang.org/x/tools/internal/gocommand"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/protocol"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/telemetry/event"
 	errors "golang.org/x/xerrors"
 )
@@ -60,7 +60,7 @@
 }
 
 func (ew *eventWriter) Write(p []byte) (n int, err error) {
-	event.Print(ew.ctx, string(p), telemetry.Operation.Of("generate"))
+	event.Print(ew.ctx, string(p), tag.Operation.Of("generate"))
 	return len(p), nil
 }
 
diff --git a/internal/lsp/highlight.go b/internal/lsp/highlight.go
index 5d31bfe..9ff37e9 100644
--- a/internal/lsp/highlight.go
+++ b/internal/lsp/highlight.go
@@ -7,9 +7,9 @@
 import (
 	"context"
 
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/protocol"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/telemetry/event"
 )
 
@@ -20,7 +20,7 @@
 	}
 	rngs, err := source.Highlight(ctx, snapshot, fh, params.Position)
 	if err != nil {
-		event.Error(ctx, "no highlight", err, telemetry.URI.Of(params.TextDocument.URI))
+		event.Error(ctx, "no highlight", err, tag.URI.Of(params.TextDocument.URI))
 	}
 	return toProtocolHighlight(rngs), nil
 }
diff --git a/internal/lsp/lsprpc/telemetry.go b/internal/lsp/lsprpc/telemetry.go
index bc6aaa9..1599a1e 100644
--- a/internal/lsp/lsprpc/telemetry.go
+++ b/internal/lsp/lsprpc/telemetry.go
@@ -10,7 +10,7 @@
 	"time"
 
 	"golang.org/x/tools/internal/jsonrpc2"
-	"golang.org/x/tools/internal/lsp/telemetry"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/telemetry/event"
 )
 
@@ -39,16 +39,16 @@
 		payload:   r.Params,
 	}
 	ctx = context.WithValue(ctx, statsKey, stats)
-	mode := telemetry.Outbound
+	mode := tag.Outbound
 	if direction == jsonrpc2.Receive {
-		mode = telemetry.Inbound
+		mode = tag.Inbound
 	}
 	ctx, stats.close = event.StartSpan(ctx, r.Method,
-		telemetry.Method.Of(r.Method),
-		telemetry.RPCDirection.Of(mode),
-		telemetry.RPCID.Of(r.ID),
+		tag.Method.Of(r.Method),
+		tag.RPCDirection.Of(mode),
+		tag.RPCID.Of(r.ID),
 	)
-	telemetry.Started.Record(ctx, 1)
+	tag.Started.Record(ctx, 1)
 	_, stats.delivering = event.StartSpan(ctx, "queued")
 	return ctx
 }
@@ -60,23 +60,23 @@
 func (h telemetryHandler) Done(ctx context.Context, err error) {
 	stats := h.getStats(ctx)
 	if err != nil {
-		ctx = event.Label(ctx, telemetry.StatusCode.Of("ERROR"))
+		ctx = event.Label(ctx, tag.StatusCode.Of("ERROR"))
 	} else {
-		ctx = event.Label(ctx, telemetry.StatusCode.Of("OK"))
+		ctx = event.Label(ctx, tag.StatusCode.Of("OK"))
 	}
 	elapsedTime := time.Since(stats.start)
 	latencyMillis := float64(elapsedTime) / float64(time.Millisecond)
-	telemetry.Latency.Record(ctx, latencyMillis)
+	tag.Latency.Record(ctx, latencyMillis)
 	stats.close()
 }
 
 func (h telemetryHandler) Read(ctx context.Context, bytes int64) context.Context {
-	telemetry.SentBytes.Record(ctx, bytes)
+	tag.SentBytes.Record(ctx, bytes)
 	return ctx
 }
 
 func (h telemetryHandler) Wrote(ctx context.Context, bytes int64) context.Context {
-	telemetry.ReceivedBytes.Record(ctx, bytes)
+	tag.ReceivedBytes.Record(ctx, bytes)
 	return ctx
 }
 
@@ -88,7 +88,7 @@
 func (h telemetryHandler) getStats(ctx context.Context) *rpcStats {
 	stats, ok := ctx.Value(statsKey).(*rpcStats)
 	if !ok || stats == nil {
-		method, ok := ctx.Value(telemetry.Method).(string)
+		method, ok := ctx.Value(tag.Method).(string)
 		if !ok {
 			method = "???"
 		}
diff --git a/internal/lsp/mod/code_lens.go b/internal/lsp/mod/code_lens.go
index 241e48d..7f76a5b 100644
--- a/internal/lsp/mod/code_lens.go
+++ b/internal/lsp/mod/code_lens.go
@@ -6,9 +6,9 @@
 	"strings"
 
 	"golang.org/x/mod/modfile"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/protocol"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/span"
 	"golang.org/x/tools/internal/telemetry/event"
 )
@@ -22,7 +22,7 @@
 	if uri != realURI {
 		return nil, nil
 	}
-	ctx, done := event.StartSpan(ctx, "mod.CodeLens", telemetry.File.Of(realURI))
+	ctx, done := event.StartSpan(ctx, "mod.CodeLens", tag.File.Of(realURI))
 	defer done()
 
 	fh, err := snapshot.GetFile(realURI)
diff --git a/internal/lsp/mod/diagnostics.go b/internal/lsp/mod/diagnostics.go
index 1ce54be..ac72e7a 100644
--- a/internal/lsp/mod/diagnostics.go
+++ b/internal/lsp/mod/diagnostics.go
@@ -12,9 +12,9 @@
 	"regexp"
 
 	"golang.org/x/mod/modfile"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/protocol"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/telemetry/event"
 )
 
@@ -27,7 +27,7 @@
 		return nil, nil, nil
 	}
 
-	ctx, done := event.StartSpan(ctx, "mod.Diagnostics", telemetry.File.Of(realURI))
+	ctx, done := event.StartSpan(ctx, "mod.Diagnostics", tag.File.Of(realURI))
 	defer done()
 
 	realfh, err := snapshot.GetFile(realURI)
@@ -97,7 +97,7 @@
 				for uri, edits := range fix.Edits {
 					fh, err := snapshot.GetFile(uri)
 					if err != nil {
-						event.Error(ctx, "no file", err, telemetry.URI.Of(uri))
+						event.Error(ctx, "no file", err, tag.URI.Of(uri))
 						continue
 					}
 					action.Edit.DocumentChanges = append(action.Edit.DocumentChanges, protocol.TextDocumentEdit{
@@ -126,7 +126,7 @@
 		return nil, nil
 	}
 
-	ctx, done := event.StartSpan(ctx, "mod.SuggestedGoFixes", telemetry.File.Of(realURI))
+	ctx, done := event.StartSpan(ctx, "mod.SuggestedGoFixes", tag.File.Of(realURI))
 	defer done()
 
 	realfh, err := snapshot.GetFile(realURI)
diff --git a/internal/lsp/source/completion_format.go b/internal/lsp/source/completion_format.go
index 815cdd9..5144ba5 100644
--- a/internal/lsp/source/completion_format.go
+++ b/internal/lsp/source/completion_format.go
@@ -14,9 +14,9 @@
 	"strings"
 
 	"golang.org/x/tools/internal/imports"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/protocol"
 	"golang.org/x/tools/internal/lsp/snippet"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/span"
 	"golang.org/x/tools/internal/telemetry/event"
 	errors "golang.org/x/xerrors"
@@ -196,7 +196,7 @@
 	}
 	hover, err := ident.Hover(c.ctx)
 	if err != nil {
-		event.Error(c.ctx, "failed to find Hover", err, telemetry.URI.Of(uri))
+		event.Error(c.ctx, "failed to find Hover", err, tag.URI.Of(uri))
 		return item, nil
 	}
 	item.Documentation = hover.Synopsis
diff --git a/internal/lsp/source/diagnostics.go b/internal/lsp/source/diagnostics.go
index d308ac3..b6ca43c 100644
--- a/internal/lsp/source/diagnostics.go
+++ b/internal/lsp/source/diagnostics.go
@@ -13,8 +13,8 @@
 
 	"golang.org/x/mod/modfile"
 	"golang.org/x/tools/go/analysis"
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/protocol"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/span"
 	"golang.org/x/tools/internal/telemetry/event"
 	errors "golang.org/x/xerrors"
@@ -128,7 +128,7 @@
 			if ctx.Err() != nil {
 				return nil, warn, ctx.Err()
 			}
-			event.Error(ctx, "failed to run analyses", err, telemetry.Package.Of(ph.ID()))
+			event.Error(ctx, "failed to run analyses", err, tag.Package.Of(ph.ID()))
 		}
 	}
 	return reports, warn, nil
@@ -163,7 +163,7 @@
 }
 
 func diagnostics(ctx context.Context, snapshot Snapshot, reports map[FileIdentity][]Diagnostic, pkg Package, hasMissingDeps bool) (bool, error) {
-	ctx, done := event.StartSpan(ctx, "source.diagnostics", telemetry.Package.Of(pkg.ID()))
+	ctx, done := event.StartSpan(ctx, "source.diagnostics", tag.Package.Of(pkg.ID()))
 	_ = ctx // circumvent SA4006
 	defer done()
 
diff --git a/internal/lsp/symbols.go b/internal/lsp/symbols.go
index 5f6824a..11e89e1 100644
--- a/internal/lsp/symbols.go
+++ b/internal/lsp/symbols.go
@@ -7,9 +7,9 @@
 import (
 	"context"
 
+	"golang.org/x/tools/internal/lsp/debug/tag"
 	"golang.org/x/tools/internal/lsp/protocol"
 	"golang.org/x/tools/internal/lsp/source"
-	"golang.org/x/tools/internal/lsp/telemetry"
 	"golang.org/x/tools/internal/telemetry/event"
 )
 
@@ -23,7 +23,7 @@
 	}
 	docSymbols, err := source.DocumentSymbols(ctx, snapshot, fh)
 	if err != nil {
-		event.Error(ctx, "DocumentSymbols failed", err, telemetry.URI.Of(fh.Identity().URI))
+		event.Error(ctx, "DocumentSymbols failed", err, tag.URI.Of(fh.Identity().URI))
 		return []interface{}{}, nil
 	}
 	// Convert the symbols to an interface array.