Skip to content

Commit 1cc80ad

Browse files
adonovangopherbot
authored andcommitted
internal/event/export/ocagent: delete
We never use it, and OpenCensus is officially moribund. Change-Id: I0095f996c58954c238be7875694ee62dd721b3f2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/653016 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]> Commit-Queue: Alan Donovan <[email protected]> Auto-Submit: Alan Donovan <[email protected]>
1 parent 8f4b8cd commit 1cc80ad

File tree

18 files changed

+10
-1766
lines changed

18 files changed

+10
-1766
lines changed

gopls/internal/cmd/cmd.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ type Application struct {
6363
// VeryVerbose enables a higher level of verbosity in logging output.
6464
VeryVerbose bool `flag:"vv,veryverbose" help:"very verbose output"`
6565

66-
// Control ocagent export of telemetry
67-
OCAgent string `flag:"ocagent" help:"the address of the ocagent (e.g. http://localhost:55678), or off"`
68-
6966
// PrepareOptions is called to update the options when a new view is built.
7067
// It is primarily to allow the behavior of gopls to be modified by hooks.
7168
PrepareOptions func(*settings.Options)
@@ -98,8 +95,6 @@ func (app *Application) verbose() bool {
9895
// New returns a new Application ready to run.
9996
func New() *Application {
10097
app := &Application{
101-
OCAgent: "off", //TODO: Remove this line to default the exporter to on
102-
10398
Serve: Serve{
10499
RemoteListenTimeout: 1 * time.Minute,
105100
},
@@ -238,7 +233,7 @@ func (app *Application) Run(ctx context.Context, args ...string) error {
238233
// executable, and immediately runs a gc.
239234
filecache.Start()
240235

241-
ctx = debug.WithInstance(ctx, app.OCAgent)
236+
ctx = debug.WithInstance(ctx)
242237
if len(args) == 0 {
243238
s := flag.NewFlagSet(app.Name(), flag.ExitOnError)
244239
return tool.Run(ctx, s, &app.Serve, args)

gopls/internal/cmd/usage/usage-v.hlp

-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ flags:
6161
filename to log to. if value is "auto", then logging to a default output file is enabled
6262
-mode=string
6363
no effect
64-
-ocagent=string
65-
the address of the ocagent (e.g. http://localhost:55678), or off (default "off")
6664
-port=int
6765
port on which to run gopls for debugging purposes
6866
-profile.alloc=string

gopls/internal/cmd/usage/usage.hlp

-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ flags:
5858
filename to log to. if value is "auto", then logging to a default output file is enabled
5959
-mode=string
6060
no effect
61-
-ocagent=string
62-
the address of the ocagent (e.g. http://localhost:55678), or off (default "off")
6361
-port=int
6462
port on which to run gopls for debugging purposes
6563
-profile.alloc=string

gopls/internal/debug/serve.go

+2-13
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
"golang.org/x/tools/internal/event/core"
3434
"golang.org/x/tools/internal/event/export"
3535
"golang.org/x/tools/internal/event/export/metric"
36-
"golang.org/x/tools/internal/event/export/ocagent"
3736
"golang.org/x/tools/internal/event/export/prometheus"
3837
"golang.org/x/tools/internal/event/keys"
3938
"golang.org/x/tools/internal/event/label"
@@ -51,13 +50,11 @@ type Instance struct {
5150
Logfile string
5251
StartTime time.Time
5352
ServerAddress string
54-
OCAgentConfig string
5553

5654
LogWriter io.Writer
5755

5856
exporter event.Exporter
5957

60-
ocagent *ocagent.Exporter
6158
prometheus *prometheus.Exporter
6259
rpcs *Rpcs
6360
traces *traces
@@ -363,16 +360,11 @@ func GetInstance(ctx context.Context) *Instance {
363360

364361
// WithInstance creates debug instance ready for use using the supplied
365362
// configuration and stores it in the returned context.
366-
func WithInstance(ctx context.Context, agent string) context.Context {
363+
func WithInstance(ctx context.Context) context.Context {
367364
i := &Instance{
368-
StartTime: time.Now(),
369-
OCAgentConfig: agent,
365+
StartTime: time.Now(),
370366
}
371367
i.LogWriter = os.Stderr
372-
ocConfig := ocagent.Discover()
373-
//TODO: we should not need to adjust the discovered configuration
374-
ocConfig.Address = i.OCAgentConfig
375-
i.ocagent = ocagent.Connect(ocConfig)
376368
i.prometheus = prometheus.New()
377369
i.rpcs = &Rpcs{}
378370
i.traces = &traces{}
@@ -541,9 +533,6 @@ func messageType(l log.Level) protocol.MessageType {
541533

542534
func makeInstanceExporter(i *Instance) event.Exporter {
543535
exporter := func(ctx context.Context, ev core.Event, lm label.Map) context.Context {
544-
if i.ocagent != nil {
545-
ctx = i.ocagent.ProcessEvent(ctx, ev, lm)
546-
}
547536
if i.prometheus != nil {
548537
ctx = i.prometheus.ProcessEvent(ctx, ev, lm)
549538
}

gopls/internal/lsprpc/lsprpc_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func TestClientLogging(t *testing.T) {
5858
server := PingServer{}
5959
client := FakeClient{Logs: make(chan string, 10)}
6060

61-
ctx = debug.WithInstance(ctx, "")
61+
ctx = debug.WithInstance(ctx)
6262
ss := NewStreamServer(cache.New(nil), false, nil).(*StreamServer)
6363
ss.serverForTest = server
6464
ts := servertest.NewPipeServer(ss, nil)
@@ -121,7 +121,7 @@ func checkClose(t *testing.T, closer func() error) {
121121

122122
func setupForwarding(ctx context.Context, t *testing.T, s protocol.Server) (direct, forwarded servertest.Connector, cleanup func()) {
123123
t.Helper()
124-
serveCtx := debug.WithInstance(ctx, "")
124+
serveCtx := debug.WithInstance(ctx)
125125
ss := NewStreamServer(cache.New(nil), false, nil).(*StreamServer)
126126
ss.serverForTest = s
127127
tsDirect := servertest.NewTCPServer(serveCtx, ss, nil)
@@ -214,8 +214,8 @@ func TestDebugInfoLifecycle(t *testing.T) {
214214

215215
baseCtx, cancel := context.WithCancel(context.Background())
216216
defer cancel()
217-
clientCtx := debug.WithInstance(baseCtx, "")
218-
serverCtx := debug.WithInstance(baseCtx, "")
217+
clientCtx := debug.WithInstance(baseCtx)
218+
serverCtx := debug.WithInstance(baseCtx)
219219

220220
cache := cache.New(nil)
221221
ss := NewStreamServer(cache, false, nil)

gopls/internal/test/integration/runner.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (r *Runner) Run(t *testing.T, files string, test TestFunc, opts ...RunOptio
173173
}
174174

175175
// TODO(rfindley): do we need an instance at all? Can it be removed?
176-
ctx = debug.WithInstance(ctx, "off")
176+
ctx = debug.WithInstance(ctx)
177177

178178
rootDir := filepath.Join(r.tempDir, filepath.FromSlash(t.Name()))
179179
if err := os.MkdirAll(rootDir, 0755); err != nil {
@@ -349,7 +349,7 @@ func (r *Runner) defaultServer() jsonrpc2.StreamServer {
349349
func (r *Runner) forwardedServer() jsonrpc2.StreamServer {
350350
r.tsOnce.Do(func() {
351351
ctx := context.Background()
352-
ctx = debug.WithInstance(ctx, "off")
352+
ctx = debug.WithInstance(ctx)
353353
ss := lsprpc.NewStreamServer(cache.New(nil), false, nil)
354354
r.ts = servertest.NewTCPServer(ctx, ss, nil)
355355
})

gopls/internal/test/marker/marker_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ func newEnv(t *testing.T, cache *cache.Cache, files, proxyFiles map[string][]byt
964964
// Put a debug instance in the context to prevent logging to stderr.
965965
// See associated TODO in runner.go: we should revisit this pattern.
966966
ctx := context.Background()
967-
ctx = debug.WithInstance(ctx, "off")
967+
ctx = debug.WithInstance(ctx)
968968

969969
awaiter := integration.NewAwaiter(sandbox.Workdir)
970970
ss := lsprpc.NewStreamServer(cache, false, nil)

internal/event/export/ocagent/README.md

-139
This file was deleted.

0 commit comments

Comments
 (0)