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

feat: add opentelemetry tracing #215

Merged
merged 45 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b13ad47
testing first trace export
aravinsiva Aug 1, 2020
cacea7c
instrumention client.py
aravinsiva Aug 3, 2020
63e9581
instrumenting job.py and adding documentation
aravinsiva Aug 4, 2020
719ed83
reconfiguring imports
aravinsiva Aug 4, 2020
72f22b6
quick cleanup of unused variable
aravinsiva Aug 5, 2020
ff8171f
adding more attributes in module and limiting complexity of instrumen…
aravinsiva Aug 7, 2020
456b445
adding tests, nox and correct attribute additions in client & job
aravinsiva Aug 9, 2020
f4aba6d
adding tests, nox and correct attribute additions in client & job (le…
aravinsiva Aug 9, 2020
e223657
linting
aravinsiva Aug 9, 2020
78b8298
reformatting noxfile.[y
aravinsiva Aug 9, 2020
88b1a57
Merge branch 'master' into opentelemetry-tracing
aravinsiva Aug 9, 2020
e0895c9
Merge branch 'master' into opentelemetry-tracing
aravinsiva Aug 10, 2020
95a35ad
addressing suggested changes
aravinsiva Aug 11, 2020
3bf4574
Merge branch 'opentelemetry-tracing' of https://github.com/aravinsiva…
aravinsiva Aug 11, 2020
4dbb692
adding suggested changes
aravinsiva Aug 12, 2020
406f61a
removing print statements
aravinsiva Aug 12, 2020
c2b9add
setting same version across all OT [ackages and other reccommended ch…
aravinsiva Aug 12, 2020
d425909
suggested changes
aravinsiva Aug 12, 2020
64ec5fd
fixing packages issue in nox and updating documentation
aravinsiva Aug 13, 2020
73230dc
fixing module install issue
aravinsiva Aug 13, 2020
ae04fc6
restructuring design for testing adding first layer of tests (some st…
aravinsiva Aug 14, 2020
ac56488
adding reamining client tests and all job tests
aravinsiva Aug 15, 2020
d4de926
fixing linting issues
aravinsiva Aug 15, 2020
2d8aeb3
Merge branch 'master' into opentelemetry-tracing
tswast Aug 17, 2020
cd8e303
fixing trace not defined issue
aravinsiva Aug 17, 2020
d8c601d
fixing lint issues
aravinsiva Aug 17, 2020
2bcd106
fixing documentation issues and python2 testing issue
aravinsiva Aug 17, 2020
f1de589
linting and fixing coverage issues
aravinsiva Aug 18, 2020
72a77d1
Merge branch 'master' into opentelemetry-tracing
tswast Aug 18, 2020
0c7b354
adding suggested changes
aravinsiva Aug 18, 2020
51045f1
Merge branch 'opentelemetry-tracing' of https://github.com/aravinsiva…
aravinsiva Aug 18, 2020
ec96f5c
linting
aravinsiva Aug 18, 2020
35afadf
Merge branch 'master' into opentelemetry-tracing
aravinsiva Aug 18, 2020
5a32ad4
adding Shawn's suggested changes
aravinsiva Aug 19, 2020
1d7155c
Merge branch 'opentelemetry-tracing' of https://github.com/aravinsiva…
aravinsiva Aug 19, 2020
54c133a
fixing _default_span_attribute_bug
aravinsiva Aug 19, 2020
3aff14d
reverting uneccesxsary changes
aravinsiva Aug 19, 2020
59477ff
adding more tests for all job_ref parameters
aravinsiva Aug 19, 2020
0d15998
removing dependecny, ordering imports and other changes
aravinsiva Aug 20, 2020
d997175
addressing Shawn concerns
aravinsiva Aug 20, 2020
61b5b85
adding test and suggested changes
aravinsiva Aug 20, 2020
4d1dec1
adding opentelemetry to setup.py and other suggested changes
aravinsiva Aug 20, 2020
7704975
adding reasoning for not adding to [all]
aravinsiva Aug 20, 2020
839cd92
linting
aravinsiva Aug 20, 2020
dd1e246
adding Tim suggested changes
aravinsiva Aug 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 google-cloud-bigquery[opentelemetry] 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 can be found here:

.. code-block:: python

from opentelemetry import trace
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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



Loading