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

fix(celery): ensure error.message tag does not include stacktrace #9585

Merged
merged 5 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 6 additions & 1 deletion ddtrace/contrib/celery/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,12 @@ def trace_failure(*args, **kwargs):
if isinstance(original_exception, task.throws):
return

span.set_exc_info(ex.type, ex.exception, ex.tb)
# ensure we are getting the actual exception class which stores the exception message
exc = ex.exception
if hasattr(exc, "exc"):
exc = exc.exc

span.set_exc_info(ex.type, exc, ex.tb)


def trace_retry(*args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion tests/contrib/celery/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def fn_exception():
assert span.error == 1
assert span.get_tag("component") == "celery"
assert span.get_tag("span.kind") == "consumer"
assert "Task class is failing" in span.get_tag(ERROR_MSG)
assert span.get_tag(ERROR_MSG) == "Task class is failing"
assert "Traceback (most recent call last)" in span.get_tag("error.stack")
assert "Task class is failing" in span.get_tag("error.stack")

Expand Down
Loading