Google Cloud Trace exporter for OpenTelemetry
Maintained. Last release 3 months ago, commits in 7 of the last 26 weeks. Weaker on issue handling.
$
pip install opentelemetry-exporter-gcp-traceOpenTelemetry Google Cloud Integration
======================================
.. image:: https://badge.fury.io/py/opentelemetry-exporter-gcp-trace.svg
:target: https://badge.fury.io/py/opentelemetry-exporter-gcp-trace
.. image:: https://readthedocs.org/projects/google-cloud-opentelemetry/badge/?version=latest
:target: https://google-cloud-opentelemetry.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. warning::
**This exporter is deprecated.**
Google Cloud supports native OpenTelemetry Protocol (OTLP) ingestion for Cloud Trace, Cloud Monitoring, and Cloud Logging via the `Telemetry API <https://docs.cloud.google.com/stackdriver/docs/reference/telemetry/overview>`_.
Please refer to the `Migration Guide <https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/blob/main/MIGRATION.md>`_ for detailed instructions on migrating your application to standard OpenTelemetry OTLP exporters.
This library provides support for exporting traces to Google Cloud Trace.
To get started with instrumentation in Google Cloud, see `Generate traces and metrics with
Python <https://cloud.google.com/stackdriver/docs/instrumentation/setup/python>`_.
To learn more about instrumentation and observability, including opinionated recommendations
for Google Cloud Observability, visit `Instrumentation and observability
<https://cloud.google.com/stackdriver/docs/instrumentation/overview>`_.
For resource detection and GCP trace context propagation, see
`opentelemetry-tools-google-cloud
<https://pypi.org/project/opentelemetry-tools-google-cloud/>`_. For the
Google Cloud Monitoring exporter, see
`opentelemetry-exporter-gcp-monitoring
<https://pypi.org/project/opentelemetry-exporter-gcp-monitoring/>`_.
Installation
------------
.. code:: bash
pip install opentelemetry-exporter-gcp-trace
Usage
-----
.. code:: python
from opentelemetry import trace
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
SimpleSpanProcessor,
)
trace.set_tracer_provider(TracerProvider())
cloud_trace_exporter = CloudTraceSpanExporter(
project_id='my-gcloud-project',
)
trace.get_tracer_provider().add_span_processor(
SimpleSpanProcessor(cloud_trace_exporter)
)
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span('foo'):
print('Hello world!')
References
----------
* `Cloud Trace <https://cloud.google.com/trace/>`_
* `OpenTelemetry Project <https://opentelemetry.io/>`_