Skip to content

Commit 3fffa7f

Browse files
committed
simplify dispatcher
1 parent 649c3ad commit 3fffa7f

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

sentry_sdk/client.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -907,26 +907,26 @@ def _capture_telemetry(
907907

908908
scope.apply_to_telemetry(telemetry)
909909

910-
before_send_getter = {
911-
"log": lambda: get_before_send_log(self.options),
912-
"metric": lambda: get_before_send_metric(self.options),
913-
}.get(ty)
910+
before_send = None
911+
if ty == "log":
912+
before_send = get_before_send_log(self.options)
913+
elif ty == "metric":
914+
before_send = get_before_send_metric(self.options) # type: ignore
914915

915-
if before_send_getter is not None:
916-
before_send = before_send_getter()
917-
if before_send is not None:
918-
telemetry = before_send(telemetry, {}) # type: ignore[arg-type]
916+
if before_send is not None:
917+
telemetry = before_send(telemetry, {}) # type: ignore
919918

920919
if telemetry is None:
921920
return
922921

923-
batcher: "Optional[Union[LogBatcher, MetricsBatcher]]" = {
924-
"log": self.log_batcher,
925-
"metric": self.metrics_batcher,
926-
}.get(ty)
922+
batcher = None
923+
if ty == "log":
924+
batcher = self.log_batcher
925+
elif ty == "metric":
926+
batcher = self.metrics_batcher # type: ignore
927927

928-
if batcher:
929-
batcher.add(telemetry) # type: ignore[arg-type]
928+
if batcher is not None:
929+
batcher.add(telemetry) # type: ignore
930930

931931
def _capture_log(self, log: "Optional[Log]", scope: "Scope") -> None:
932932
self._capture_telemetry(log, "log", scope)

0 commit comments

Comments
 (0)