Skip to content

Files

opentelemetry-exporter-gcp-trace

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 3, 2025
Jul 18, 2024
Feb 3, 2025
Apr 6, 2021
Apr 6, 2021
Oct 3, 2024
Nov 11, 2022
Dec 23, 2024
Jun 7, 2021

OpenTelemetry Google Cloud Integration

Documentation Status

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.

To learn more about instrumentation and observability, including opinionated recommendations for Google Cloud Observability, visit Instrumentation and observability.

For resource detection and GCP trace context propagation, see opentelemetry-tools-google-cloud. For the Google Cloud Monitoring exporter, see opentelemetry-exporter-gcp-monitoring.

Installation

pip install opentelemetry-exporter-gcp-trace

Usage

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