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

Add ability to flush during response cache for celery #24

Merged
merged 2 commits into from
Mar 23, 2024

Conversation

stevenbunting
Copy link
Collaborator

The way celery forks the existing main process ends up being problematic for the supergood python client.

It makes a copy of all the in-memory items on the client, but does NOT copy over the threads running on the main thread. This means remote configs will not get updated in the background, and flushes won't occur in the background. There's a few ways we're thinking of addressing this.

In the short term:
This PR ensures that the forked celery worker will still report events to supergood. The downside is we can't make use of batching like we can in the main thread, but it was a quick option to ensure we don't miss events.

In the medium term:
we're thinking about utilizing disk writes on forked threads so we can bundle those up on either the main thread or in a sidecar agent. This will remove the synchronous redact and post from the celery worker and offload it to the main thread / sidecar which are more long-running

In the long term:
we're investigating eBPF solutions

Tested on a dummy django server with simple celery workers making http calls

@@ -356,7 +372,7 @@ def flush_cache(self, force=False) -> None:
except Exception:
# something is really messed up, just report out
payload = self._build_log_payload()
self.log.error(ERRORS["POSTING_EVENTS"], trace, payload)
self.log.error(ERRORS["POSTING_EVENTS"], trace, payload)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was a pre-existing bug I caught during testing

@stevenbunting stevenbunting merged commit 0e433b5 into master Mar 23, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants