prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Log more extra data for Celery
  The old integration in celery used to log arguments to the task and more. Add that to our celery integration
  
  </issue>
  <code>
  [start of sentry_sdk/integrations/celery.py]
  1 from __future__ import absolute_import
  2 
  3 import sys
  4 
  5 from celery.signals import task_failure, task_prerun, task_postrun
  6 from celery.exceptions import SoftTimeLimitExceeded
  7 
  8 from sentry_sdk.hub import Hub
  9 from sentry_sdk.utils import capture_internal_exceptions, event_from_exception
  10 from sentry_sdk.integrations import Integration
  11 from sentry_sdk.integrations.logging import ignore_logger
  12 
  13 
  14 class CeleryIntegration(Integration):
  15     identifier = "celery"
  16 
  17     @staticmethod
  18     def setup_once():
  19         task_prerun.connect(_handle_task_prerun, weak=False)
  20         task_postrun.connect(_handle_task_postrun, weak=False)
  21         task_failure.connect(_process_failure_signal, weak=False)
  22 
  23         # This logger logs every status of every task that ran on the worker.
  24         # Meaning that every task's breadcrumbs are full of stuff like "Task
  25         # <foo> raised unexpected <bar>".
  26         ignore_logger("celery.worker.job")
  27 
  28 
  29 def _process_failure_signal(sender, task_id, einfo, **kw):
  30     # einfo from celery is not reliable
  31     exc_info = sys.exc_info()
  32 
  33     hub = Hub.current
  34     integration = hub.get_integration(CeleryIntegration)
  35     if integration is None:
  36         return
  37 
  38     if hasattr(sender, "throws") and isinstance(einfo.exception, sender.throws):
  39         return
  40 
  41     if isinstance(einfo.exception, SoftTimeLimitExceeded):
  42         # TODO: Move this into event processor
  43         with hub.push_scope() as scope:
  44             scope.fingerprint = [
  45                 "celery",
  46                 "SoftTimeLimitExceeded",
  47                 getattr(sender, "name", sender),
  48             ]
  49             _capture_event(hub, exc_info)
  50     else:
  51         _capture_event(hub, exc_info)
  52 
  53 
  54 def _handle_task_prerun(sender, task, **kw):
  55     hub = Hub.current
  56     if hub.get_integration(CeleryIntegration) is not None:
  57         scope = hub.push_scope().__enter__()
  58         with capture_internal_exceptions():
  59             scope.transaction = task.name
  60 
  61 
  62 def _handle_task_postrun(sender, task_id, task, **kw):
  63     hub = Hub.current
  64     if hub.get_integration(CeleryIntegration) is not None:
  65         hub.pop_scope_unsafe()
  66 
  67 
  68 def _capture_event(hub, exc_info):
  69     event, hint = event_from_exception(
  70         exc_info,
  71         client_options=hub.client.options,
  72         mechanism={"type": "celery", "handled": False},
  73     )
  74     hub.capture_event(event, hint=hint)
  75
  [end of sentry_sdk/integrations/celery.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/sentry_sdk/integrations/celery.py b/sentry_sdk/integrations/celery.py
  --- a/sentry_sdk/integrations/celery.py
  +++ b/sentry_sdk/integrations/celery.py
  @@ -35,28 +35,48 @@
       if integration is None:
           return
   
  -    if hasattr(sender, "throws") and isinstance(einfo.exception, sender.throws):
  -        return
  -
  -    if isinstance(einfo.exception, SoftTimeLimitExceeded):
  -        # TODO: Move this into event processor
  -        with hub.push_scope() as scope:
  -            scope.fingerprint = [
  -                "celery",
  -                "SoftTimeLimitExceeded",
  -                getattr(sender, "name", sender),
  -            ]
  -            _capture_event(hub, exc_info)
  -    else:
  -        _capture_event(hub, exc_info)
  +    _capture_event(hub, exc_info)
   
   
  -def _handle_task_prerun(sender, task, **kw):
  +def _handle_task_prerun(sender, task, args, kwargs, **_):
       hub = Hub.current
       if hub.get_integration(CeleryIntegration) is not None:
           scope = hub.push_scope().__enter__()
  +        scope.add_event_processor(_make_event_processor(args, kwargs, task))
  +
  +
  +def _make_event_processor(args, kwargs, task):
  +    def event_processor(event, hint):
  +        with capture_internal_exceptions():
  +            if "transaction" not in event:
  +                event["transaction"] = task.name
  +
           with capture_internal_exceptions():
  -            scope.transaction = task.name
  +            extra = event.setdefault("extra", {})
  +            extra["celery-job"] = {
  +                "task_name": task.name,
  +                "args": args,
  +                "kwargs": kwargs,
  +            }
  +
  +        if "exc_info" in hint:
  +            with capture_internal_exceptions():
  +                if issubclass(hint["exc_info"][0], SoftTimeLimitExceeded):
  +                    event["fingerprint"] = [
  +                        "celery",
  +                        "SoftTimeLimitExceeded",
  +                        getattr(task, "name", task),
  +                    ]
  +
  +            with capture_internal_exceptions():
  +                if hasattr(task, "throws") and isinstance(
  +                    hint["exc_info"][1], task.throws
  +                ):
  +                    return None
  +
  +        return event
  +
  +    return event_processor
   
   
   def _handle_task_postrun(sender, task_id, task, **kw):
  
verification_info: {"golden_diff": "diff --git a/sentry_sdk/integrations/celery.py b/sentry_sdk/integrations/celery.py\n--- a/sentry_sdk/integrations/celery.py\n+++ b/sentry_sdk/integrations/celery.py\n@@ -35,28 +35,48 @@\n     if integration is None:\n         return\n \n-    if hasattr(sender, \"throws\") and isinstance(einfo.exception, sender.throws):\n-        return\n-\n-    if isinstance(einfo.exception, SoftTimeLimitExceeded):\n-        # TODO: Move this into event processor\n-        with hub.push_scope() as scope:\n-            scope.fingerprint = [\n-                \"celery\",\n-                \"SoftTimeLimitExceeded\",\n-                getattr(sender, \"name\", sender),\n-            ]\n-            _capture_event(hub, exc_info)\n-    else:\n-        _capture_event(hub, exc_info)\n+    _capture_event(hub, exc_info)\n \n \n-def _handle_task_prerun(sender, task, **kw):\n+def _handle_task_prerun(sender, task, args, kwargs, **_):\n     hub = Hub.current\n     if hub.get_integration(CeleryIntegration) is not None:\n         scope = hub.push_scope().__enter__()\n+        scope.add_event_processor(_make_event_processor(args, kwargs, task))\n+\n+\n+def _make_event_processor(args, kwargs, task):\n+    def event_processor(event, hint):\n+        with capture_internal_exceptions():\n+            if \"transaction\" not in event:\n+                event[\"transaction\"] = task.name\n+\n         with capture_internal_exceptions():\n-            scope.transaction = task.name\n+            extra = event.setdefault(\"extra\", {})\n+            extra[\"celery-job\"] = {\n+                \"task_name\": task.name,\n+                \"args\": args,\n+                \"kwargs\": kwargs,\n+            }\n+\n+        if \"exc_info\" in hint:\n+            with capture_internal_exceptions():\n+                if issubclass(hint[\"exc_info\"][0], SoftTimeLimitExceeded):\n+                    event[\"fingerprint\"] = [\n+                        \"celery\",\n+                        \"SoftTimeLimitExceeded\",\n+                        getattr(task, \"name\", task),\n+                    ]\n+\n+            with capture_internal_exceptions():\n+                if hasattr(task, \"throws\") and isinstance(\n+                    hint[\"exc_info\"][1], task.throws\n+                ):\n+                    return None\n+\n+        return event\n+\n+    return event_processor\n \n \n def _handle_task_postrun(sender, task_id, task, **kw):\n", "issue": "Log more extra data for Celery\nThe old integration in celery used to log arguments to the task and more. Add that to our celery integration\n", "before_files": [{"content": "from __future__ import absolute_import\n\nimport sys\n\nfrom celery.signals import task_failure, task_prerun, task_postrun\nfrom celery.exceptions import SoftTimeLimitExceeded\n\nfrom sentry_sdk.hub import Hub\nfrom sentry_sdk.utils import capture_internal_exceptions, event_from_exception\nfrom sentry_sdk.integrations import Integration\nfrom sentry_sdk.integrations.logging import ignore_logger\n\n\nclass CeleryIntegration(Integration):\n    identifier = \"celery\"\n\n    @staticmethod\n    def setup_once():\n        task_prerun.connect(_handle_task_prerun, weak=False)\n        task_postrun.connect(_handle_task_postrun, weak=False)\n        task_failure.connect(_process_failure_signal, weak=False)\n\n        # This logger logs every status of every task that ran on the worker.\n        # Meaning that every task's breadcrumbs are full of stuff like \"Task\n        # <foo> raised unexpected <bar>\".\n        ignore_logger(\"celery.worker.job\")\n\n\ndef _process_failure_signal(sender, task_id, einfo, **kw):\n    # einfo from celery is not reliable\n    exc_info = sys.exc_info()\n\n    hub = Hub.current\n    integration = hub.get_integration(CeleryIntegration)\n    if integration is None:\n        return\n\n    if hasattr(sender, \"throws\") and isinstance(einfo.exception, sender.throws):\n        return\n\n    if isinstance(einfo.exception, SoftTimeLimitExceeded):\n        # TODO: Move this into event processor\n        with hub.push_scope() as scope:\n            scope.fingerprint = [\n                \"celery\",\n                \"SoftTimeLimitExceeded\",\n                getattr(sender, \"name\", sender),\n            ]\n            _capture_event(hub, exc_info)\n    else:\n        _capture_event(hub, exc_info)\n\n\ndef _handle_task_prerun(sender, task, **kw):\n    hub = Hub.current\n    if hub.get_integration(CeleryIntegration) is not None:\n        scope = hub.push_scope().__enter__()\n        with capture_internal_exceptions():\n            scope.transaction = task.name\n\n\ndef _handle_task_postrun(sender, task_id, task, **kw):\n    hub = Hub.current\n    if hub.get_integration(CeleryIntegration) is not None:\n        hub.pop_scope_unsafe()\n\n\ndef _capture_event(hub, exc_info):\n    event, hint = event_from_exception(\n        exc_info,\n        client_options=hub.client.options,\n        mechanism={\"type\": \"celery\", \"handled\": False},\n    )\n    hub.capture_event(event, hint=hint)\n", "path": "sentry_sdk/integrations/celery.py"}]}