Conversation
bc9bc03 to
fedd677
Compare
Fixes #35. Track the queue time by using an extra haeder to track when the task is added to the queue and comparing when it gets executed. This should work in most setups but if the celery app isn't all set up on the producer side, we are well defended against it. Like #205, I manually tested on Celery 3.1.x locally by editing `tox.ini` and reinstalling with `tox -r`.
Fixes #35. Track the queue time by using an extra haeder to track when the task is added to the queue and comparing when it gets executed. This should work in most setups but if the celery app isn't all set up on the producer side, we are well defended against it. Like #205, I manually tested on Celery 3.1.x locally by editing `tox.ini` and reinstalling with `tox -r`.
Fixes #35. Track the queue time by using an extra haeder to track when the task is added to the queue and comparing when it gets executed. This should work in most setups but if the celery app isn't all set up on the producer side, we are well defended against it. Like #205, I manually tested on Celery 3.1.x locally by editing `tox.ini` and reinstalling with `tox -r`.
dlanderson
left a comment
There was a problem hiding this comment.
A few questions around changing method signatures and tags
src/scout_apm/celery.py
Outdated
| span.tag("is_eager", delivery_info.get("is_eager", False)) | ||
| span.tag("exchange", delivery_info.get("exchange", "unknown")) | ||
| span.tag("routing_key", delivery_info.get("routing_key", "unknown")) | ||
| span.tag("queue", delivery_info.get("queue", "unknown")) |
There was a problem hiding this comment.
I think the core agent knows how to handle the queue tag, but the others are not supported explicitly and will be silently dropped, IIRC. Are we wanting to track this info in span tags or in context? @cschneid might chime in here.
There was a problem hiding this comment.
Aha, I didn't know that span tags are dropped. Moving to request tags/context is probably the right move in that case, but I'll wait for @cschneid 's input.
There was a problem hiding this comment.
Currently in the core agent, span tags are very specific, and unknown ones are dropped. Some upcoming work will be to support the new trace structure, where arbitrary span tags are sent onward, but that's not for a bit. queue is recognized as the string queue name that the job was enqueued on & then popped off of.
For now it's probably ok to add these as request tags (context). But anyway, this does feel like it's scoped to the whole request (the job), not just the section of code that celery is calling first..
There was a problem hiding this comment.
Moving them all to request tags then. I think I had a concern that celery might recursively execute tasks with its fancy chord structures, but after checking the docs again I don't think that's the case
fedd677 to
91380a1
Compare
Fixes #34. Tagging with the current *queue* is only *sometimes* possible - often the *exchange* and *routing_key* are provided instead. The task may have come from a particular queue, but its delivery information normally onyl tracks where it was sent at the top of the AMQP funnel by exchange + routing_key, since that's what's needed for retry. Also track the `is_eager` flag which may be useful for determining which way the task was run. More information on these parameters can be gleaned from [the source](https://github.com/celery/celery/blob/8cf8fae70630954cff3448485588bbe2a77ff3ab/celery/app/task.py#L600). Updating the tests to use the fixture added in Celery 4.0, but since we support 3.1 this is in a conditional test. Our test suite currently installs the latest version of Celery only, so I tested locally temporarily with Celery 3.1 as well by specifying `celery>=3.1,<3.2` in `tox.ini`. For complete automated testing in the future, we should look at a better requirements management system.
91380a1 to
0881794
Compare
Fixes #35. Track the queue time by using an extra haeder to track when the task is added to the queue and comparing when it gets executed. This should work in most setups but if the celery app isn't all set up on the producer side, we are well defended against it. Like #205, I manually tested on Celery 3.1.x locally by editing `tox.ini` and reinstalling with `tox -r`.
Fixes #35. Track the queue time by using an extra haeder to track when the task is added to the queue and comparing when it gets executed. This should work in most setups but if the celery app isn't all set up on the producer side, we are well defended against it. Like #205, I manually tested on Celery 3.1.x locally by editing `tox.ini` and reinstalling with `tox -r`.
Fixes #35. Track the queue time by using an extra haeder to track when the task is added to the queue and comparing when it gets executed. This should work in most setups but if the celery app isn't all set up on the producer side, we are well defended against it. Like #205, I manually tested on Celery 3.1.x locally by editing `tox.ini` and reinstalling with `tox -r`.
Fixes #34. Tagging with the current queue is only sometimes possible - often the exchange and routing_key are provided instead. The task may have come from a particular queue, but its delivery information normally onyl tracks where it was sent at the top of the AMQP funnel by exchange + routing_key, since that's what's needed for retry. Also track the
is_eagerflag which may be useful for determining which way the task was run.More information on these parameters can be gleaned from the source.
Updating the tests to use the fixture added in Celery 4.0, but since we support 3.1 this is in a conditional test. Our test suite currently installs the latest version of Celery only, so I tested locally temporarily with Celery 3.1 as well by specifying
celery>=3.1,<3.2intox.ini. For complete automated testing in the future, we should look at a better requirements management system.