Skip to content

Commit 4caff59

Browse files
yirutangparthea
authored andcommitted
feat: add client side lib id with lib version (#760)
* . * . * . * . * . * .
1 parent 03f9fbe commit 4caff59

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/google-cloud-bigquery-storage/google/cloud/bigquery_storage_v1/writer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import grpc
2929

3030
from google.cloud.bigquery_storage_v1 import exceptions as bqstorage_exceptions
31+
from google.cloud.bigquery_storage_v1 import gapic_version as package_version
3132
from google.cloud.bigquery_storage_v1 import types as gapic_types
3233
from google.cloud.bigquery_storage_v1.services import big_query_write
3334

@@ -163,6 +164,10 @@ def _open(
163164
gapic_types.AppendRowsRequest.copy_from(request, self._inital_request_template)
164165
request._pb.MergeFrom(initial_request._pb)
165166
self._stream_name = request.write_stream
167+
if initial_request.trace_id:
168+
request.trace_id = f"python-writer:{package_version.__version__} {initial_request.trace_id}"
169+
else:
170+
request.trace_id = f"python-writer:{package_version.__version__}"
166171

167172
inital_response_future = AppendRowsFuture(self)
168173
self._futures_queue.put(inital_response_future)

packages/google-cloud-bigquery-storage/tests/unit/test_writer_v1.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717

1818
from google.api_core import exceptions
1919
from google.protobuf import descriptor_pb2
20+
2021
import pytest
2122

2223
from google.cloud.bigquery_storage_v1 import exceptions as bqstorage_exceptions
24+
from google.cloud.bigquery_storage_v1 import gapic_version as package_version
2325
from google.cloud.bigquery_storage_v1 import types as gapic_types
2426
from google.cloud.bigquery_storage_v1.services import big_query_write
2527

@@ -96,6 +98,7 @@ def test_initial_send(background_consumer, bidi_rpc, module_under_test):
9698
),
9799
rows=proto_rows,
98100
),
101+
trace_id=f"python-writer:{package_version.__version__}",
99102
)
100103
bidi_rpc.assert_called_once_with(
101104
start_rpc=mock_client.append_rows,

0 commit comments

Comments
 (0)