Skip to content

Commit b684832

Browse files
tswastLinchin
andauthored
docs: add a TROUBLESHOOTING.md file with tips for logging (#2262)
* docs: add a TROUBLESHOOTING.md file with tips for logging * typo * finish my sentence --------- Co-authored-by: Lingqing Gan <[email protected]>
1 parent 6659355 commit b684832

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

TROUBLESHOOTING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Troubleshooting steps
2+
3+
## Enable logging of BQ Storage Read API session creation
4+
5+
It can be helpful to get the BQ Storage Read API session to allow the BigQuery
6+
backend team to debug cases of API instability. The logs that share the session
7+
creation are in a module-specific logger. To enable the logs, refer to the
8+
following code sample:
9+
10+
```python
11+
import logging
12+
import google.cloud.bigquery
13+
14+
# Configure the basic logging to show DEBUG level messages
15+
log_formatter = logging.Formatter(
16+
'%(asctime)s - %(levelname)s - %(message)s'
17+
)
18+
handler = logging.StreamHandler()
19+
handler.setFormatter(log_formatter)
20+
default_logger = logging.getLogger()
21+
default_logger.setLevel(logging.DEBUG)
22+
default_logger.addHandler(handler)
23+
to_dataframe_logger = logging.getLogger("google.cloud.bigquery._pandas_helpers")
24+
to_dataframe_logger.setLevel(logging.DEBUG)
25+
to_dataframe_logger.addHandler(handler)
26+
27+
# Example code that touches the BQ Storage Read API.
28+
bqclient = google.cloud.bigquery.Client()
29+
results = bqclient.query_and_wait("SELECT * FROM `bigquery-public-data.usa_names.usa_1910_2013`")
30+
print(results.to_dataframe().head())
31+
```
32+
33+
In particular, watch for the text "with BQ Storage API session" in the logs
34+
to get the streaming API session ID to share with your support person.

0 commit comments

Comments
 (0)