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.11.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.

File details

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

File metadata

File hashes

Hashes for opentelemetry_propagator_gcp-1.11.0.tar.gz
Algorithm Hash digest
SHA256 a8a9ffae6e769fc2155359a4ee35c4d2bae0826a2637fcde67334f596293683d
MD5 45fb8dc2a98745fd2d543dacbd999212
BLAKE2b-256 61d297d57d0214886652e4f051376153629ebe4844728fd0a6cd5f0216f254a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opentelemetry_propagator_gcp-1.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d96d57a8f46c4395ea65be44c46bd7d01e57c43cf93d8a13568e51fe2525f673
MD5 7e60d08b74c81a40f457c69c59c46ab2
BLAKE2b-256 c479e0053c7f516357eabd71187148289a54d051e6996ad28f986795214d418a

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