Incompatibility With Recent GCP SDK Versions
See original GitHub issueDescribe your environment.
The code is an asynchronous workload running in GKE.
Python 3.7.9
google-api-core==1.22.3 google-auth==1.22.0 google-cloud-bigquery==1.20.0 google-cloud-core==1.3.0 google-cloud-error-reporting==0.32.1 google-cloud-kms==2.2.0 opencensus-context==0.1.1 opencensus-ext-google-cloud-clientlibs==0.1.2 opencensus-ext-grpc==0.7.1
Steps to reproduce.
- Enable the
google_cloud_clientlibs
integration - Call the GCP KMS API using the Python SDK client.
What is the expected behavior?
The GRPC call to the KMS API is traced automatically.
What is the actual behavior?
The following (partially redacted) exception is raised because it seems that the opencensus.ext.grpc.utils. add_message_event
function assumes that all Message
objects will have ByteSize
method. Recently the official GCP SDK packages for Python have begun to use the proto plus package, and that version of the Message
object does not have the ByteSize
method.
Additional context.
Traceback (most recent call last):
File "/redacted.py", line 167, in redacted
public_key = client.get_public_key(request={"name": key_name})
File "/usr/local/lib/python3.7/site-packages/google/cloud/kms_v1/services/key_management_service/client.py", line 1026, in get_public_key
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
File "/usr/local/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py", line 145, in __call__
return wrapped_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/google/api_core/retry.py", line 286, in retry_wrapped_func
on_error=on_error,
File "/usr/local/lib/python3.7/site-packages/google/api_core/retry.py", line 184, in retry_target
return target()
File "/usr/local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
return callable_(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/grpc/_interceptor.py", line 221, in __call__
compression=compression)
File "/usr/local/lib/python3.7/site-packages/grpc/_interceptor.py", line 256, in _with_call
request)
File "/usr/local/lib/python3.7/site-packages/opencensus/ext/grpc/client_interceptor.py", line 166, in intercept_unary_unary
next(new_request))
File "/usr/local/lib/python3.7/site-packages/opencensus/ext/grpc/utils.py", line 33, in wrap_iter_with_message_events
message_id=message_id)
File "/usr/local/lib/python3.7/site-packages/opencensus/ext/grpc/utils.py", line 18, in add_message_event
uncompressed_size_bytes=proto_message.ByteSize()
File "/usr/local/lib/python3.7/site-packages/proto/message.py", line 525, in __getattr__
raise AttributeError(str(ex))
AttributeError: 'ByteSize'
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top GitHub Comments
proto-plus provides access to the underlying protobuf with the
pb()
classmethod.https://proto-plus-python.readthedocs.io/en/stable/reference/message.html#proto.message.Message.pb
No workaround, but the fix should be straightforward