opentelemetry-collector-contrib icon indicating copy to clipboard operation
opentelemetry-collector-contrib copied to clipboard

[exporter/signalfx] Fix goroutine leaks

Open crobert-1 opened this issue 9 months ago • 10 comments

Description: <Describe what has changed.>

This change is a refactor to allow us to enable goleak checks in each of the exporter's sub-directories, as well as the signalfx receiver (which uses the signalfxexporter in a test). The main idea is to use start/shutdown for each package's functionality, rather than relying on the top level context cancel of the exporter. The addition of start and shutdowns for each package means we can more closely control the lifecycle of each as needed, and enable goleak for each package.

The memory leaks being fixed are:

  1. Call the TTLMap.Shutdown so the ticker is properly stopped: t.prevPts.Shutdown().
  2. Don't block waiting for a request if the context is cancelled.

Link to tracking issue: #30438

crobert-1 avatar Apr 30 '24 18:04 crobert-1

~Did some more testing, looks like I've broken something during shutdown. I'll investigate and move back to ready to review when I've figured out what's going on.~

Nevermind, I was running tests using the hostmetrics receiver and didn't realize it blocks shutdown until active scrape operations are complete. I tested with debug exporter, and signalfx exporter before these changes, and everything is working as previously.

crobert-1 avatar May 03 '24 22:05 crobert-1

This PR was marked stale due to lack of activity. It will be closed in 14 days.

github-actions[bot] avatar May 21 '24 05:05 github-actions[bot]