cockroachdb / cockroachdb/cockroach
obs: review context usage in `(*EventsExporter).Start`
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
Consider the following code:
https://github.com/cockroachdb/cockroach/blob/d9ec7443a8bc749d12821d2e2c46aec870dd57ff/pkg/obs/event_exporter.go#L297-L332
When the context is canceled in `case <-ctx.Done()`, we don't return from `(*EventsExporter).Start()` because there's an attempt to "flush everything". The actual flushing to the `otelClient`, however, reuses the same `ctx` instance that we know is already canceled, so that will be a no-op (the error will be logged, but nothing will actually be exported).
We should either return on `ctx.Done()` (making it clear no export will take place), or use a different context in the call to `Export()` (care would need to be taken to avoid hanging since the context passed to `Start` is already canceled).
Jira issue: CRDB-36912
Contributor guide
Assessment
This issue has not been assessed yet.