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 instrumentation for Celery #780

Merged

Conversation

majorgreys
Copy link
Contributor

Resolves #629 and supersedes #648.

This is largely a migration of the Datadog-donated integration of Celery though I have made an effort here to add tests for asynchronous tasks. In order to do so, I have used the pytest fixtures provided by Celery. At times I've had to add workarounds for known issues in celery.

As a follow-up on this PR, we should address the requests for better handling revoked and rejected tasks #648 (review) and canvases #648 (comment).

mauriciovasquezbernal and others added 18 commits May 4, 2020 12:16
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
…quezbernal/opentelemetry-python into mauricio/instrumentor-celery
@majorgreys majorgreys requested a review from a team June 4, 2020 23:33
Comment on lines 86 to 87
# pylint: disable=unused-argument
def _instrument(self, **kwargs):
Copy link

@turbaszek turbaszek Jun 11, 2020

Choose a reason for hiding this comment

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

Using pylint disable in this place disables the check for all next lines I think, docs:
http://pylint.pycqa.org/en/latest/user_guide/message-control.html

If this is used only because of kwargs then wouldn't it be reasonable to add args and kwargs to pylintrc as ignored? It seems that it can be common case. WDYT?

# Argument names that match this expression will be ignored. Default to name
# with leading underscore.
ignored-argument-names=_.*|^ignored_|^unused_|^kwargs|^args|^mock_.+

task_id = retrieve_task_id(kwargs)
if task is None or task_id is None:
logger.debug(
"Unable to extract the Task and the task_id. This version of Celery may not be supported."

Choose a reason for hiding this comment

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

Seeing this log message, as I user I would wonder where can I find information about supported Celery versions. Is it possible to add some link / information about places where can I look for those?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to be conclusive about the Celery versions that are not supported? Letting the user know that this version may not be supported is not that useful.

Copy link
Contributor

Choose a reason for hiding this comment

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

This check is repeated several times, can it be placed in its own function?

Choose a reason for hiding this comment

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

This check is repeated several times, can it be placed in its own function?

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've pulled these out as much as I could into utility functions, though the signatures for the signals we handle differ slightly.

Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

Just some suggestions


[options.extras_require]
test =
pytest
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this have a version specified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are using latest elsewhere in the code

task_id = retrieve_task_id(kwargs)
if task is None or task_id is None:
logger.debug(
"Unable to extract the Task and the task_id. This version of Celery may not be supported."
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to be conclusive about the Celery versions that are not supported? Letting the user know that this version may not be supported is not that useful.

task_id = retrieve_task_id(kwargs)
if task is None or task_id is None:
logger.debug(
"Unable to extract the Task and the task_id. This version of Celery may not be supported."
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is repeated several times, can it be placed in its own function?

tox.ini Outdated Show resolved Hide resolved
Copy link
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

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

A couple comments that are carried over from #648. But so close!

I'm going to close out #648 since we're almost there.

ext/opentelemetry-ext-celery/setup.cfg Outdated Show resolved Hide resolved
ext/opentelemetry-ext-celery/setup.cfg Outdated Show resolved Hide resolved
Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 15, 2020

CLA Check

  • Mauricio Vásquez The commit (4e49915 ,7094ec4d44b6a19007ca9d0204efabe779b47bed ,8b0f2e524885f58c963ba85128107a7b457fc50f ,df5bf4819ce757c276fdaab27e545b5db14f33a8 ,5ae56261bd272bc131c04614cb6c3c75876fc2d0 ,001527e51f773753075397c513d2ad6ca94a35d3 ,eb05bae2c060418b8be244ac6171b36f389cf4a4 ,0b590c6876c52605df5737eab9da3a7a77358735 ,d8aead4b8ed679a1725348ac60c13700029cf9a7 ,c2b7561f6c135d9454217a750070f3330e481c42 ,b0e0720690897bc2181df2aca1b6d38856170395 ,a571304573f65303b5a4c8b5ecd434b2664207e4 ,3d94aed346b5d2f07cfb702474a105355800b703 ,606595e3b8c73f30c886ef24bcec74d707939949 ,db71469e10539c8ed340958d3d7df1b4d67b53f6 ,ba6db4ec5c0a562325e84513431daa0657b26490) is not authorized under a signed CLA. Please click here to be authorized. For further assistance with EasyCLA, please submit a support request ticket.

@majorgreys majorgreys force-pushed the majorgreys/instrumentor-celery branch from a6dc985 to 21cac5b Compare June 16, 2020 19:20
@majorgreys majorgreys force-pushed the majorgreys/instrumentor-celery branch from 21cac5b to 3eae958 Compare June 16, 2020 19:27
tox.ini Outdated Show resolved Hide resolved
@codeboten
Copy link
Contributor

@toumorokoshi can you confirm all your comments have been addressed and approve if they have. Would be good to get this one in

Copy link
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

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

LGTM! thanks for addressing.

@toumorokoshi toumorokoshi merged commit a284367 into open-telemetry:master Jun 17, 2020
@thedrow
Copy link

thedrow commented Jul 2, 2020

If someone wants to mention this in Celery's docs I'd be happy to merge that PR.

srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
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.

Add instrumentation for celery
9 participants