Skip to content

Commit 9b14623

Browse files
inline get_client()
1 parent a789a2e commit 9b14623

4 files changed

Lines changed: 10 additions & 14 deletions

File tree

sentry_sdk/integrations/grpc/aio/client.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ async def intercept_unary_unary(
5050
) -> "Union[UnaryUnaryCall, Message]":
5151
method = client_call_details.method
5252

53-
client = sentry_sdk.get_client()
54-
span_streaming = has_span_streaming_enabled(client.options)
55-
53+
span_streaming = has_span_streaming_enabled(sentry_sdk.get_client().options)
5654
if span_streaming:
5755
with sentry_sdk.traces.start_span(
5856
name="unary unary call to %s" % method.decode(),
@@ -107,9 +105,7 @@ async def intercept_unary_stream(
107105
) -> "Union[AsyncIterable[Any], UnaryStreamCall]":
108106
method = client_call_details.method
109107

110-
client = sentry_sdk.get_client()
111-
span_streaming = has_span_streaming_enabled(client.options)
112-
108+
span_streaming = has_span_streaming_enabled(sentry_sdk.get_client().options)
113109
if span_streaming:
114110
with sentry_sdk.traces.start_span(
115111
name="unary stream call to %s" % method.decode(),

sentry_sdk/integrations/grpc/aio/server.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ async def wrapped(request: "Any", context: "ServicerContext") -> "Any":
5353
if not name:
5454
return await handler(request, context)
5555

56-
client = sentry_sdk.get_client()
57-
span_streaming = has_span_streaming_enabled(client.options)
56+
span_streaming = has_span_streaming_enabled(
57+
sentry_sdk.get_client().options
58+
)
5859
if span_streaming:
5960
# What if the headers are empty?
6061
sentry_sdk.traces.continue_trace(

sentry_sdk/integrations/grpc/client.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ def intercept_unary_unary(
3131
) -> "_UnaryOutcome":
3232
method = client_call_details.method
3333

34-
client = sentry_sdk.get_client()
35-
span_streaming = has_span_streaming_enabled(client.options)
34+
span_streaming = has_span_streaming_enabled(sentry_sdk.get_client().options)
3635
if span_streaming:
3736
with sentry_sdk.traces.start_span(
3837
name="unary unary call to %s" % method,
@@ -82,8 +81,7 @@ def intercept_unary_stream(
8281
) -> "Union[Iterator[Message], Call]":
8382
method = client_call_details.method
8483

85-
client = sentry_sdk.get_client()
86-
span_streaming = has_span_streaming_enabled(client.options)
84+
span_streaming = has_span_streaming_enabled(sentry_sdk.get_client().options)
8785
response: "UnaryStreamCall"
8886
if span_streaming:
8987
with sentry_sdk.traces.start_span(

sentry_sdk/integrations/grpc/server.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ def behavior(request: "Message", context: "ServicerContext") -> "Message":
4646
if name:
4747
metadata = dict(context.invocation_metadata())
4848

49-
client = sentry_sdk.get_client()
50-
span_streaming = has_span_streaming_enabled(client.options)
49+
span_streaming = has_span_streaming_enabled(
50+
sentry_sdk.get_client().options
51+
)
5152
if span_streaming:
5253
sentry_sdk.traces.continue_trace(metadata)
5354

0 commit comments

Comments
 (0)