Repository: getsentry/sentry-python

Issue:
protect against bad serialization in logger statements
### How do you use Sentry?

Sentry Saas (sentry.io)

### Version

1.13.0

### Steps to Reproduce

use `debug=True`
have bytes in local variable
[event processor drop](https://github.com/getsentry/sentry-python/blob/0b2415e87bf2944cb98f14e0a1e85d2ac4462987/sentry_sdk/scope.py#L377) will get logged with massive bytes payload 



### Expected Result

don't serialize garbage in logger statements

### Actual Result

![image](https://user-images.githubusercontent.com/6536764/213532655-a1918ebd-7cda-4d5a-95f1-7488022897a0.png)



Discussion:

Resolving patch:
diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py
--- a/sentry_sdk/client.py
+++ b/sentry_sdk/client.py
@@ -241,7 +241,7 @@ def _prepare_event(
             with capture_internal_exceptions():
                 new_event = before_send(event, hint or {})
             if new_event is None:
-                logger.info("before send dropped event (%s)", event)
+                logger.info("before send dropped event")
                 if self.transport:
                     self.transport.record_lost_event(
                         "before_send", data_category="error"
@@ -254,7 +254,7 @@ def _prepare_event(
             with capture_internal_exceptions():
                 new_event = before_send_transaction(event, hint or {})
             if new_event is None:
-                logger.info("before send transaction dropped event (%s)", event)
+                logger.info("before send transaction dropped event")
                 if self.transport:
                     self.transport.record_lost_event(
                         "before_send", data_category="transaction"
diff --git a/sentry_sdk/scope.py b/sentry_sdk/scope.py
--- a/sentry_sdk/scope.py
+++ b/sentry_sdk/scope.py
@@ -370,9 +370,9 @@ def apply_to_event(
         # type: (...) -> Optional[Event]
         """Applies the information contained on the scope to the given event."""
 
-        def _drop(event, cause, ty):
-            # type: (Dict[str, Any], Any, str) -> Optional[Any]
-            logger.info("%s (%s) dropped event (%s)", ty, cause, event)
+        def _drop(cause, ty):
+            # type: (Any, str) -> Optional[Any]
+            logger.info("%s (%s) dropped event", ty, cause)
             return None
 
         is_transaction = event.get("type") == "transaction"
@@ -425,7 +425,7 @@ def _drop(event, cause, ty):
             for error_processor in self._error_processors:
                 new_event = error_processor(event, exc_info)
                 if new_event is None:
-                    return _drop(event, error_processor, "error processor")
+                    return _drop(error_processor, "error processor")
                 event = new_event
 
         for event_processor in chain(global_event_processors, self._event_processors):
@@ -433,7 +433,7 @@ def _drop(event, cause, ty):
             with capture_internal_exceptions():
                 new_event = event_processor(event, hint)
             if new_event is None:
-                return _drop(event, event_processor, "event processor")
+                return _drop(event_processor, "event processor")
             event = new_event
 
         return event


Test patch: