Skip to content
Permalink
Browse files
feat: add opentelemetry tracing (#215)
* testing first trace export

* instrumention client.py

* instrumenting job.py and adding documentation

* reconfiguring imports

* quick cleanup of unused variable

* adding more attributes in module and limiting complexity of instrumentation

* adding tests, nox and correct attribute additions in client & job

* adding tests, nox and correct attribute additions in client & job (left out of last commit)

* linting

* reformatting noxfile.[y

* addressing suggested changes

* adding suggested changes

* removing print statements

* setting same version across all OT [ackages and other reccommended changes

* suggested changes

* fixing packages issue in nox and updating documentation

* fixing module install issue

* restructuring design for testing adding first layer of tests (some still failing)

* adding reamining client tests and all job tests

* fixing linting issues

* fixing trace not defined issue

* fixing lint issues

* fixing documentation issues and python2 testing issue

* linting and fixing coverage issues

* adding suggested changes

* linting

* adding Shawn's suggested changes

* fixing _default_span_attribute_bug

* reverting uneccesxsary changes

* adding more tests for all job_ref parameters

* removing dependecny, ordering imports and other changes

* addressing Shawn concerns

* adding test and suggested changes

* adding opentelemetry to setup.py and other suggested changes

* adding reasoning for not adding to [all]

* linting

* adding Tim suggested changes

Co-authored-by: Tim Swast <swast@google.com>
  • Loading branch information
aravinsiva and tswast committed Aug 21, 2020
1 parent 1c601aa commit a04996c537e9d8847411fcbb1b05da5f175b339e
Showing with 1,506 additions and 319 deletions.
  1. +38 −0 README.rst
  2. +219 −98 google/cloud/bigquery/client.py
  3. +46 −25 google/cloud/bigquery/job.py
  4. +122 −0 google/cloud/bigquery/opentelemetry_tracing.py
  5. +5 −0 noxfile.py
  6. +10 −1 setup.py
  7. +556 −133 tests/unit/test_client.py
  8. +298 −62 tests/unit/test_job.py
  9. +212 −0 tests/unit/test_opentelemetry_tracing.py
@@ -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
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

0 comments on commit a04996c

Please sign in to comment.