We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sentry_sdk/integrations/celery.py`
Content:
```
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 FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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):

{"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"}], "after_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    _capture_event(hub, exc_info)\n\n\ndef _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\ndef _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            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\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"}]}