Skip to content

Commit

Permalink
fix(grpc): Transform metadata into Metadata object in case it's a tuple
Browse files Browse the repository at this point in the history
Up until version 1.65.0 of grpcio, the metadata was not guaranteed to
arrive as the type specified in annotations but could be a tuple.
To support versions before that we check and transform it here.
  • Loading branch information
fdellekart committed Jul 3, 2024
1 parent 6b17d04 commit fba9d83
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sentry_sdk/integrations/grpc/aio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def _update_client_call_details_metadata_from_scope(
) -> ClientCallDetails:
if client_call_details.metadata is None:
client_call_details = client_call_details._replace(metadata=Metadata())
elif not isinstance(client_call_details.metadata, Metadata):
client_call_details = client_call_details._replace(
metadata=Metadata.from_tuple(client_call_details.metadata)
)
for key, value in Scope.get_current_scope().iter_trace_propagation_headers():
client_call_details.metadata.add(key, value)
return client_call_details
Expand Down

0 comments on commit fba9d83

Please sign in to comment.