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.9.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for opentelemetry_propagator_gcp-1.9.0.tar.gz
Algorithm Hash digest
SHA256 ddc08b7742b17bd36668b042dbf43e1205aaa61e98f05c2040bc7612caa6dc87
MD5 55daafb82df8f4593e2aa9b428bb24bd
BLAKE2b-256 082aa4f67888d24f9e7483f8860958eb14ae418e0297749d9c3eb1f1add2e202

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opentelemetry_propagator_gcp-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80affc99d5dde26fdf2b1c9bf1daafee3bb56c399172e1cc64aa3e0911d6fcf8
MD5 e3dd2cd740a6fa1a1656505b02b023a8
BLAKE2b-256 8b22f6ceae4240ce62d8c4f9c8939204440fd04cf465e9f5aa2bad06bc557686

See more details on using hashes here.

Supported by

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