Skip to content

Commit ba7db76

Browse files
committed
mypy
1 parent 26a1fe4 commit ba7db76

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

sentry_sdk/client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -865,12 +865,12 @@ def capture_log(self, scope, severity_text, severity_number, template, **kwargs)
865865
attrs = {
866866
"sentry.message.template": template,
867867
}
868-
if (extra_attrs := kwargs.get("attributes")) is not None:
869-
attrs.update(extra_attrs)
870-
if (env := self.options.get("environment")) is not None:
871-
attrs["sentry.environment"] = env
872-
if (release := self.options.get("release")) is not None:
873-
attrs["sentry.release"] = release
868+
if kwargs.get("attributes") is not None:
869+
attrs.update(kwargs.get("attributes"))
870+
if self.options.get("environment") is not None:
871+
attrs["sentry.environment"] = self.options.get("environment")
872+
if self.options.get("release") is not None:
873+
attrs["sentry.release"] = self.options.get("release")
874874
for k, v in kwargs.items():
875875
attrs[f"sentry.message.parameters.{k}"] = v
876876

@@ -882,9 +882,10 @@ def capture_log(self, scope, severity_text, severity_number, template, **kwargs)
882882
"time_unix_nano": time.time_ns(),
883883
}
884884

885-
if (ctx := scope.get_active_propagation_context()) is not None:
886-
headers["trace_id"] = ctx.trace_id
887-
log["trace_id"] = ctx.trace_id
885+
propagation_context = scope.get_active_propagation_context()
886+
if propagation_context is not None:
887+
headers["trace_id"] = propagation_context.trace_id
888+
log["trace_id"] = propagation_context.trace_id
888889
envelope = Envelope(headers=headers)
889890

890891
before_send_log = self.options.get("before_send_log")
@@ -911,11 +912,10 @@ def format_attribute(key, val):
911912
"severityNumber": log["severity_number"],
912913
"body": {"stringValue": log["body"]},
913914
"timeUnixNano": str(log["time_unix_nano"]),
915+
"attributes": [
916+
format_attribute(k, v) for (k, v) in log["attributes"].items()
917+
],
914918
}
915-
if isinstance((attrs := log["attributes"]), dict):
916-
otel_log["attributes"] = [
917-
format_attribute(k, v) for (k, v) in attrs.items()
918-
]
919919
if "trace_id" in log:
920920
otel_log["traceId"] = log["trace_id"]
921921

0 commit comments

Comments
 (0)