From eba00a9c3670f2833bba8a2ca0a9cf4e4acdb461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a=20=28Swast=29?= Date: Thu, 14 Aug 2025 13:36:26 -0500 Subject: [PATCH 1/3] docs: add a TROUBLESHOOTING.md file with tips for logging --- TROUBLESHOOTING.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 TROUBLESHOOTING.md diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md new file mode 100644 index 000000000..0e193e509 --- /dev/null +++ b/TROUBLESHOOTING.md @@ -0,0 +1,34 @@ +# Troubleshooting steps + +## Enable logging of BQ Storage Read API session creation + +It can be helpful to get the BQ Storage Read API session to allow the BigQuery +backend team to debug cases of API instability. The logs that share the session +creation are in a module-specific logger. To enable the logs, refer to the +following code sample:kj + +```python +import logging +import google.cloud.bigquery + +# Configure the basic logging to show DEBUG level messages +log_formatter = logging.Formatter( + '%(asctime)s - %(levelname)s - %(message)s' +) +handler = logging.StreamHandler() +handler.setFormatter(log_formatter) +default_logger = logging.getLogger() +default_logger.setLevel(logging.DEBUG) +default_logger.addHandler(handler) +to_dataframe_logger = logging.getLogger("google.cloud.bigquery._pandas_helpers") +to_dataframe_logger.setLevel(logging.DEBUG) +to_dataframe_logger.addHandler(handler) + +# Example code that touches +bqclient = google.cloud.bigquery.Client() +results = bqclient.query_and_wait("SELECT * FROM `bigquery-public-data.usa_names.usa_1910_2013`") +print(results.to_dataframe().head()) +``` + +In particular, watch for the text "with BQ Storage API session" in the logs +to get the streaming API session ID to share with your support person. From 5c8c85ccfd286fc991bee57468fe7bb6f4eddb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a=20=28Swast=29?= Date: Thu, 14 Aug 2025 13:36:59 -0500 Subject: [PATCH 2/3] typo --- TROUBLESHOOTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md index 0e193e509..49bb4cb30 100644 --- a/TROUBLESHOOTING.md +++ b/TROUBLESHOOTING.md @@ -5,7 +5,7 @@ It can be helpful to get the BQ Storage Read API session to allow the BigQuery backend team to debug cases of API instability. The logs that share the session creation are in a module-specific logger. To enable the logs, refer to the -following code sample:kj +following code sample: ```python import logging From b056ffff0a9497e1b2bee36dfc2f71487e4bcc5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a=20=28Swast=29?= Date: Thu, 14 Aug 2025 13:37:34 -0500 Subject: [PATCH 3/3] finish my sentence --- TROUBLESHOOTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md index 49bb4cb30..7da12c440 100644 --- a/TROUBLESHOOTING.md +++ b/TROUBLESHOOTING.md @@ -24,7 +24,7 @@ to_dataframe_logger = logging.getLogger("google.cloud.bigquery._pandas_helpers") to_dataframe_logger.setLevel(logging.DEBUG) to_dataframe_logger.addHandler(handler) -# Example code that touches +# Example code that touches the BQ Storage Read API. bqclient = google.cloud.bigquery.Client() results = bqclient.query_and_wait("SELECT * FROM `bigquery-public-data.usa_names.usa_1910_2013`") print(results.to_dataframe().head())