diff --git a/internal/lsp/diagnostics.go b/internal/lsp/diagnostics.go index 6f62167d0b..85e9416fe9 100644 --- a/internal/lsp/diagnostics.go +++ b/internal/lsp/diagnostics.go @@ -36,6 +36,8 @@ func (s *Server) diagnose(ctx context.Context, snapshot source.Snapshot) { ctx, done := trace.StartSpan(ctx, "lsp:background-worker") defer done() + ctx = telemetry.Snapshot.With(ctx, snapshot.ID()) + // Diagnose all of the packages in the workspace. go func() { wsPackages, err := snapshot.WorkspacePackages(ctx) @@ -148,7 +150,9 @@ func (s *Server) publishReports(ctx context.Context, snapshot source.Snapshot, r URI: protocol.NewURI(fileID.URI), Version: fileID.Version, }); err != nil { - log.Error(ctx, "publishReports: failed to deliver diagnostic", err, telemetry.File) + if ctx.Err() == nil { + log.Error(ctx, "publishReports: failed to deliver diagnostic", err, telemetry.File) + } continue } // Update the delivered map. diff --git a/internal/lsp/telemetry/telemetry.go b/internal/lsp/telemetry/telemetry.go index 71c54a72a9..e55e278c14 100644 --- a/internal/lsp/telemetry/telemetry.go +++ b/internal/lsp/telemetry/telemetry.go @@ -25,6 +25,7 @@ const ( Package = tag.Key("package") PackagePath = tag.Key("package_path") Query = tag.Key("query") + Snapshot = tag.Key("snapshot") ) var (