appsignal/appsignal-python

Errors from Celery tasks are all reported as ExceptionInfo making grouping bad

tombruijn opened this issue · 2 comments

All Celery errors, even custom errors, seem to be reported as "ExceptionInfo" by OpenTelemetry:
Not a blocker for me right now, but something to be aware off and most certainly will have someone pop up in support about. This is something I think should be fixed in the Celery instrumentation, as that's what's reporting it with this wrapper error.

2023-06-15 09-26-24 Errors - pythondjango4-celery - AppSignal

OpenTelemetry payload

{
events: {
  time_unix_nano: 1686813462797997050,
  name: "exception",
  attributes: {
    key: "exception.type",
    value: {
      string_value: "ExceptionInfo",
    },
  },
  attributes: {
    key: "exception.message",
    value: {
      string_value: "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.11/site-packages/celery/app/trace.py\", line 477, in trace_task\n    R = retval = fun(*args, **kwargs)\n                 ^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/site-packages/celery/app/trace.py\", line 760, in __protected_call__\n    return self.run(*args, **kwargs)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/tasks.py\", line 43, in custom_error_task\n    raise MyCeleryException(\"Custom Celery error\")\ntasks.MyCeleryException: Custom Celery error\n",
    },
  },
  attributes: {
    key: "exception.stacktrace",
    value: {
      string_value: "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.11/site-packages/celery/app/trace.py\", line 477, in trace_task\n    R = retval = fun(*args, **kwargs)\n                 ^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/site-packages/celery/app/trace.py\", line 760, in __protected_call__\n    return self.run(*args, **kwargs)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/tasks.py\", line 43, in custom_error_task\n    raise MyCeleryException(\"Custom Celery error\")\ntasks.MyCeleryException: Custom Celery error\n",
    },
  },
  attributes: {
    key: "exception.escaped",
    value: {
      string_value: "False",
    },
  },
},
status: {
  message: "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.11/site-packages/celery/app/trace.py\", line 477, in trace_task\n    R = retval = fun(*args, **kwargs)\n                 ^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/site-packages/celery/app/trace.py\", line 760, in __protected_call__\n    return self.run(*args, **kwargs)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/tasks.py\", line 43, in custom_error_task\n    raise MyCeleryException(\"Custom Celery error\")\ntasks.MyCeleryException: Custom Celery error\n",
  code: STATUS_CODE_ERROR
},
}

This issue was fixed by the upstream PR open-telemetry/opentelemetry-python-contrib#1863. It's not been released yet, but once it is, it should be a matter of upgrading the opentelemetry-instrumentation-celery package. Closing this issue as it's fixed (but not yet released).

We'll have a look at if we can require a certain version of dependencies in #126.