From db3c3639a334d8275fd1b84e8936096f48356eae Mon Sep 17 00:00:00 2001 From: Mattie Fu Date: Mon, 17 Aug 2026 16:32:33 +0000 Subject: [PATCH] Set Apache Beam user agent for Python BigtableIO write client Configure the native Python Bigtable write client with a Beam user agent (apache-beam/ (GPN:Beam)), matching the Java BigtableIO behavior and the convention used by gcsio.py and the Datastore connector. --- sdks/python/apache_beam/io/gcp/bigtableio.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdks/python/apache_beam/io/gcp/bigtableio.py b/sdks/python/apache_beam/io/gcp/bigtableio.py index f10039e564d1..7d25a0082a79 100644 --- a/sdks/python/apache_beam/io/gcp/bigtableio.py +++ b/sdks/python/apache_beam/io/gcp/bigtableio.py @@ -43,6 +43,7 @@ from typing import List import apache_beam as beam +from apache_beam import version as beam_version from apache_beam.internal.metrics.metric import ServiceCallMetric from apache_beam.io.gcp import resource_identifiers from apache_beam.metrics import Metrics @@ -59,6 +60,7 @@ MAX_ROW_BYTES = 5242880 # 5MB try: + from google.api_core.gapic_v1 import client_info as client_info_lib from google.cloud.bigtable import Client from google.cloud.bigtable.batcher import MutationsBatcher from google.cloud.bigtable.row import Cell @@ -141,7 +143,11 @@ def start_service_call_metrics(self, project_id, instance_id, table_id): def start_bundle(self): if self.table is None: - client = Client(project=self.beam_options['project_id']) + client = Client( + project=self.beam_options['project_id'], + client_info=client_info_lib.ClientInfo( + user_agent="apache-beam/%s (GPN:Beam)" % + beam_version.__version__)) instance = client.instance(self.beam_options['instance_id']) self.table = instance.table(self.beam_options['table_id']) self.service_call_metric = self.start_service_call_metrics(