ashb commented on code in PR #69504:
URL: https://github.com/apache/airflow/pull/69504#discussion_r3820697226


##########
task-sdk/src/airflow/sdk/execution_time/sentry/configured.py:
##########
@@ -80,24 +80,28 @@ def prepare_to_enrich_errors(self, executor_integration: 
str) -> None:
                 log.exception("Invalid executor Sentry integration", 
import_path=executor_integration)
 
         sentry_config_opts: dict[str, Any] = conf.getsection("sentry") or {}
-        if sentry_config_opts:
-            sentry_config_opts.pop("sentry_on")
-            old_way_dsn = sentry_config_opts.pop("sentry_dsn", None)
-            new_way_dsn = sentry_config_opts.pop("dsn", None)
-            # supported backward compatibility with old way dsn option
-            dsn = old_way_dsn or new_way_dsn
-
-            if unsupported_options := 
self.UNSUPPORTED_SENTRY_OPTIONS.intersection(sentry_config_opts):
-                log.warning(
-                    "There are unsupported options in [sentry] section",
-                    options=unsupported_options,
-                )
+        sentry_config_opts.pop("sentry_on", None)
+        old_way_dsn = sentry_config_opts.pop("sentry_dsn", None)
+        new_way_dsn = sentry_config_opts.pop("dsn", None)
+        # supported backward compatibility with old way dsn option
+        dsn = old_way_dsn or new_way_dsn
+
+        # Resolve before_send and transport to callables if configured
+        if before_send := conf.getimport("sentry", "before_send", 
fallback=None):
+            sentry_config_opts["before_send"] = before_send
         else:
-            dsn = None
-            if before_send := conf.getimport("sentry", "before_send", 
fallback=None):
-                sentry_config_opts["before_send"] = before_send
-            if transport := conf.getimport("sentry", "transport", 
fallback=None):
-                sentry_config_opts["transport"] = transport
+            sentry_config_opts.pop("before_send", None)
+
+        if transport := conf.getimport("sentry", "transport", fallback=None):
+            sentry_config_opts["transport"] = transport
+        else:
+            sentry_config_opts.pop("transport", None)

Review Comment:
   This can be simplified by using the `import_string` method
   
   `from airflow.sdk._shared.module_loading import import_string` and then:
   
   ```suggestion
           if before_send := sentry_config_opts.pop("before_send", None):
               sentry_config_opts["before_send"] = import_string(before_send)
           if transport := sentry_config_opts.pop("transport", None):
               sentry_config_opts["transport"] = import_string(transport)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to