Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBAPI does not add tracing spans to additional page fetches #1791

Open
nickmarx12345678 opened this issue Jan 19, 2024 · 2 comments
Open

DBAPI does not add tracing spans to additional page fetches #1791

nickmarx12345678 opened this issue Jan 19, 2024 · 2 comments
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@nickmarx12345678
Copy link
Contributor

nickmarx12345678 commented Jan 19, 2024

Environment details

  • OS type and version: Darwin M-C02D404FMD6T 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:54:10 PST 2023; root:xnu-10002.61.3~2/RELEASE_X86_64 x86_64
  • Python version: Python 3.11.3
  • pip version: `pip 22.3.1
  • google-cloud-bigquery version: Version: 3.15.0

Steps to reproduce

I will try to add a self contained repro, but I'm newer to this library/python, so I will summarize in the meantime.

We have been using the opentelemetry integration along with GCP Cloud Trace to reduce latency of an application using python-bigquery and have noticed when there is more than one page worth of results in a DB-API cursor, we will only see trace spans for the initial bq.query and job.reload calls, but not for the fetching of the additional pages, which leaves an unexplained gap in the trace timeline (see pic)

image

To reproduce, run a DB-API query with array_size

set to less than the output number of rows of the query, and opentelemetry tracing installed, and observe .

Code example

cursor = execute(sql)
results = cursor.all()

subset of flame graph from my debugging. this segment of calls appears not to generate any tracing spans (despite using bigquery_storage_client)
image

Thanks!

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Jan 19, 2024
@tswast tswast added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Jan 19, 2024
@tswast
Copy link
Contributor

tswast commented Jan 19, 2024

There are two methods in which we download results: REST API (this client library) and BQ Storage Read API.

For REST API, it appears we need to add the span attributes in the following location:

api_request=functools.partial(self._call_api, retry, timeout=timeout),

For the BQ Storage API, please file a feature request for opentelemetry support in our gRPC clients here: https://github.com/googleapis/gapic-generator-python/issues?q=is%3Aissue+is%3Aopen+

@nickmarx12345678
Copy link
Contributor Author

Done! googleapis/gapic-generator-python#1910

Thanks @tswast

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants