Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

goroutine leak detected  #1191

Open
Open
@adamdecaf

Description

@adamdecaf

Please answer these questions before submitting a bug report.

What version of OpenCensus are you using?

v0.22.0

What version of Go are you using?

go1.13.6

What did you do?

I was running the new goleak tool on my codebase and ran into a leak coming from OpenCensus.

goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine 37 in state select, with go.opencensus.io/stats/view.(*worker).start on top of the stack:
goroutine 37 [select]:
go.opencensus.io/stats/view.(*worker).start(0xc000143310)
	/Users/adam/code/pkg/mod/[email protected]/stats/view/worker.go:154 +0x100
created by go.opencensus.io/stats/view.init.0
	/Users/adam/code/pkg/mod/[email protected]/stats/view/worker.go:32 +0x57
]

What did you expect to see?

I expected no goroutine leaks in libraries I depend on.

What did you see instead?

A crash from goleaks.

Additional context

I'm pulling this library in via gocloud.dev/secrets v0.17.0, but that doesn't matter here since v0.22.0 of OpenCensus is used in both.

This appears to be coming from internal global state of a default recorder being set.

https://github.com/census-instrumentation/opencensus-go/blob/v0.22.0/stats/view/worker.go#L30-L34

Also, there doesn't seem to be a way to retrieve this reporter to shutdown on application shutdown.

https://github.com/census-instrumentation/opencensus-go/search?q=DefaultRecorder&unscoped_q=DefaultRecorder

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions