-
Notifications
You must be signed in to change notification settings - Fork 797
Do not keep task id reference indefinitely in Celery instrumenation #3690
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
base: main
Are you sure you want to change the base?
Changes from all commits
ab1247d
e1e723b
a4ab037
1a18034
c4c5de3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,8 @@ def test_basic_metric(self): | |
task_runtime_estimated = (default_timer() - start_time) * 1000 | ||
|
||
metrics = self.get_metrics() | ||
self.assertEqual(CeleryInstrumentor().task_id_to_start_time, {}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should another test be added where the task_id does not exist and the pop operation returns None instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would that test matter actually? We're not testing return value of the |
||
|
||
CeleryInstrumentor().uninstrument() | ||
self.assertEqual(len(metrics), 1) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is that we are leaking? On line 355 we are setting this a time object so don't expect to keep alive something on the celery side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
task_id_to_start_time
is a dictionary initialised withCeleryInstrumentor
. Each time a task finishes the dictionary is augmented with a record of time spent for that task id. In the current state the dictionary just keeps growing even though the task finished long time ago (task identifiers are normally unique). There are no references to any other Python objects that prevent GC, it's just this relatively small issue.