Skip to content

Update Celery tests #4211

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

Merged
merged 5 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/populate_tox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"package": "celery",
"deps": {
"*": ["newrelic", "redis"],
"py3.7": ["importlib-metadata<5.0"],
},
"python": ">=3.8",
},
"clickhouse_driver": {
"package": "clickhouse-driver",
Expand Down
12 changes: 8 additions & 4 deletions tests/integrations/celery/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,14 @@ def dummy_task(x, y):
)
assert submission_event["spans"] == [
{
"data": ApproxDict(),
"data": {
"sentry.name": "dummy_task",
"sentry.op": "queue.submit.celery",
"sentry.origin": "auto.queue.celery",
"sentry.source": "custom",
"thread.id": mock.ANY,
"thread.name": mock.ANY,
},
"description": "dummy_task",
"op": "queue.submit.celery",
"origin": "auto.queue.celery",
Expand All @@ -238,9 +245,6 @@ def dummy_task(x, y):
"timestamp": submission_event["spans"][0]["timestamp"],
"trace_id": str(root_span.trace_id),
"status": "ok",
"tags": {
"status": "ok",
},
}
]

Expand Down
18 changes: 10 additions & 8 deletions tests/integrations/celery/test_update_celery_task_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from sentry_sdk.integrations.celery import _update_celery_task_headers
import sentry_sdk
from sentry_sdk.tracing_utils import Baggage
from tests.conftest import SortedBaggage


BAGGAGE_VALUE = (
Expand Down Expand Up @@ -83,10 +84,11 @@ def test_span_with_transaction(sentry_init):

assert outgoing_headers["sentry-trace"] == span.to_traceparent()
assert outgoing_headers["headers"]["sentry-trace"] == span.to_traceparent()
assert outgoing_headers["baggage"] == transaction.get_baggage().serialize()
assert (
outgoing_headers["headers"]["baggage"]
== transaction.get_baggage().serialize()
assert outgoing_headers["baggage"] == SortedBaggage(
transaction.get_baggage().serialize()
)
assert outgoing_headers["headers"]["baggage"] == SortedBaggage(
transaction.get_baggage().serialize()
)


Expand Down Expand Up @@ -117,11 +119,11 @@ def test_span_with_transaction_custom_headers(sentry_init):
if x is not None and x != ""
]
)
assert outgoing_headers["baggage"] == combined_baggage.serialize(
include_third_party=True
assert outgoing_headers["baggage"] == SortedBaggage(
combined_baggage.serialize(include_third_party=True)
)
assert outgoing_headers["headers"]["baggage"] == combined_baggage.serialize(
include_third_party=True
assert outgoing_headers["headers"]["baggage"] == SortedBaggage(
combined_baggage.serialize(include_third_party=True)
)


Expand Down
7 changes: 3 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# The file (and all resulting CI YAMLs) then need to be regenerated via
# "scripts/generate-test-files.sh".
#
# Last generated: 2025-03-27T10:11:24.425788+00:00
# Last generated: 2025-03-28T12:52:29.636426+00:00

[tox]
requires =
Expand Down Expand Up @@ -226,8 +226,8 @@ envlist =


# ~~~ Tasks ~~~
{py3.7,py3.8}-celery-v4.4.7
{py3.7,py3.8}-celery-v5.0.5
{py3.8}-celery-v4.4.7
{py3.8}-celery-v5.0.5
{py3.8,py3.11,py3.12}-celery-v5.4.0
{py3.8,py3.12,py3.13}-celery-v5.5.0rc5

Expand Down Expand Up @@ -628,7 +628,6 @@ deps =
celery-v5.5.0rc5: celery==5.5.0rc5
celery: newrelic
celery: redis
py3.7-celery: importlib-metadata<5.0

dramatiq-v1.9.0: dramatiq==1.9.0
dramatiq-v1.12.3: dramatiq==1.12.3
Expand Down
Loading