Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] docker observer: Ensure routines are managed without storing context #38378

Conversation

MovieStoreGuy
Copy link
Contributor

Description

This follows the go practice of avoiding storing context as part of a structure and passing it through method invocations.

Link to tracking issue

Fixes NA

Testing

This should keep the same behaviour

Documentation

Transparent user change, not added.

@MovieStoreGuy MovieStoreGuy force-pushed the msg/ensure-controlled-routines branch from cc26f63 to 3422e8a Compare March 5, 2025 02:15
@MovieStoreGuy MovieStoreGuy added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Mar 5, 2025
@MovieStoreGuy MovieStoreGuy changed the title [chore] docker observer: Ensure routines are managed with storing context [chore] docker observer: Ensure routines are managed without storing context Mar 5, 2025
once *sync.Once
ctx context.Context
cancel context.CancelFunc
wg errgroup.Group
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to store cancel? We can probably initialize wg using WithContext instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So looking at the errgroup in more detail, when initialised with errgroup.WithContext, the group.Wait method will first wait for all routines to finish and then call cancel.

In this scenario, we need it the other way around so that the routines are shutdown and then wait for the routines to cleanly stop.

@MovieStoreGuy MovieStoreGuy merged commit 2d3edff into open-telemetry:main Mar 5, 2025
156 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension/observer Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants