Skip to main content

Google Cloud propagator for OpenTelemetry

Project description

https://badge.fury.io/py/opentelemetry-propagator-gcp.svg Documentation Status

This library provides support for propagating trace context in the Google Cloud X-Cloud-Trace-Context format.

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.

Installation

pip install opentelemetry-propagator-gcp

Usage

The CloudTraceOneWayPropagator reads the Google Cloud X-Cloud-Trace-Context format, but does not write the X-Cloud-Trace-Context header on outgoing requests. It is intended for use with a CompositePropagator as below.

from opentelemetry.propagate import set_global_textmap
from opentelemetry.propagators.composite import CompositePropagator
from opentelemetry.propagators.cloud_trace_propagator import (
    CloudTraceOneWayPropagator,
)
set_global_textmap(
    CompositePropagator([
        CloudTraceOneWayPropagator(),
        propagate.get_global_textmap(),
    ]),
)

The CloudTraceFormatPropagator reads and writes the X-Cloud-Trace-Context header formats. Note that when using this propagator, the sampled bit is interpreted as the TRACE_TRUE flag, which may cause a higher sampling rate than desired. See the Trace documentation <https://cloud.google.com/trace/docs/setup#force-trace> for additional context.

from opentelemetry.propagate import set_global_textmap
from opentelemetry.propagators.cloud_trace_propagator import (
    CloudTraceFormatPropagator,
)

# Set the X-Cloud-Trace-Context header
set_global_textmap(CloudTraceFormatPropagator())
from opentelemetry.propagate import set_global_textmap
from opentelemetry.propagators.cloud_trace_propagator import (
    CloudTraceFormatPropagator,
)

# Set the X-Cloud-Trace-Context header
set_global_textmap(CloudTraceFormatPropagator())

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opentelemetry_propagator_gcp-1.12.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opentelemetry_propagator_gcp-1.12.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file opentelemetry_propagator_gcp-1.12.0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_propagator_gcp-1.12.0.tar.gz
Algorithm Hash digest
SHA256 5495b891e7c816688d4e12fda7b365572dc8cb7ea8027a4390c5d2d868db1b98
MD5 5455bfb6e4186cf44a9a4f361b11e842
BLAKE2b-256 1e13a12ca18674e4934913e425cc318e5beeb307b7e21cd7308e436a742661fe

See more details on using hashes here.

File details

Details for the file opentelemetry_propagator_gcp-1.12.0-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_propagator_gcp-1.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b7d6b5a2b21cdc8ae6d546c01f38335db44c03125b6248e92a4aa8fbbfdd36f
MD5 469d87de207b1017f777e4b2487adc93
BLAKE2b-256 71e4ef88e2fccc322e92dba9f78fdc97857113337fb290086cb5be3830517100

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page