-
Notifications
You must be signed in to change notification settings - Fork 803
celery: allow using links instead of child spans for task execution #3779
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?
celery: allow using links instead of child spans for task execution #3779
Conversation
| SpanAttributes.MESSAGING_DESTINATION: "celery", | ||
| }, | ||
| ) |
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.
This section of code is just duplicated from test_task, the remaining assertions below are the only meaningful changes
b87b7a0 to
541face
Compare
541face to
b87b7a0
Compare
99cc8be to
4f1eda6
Compare
|
@xrmx just rebased latest from main onto this branch, lmk if it's easier for your review process to just let it drift and rebase after you've reviewed |
| The ``CeleryInstrumentor().instrument()`` method accepts the following arguments: | ||
| * ``use_links`` (bool): When ``True``, Celery task execution spans will be linked to the |
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.
From #3002 (comment) I understand we should always add links but make the parent / child relationship optional instead?
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.
It seems a "one-or-the-other" situation to me...
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.
It seems a "one-or-the-other" situation to me...
Agreed, I went with a default of False since it seemed like this would be a pretty major change for consumers of this package that weren't expecting the update without warning, whilst still giving consumers who care about this an option to opt-out of the current behaviour.
Maybe the changing of the default from False to True could be packaged up in a future release and a warning logged mentioning the change in that future release so people are aware of the incoming change?
Personally no objection from my side for changing the default though so if this isn't as contentious as I'm imagining it would be then I'm happy to flip the value.
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.
@xrmx are you happy with this approach? As mentioned I don't feel strongly either way but don't want to leave this PR open too long and end up drifting from main.
| tracer_provider, | ||
| schema_url="https://opentelemetry.io/schemas/1.11.0", | ||
| ) | ||
| # pylint: disable=attribute-defined-outside-init |
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.
Not related to this PR, but this pylint rule seems useless in this project, can we disable it?
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.
True... I added it to keep it consistent with the rest of the file but I'll add an issue to the project for this
...on/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/__init__.py
Outdated
Show resolved
Hide resolved
d6f5fa1 to
3bd9d2e
Compare
Description
As described in #3002, the current default behaviour results in all celery tasks that execute are child spans of the code that pushed it on to the broker, which conflicts with the semantic conventions.
This PR doesn't change the default behaviour since this may be undesirable for consumers expecting the behaviour to be consistent.
Fixes #3002 by providing an optional parameter to the
.instrument()method to allow for optionally using span links, e.g.Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
use_links=Falseand alsouse_links=Trueand observed the expected behaviour: when the flag isFalse(default) all task executions of a fan-out job are child spans of the code that enqueued it and whenTruethey appeared as linked spans.Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.