-
Notifications
You must be signed in to change notification settings - Fork 306
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
feat: add opentelemetry tracing #215
Changes from 19 commits
b13ad47
cacea7c
63e9581
719ed83
72f22b6
ff8171f
456b445
f4aba6d
e223657
78b8298
88b1a57
e0895c9
95a35ad
3bf4574
4dbb692
406f61a
c2b9add
d425909
64ec5fd
73230dc
ae04fc6
ac56488
d4de926
2d8aeb3
cd8e303
d8c601d
2bcd106
f1de589
72a77d1
0c7b354
51045f1
ec96f5c
35afadf
5a32ad4
1d7155c
54c133a
3aff14d
59477ff
0d15998
d997175
61b5b85
4d1dec1
7704975
839cd92
dd1e246
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,41 @@ Perform a query | |
|
||
for row in rows: | ||
print(row.name) | ||
|
||
Instrumenting With OpenTelemetry | ||
-------------------------------- | ||
|
||
This application uses `OpenTelemetry`_ to output tracing data from | ||
API calls to BigQuery. To enable OpenTelemetry tracing in | ||
the BigQuery client the following PyPI packages need to be installed: | ||
|
||
.. _OpenTelemetry: https://opentelemetry.io | ||
|
||
.. code-block:: console | ||
|
||
pip install opentelemetry-api opentelemetry-sdk opentelemetry-instrumentation opentelemetry-exporter-google-cloud | ||
|
||
After installation, OpenTelemetry can be used in the BigQuery | ||
client and in BigQuery jobs. First, however, an exporter must be | ||
specified for where the trace data will be outputted to. An example of this | ||
aravinsiva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
can be found here: | ||
|
||
.. code-block:: python | ||
|
||
from opentelemetry import trace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a runnable / tested code snippet somewhere this can be linked from? I'm worried that the code sample may get out-of-date / break. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently looking into it. |
||
from opentelemetry.sdk.trace import TracerProvider | ||
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor | ||
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter | ||
trace.set_tracer_provider(TracerProvider()) | ||
trace.get_tracer_provider().add_span_processor( | ||
BatchExportSpanProcessor(CloudTraceSpanExporter()) | ||
) | ||
|
||
In this example all tracing data will be published to the Google | ||
`Cloud Trace`_ console. For more information on OpenTelemetry, please consult the `OpenTelemetry documentation`_. | ||
|
||
.. _OpenTelemetry documentation: https://opentelemetry-python.readthedocs.io | ||
.. _Cloud Trace: https://cloud.google.com/trace | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still prefer if these dependencies were defined in
extras
. You can add a line to exclude fromall
since it's not supported on Python 2.7.