Skip to main content

OpenTelemetry Baggage Span Processor

Project description

pypi

The BaggageSpanProcessor reads entries stored in Baggage from the parent context and adds the baggage entries’ keys and values to the span as attributes on span start.

Installation

pip install opentelemetry-processor-baggage

Add this span processor to a tracer provider.

Keys and values added to Baggage will appear on subsequent child spans for a trace within this service and be propagated to external services in accordance with any configured propagation formats configured. If the external services also have a Baggage span processor, the keys and values will appear in those child spans as well.

[!WARNING]

Do not put sensitive information in Baggage.

To repeat: a consequence of adding data to Baggage is that the keys and values will appear in all outgoing HTTP headers from the application.

Usage

Add the span processor when configuring the tracer provider.

To configure the span processor to copy all baggage entries during configuration:

from opentelemetry.processor.baggage import BaggageSpanProcessor, ALLOW_ALL_BAGGAGE_KEYS

tracer_provider = TracerProvider()
tracer_provider.add_span_processor(BaggageSpanProcessor(ALLOW_ALL_BAGGAGE_KEYS))

Alternatively, you can provide a custom baggage key predicate to select which baggage keys you want to copy.

For example, to only copy baggage entries that start with my-key:

starts_with_predicate = lambda baggage_key: baggage_key.startswith("my-key")
tracer_provider.add_span_processor(BaggageSpanProcessor(starts_with_predicate))

For example, to only copy baggage entries that match the regex ^key.+:

regex_predicate = lambda baggage_key: baggage_key.startswith("^key.+")
tracer_provider.add_span_processor(BaggageSpanProcessor(regex_predicate))

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_processor_baggage-0.60b1.tar.gz (7.6 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_processor_baggage-0.60b1.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_processor_baggage-0.60b1.tar.gz
Algorithm Hash digest
SHA256 f2c29d593907640b41b57dc23def008e90b5012ba01efab2bf4a622da056c4f9
MD5 38775d9a8fd45353a87bd17252c40f5b
BLAKE2b-256 4ee930a08ac474293efac0c1c4c632e4ffa09fd29b0f05652d6a8c63deabce4b

See more details on using hashes here.

File details

Details for the file opentelemetry_processor_baggage-0.60b1-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_processor_baggage-0.60b1-py3-none-any.whl
Algorithm Hash digest
SHA256 255b0b098afbd409de795e01a53e1b56ca7ec0052ed285ded25c42d1a7a1af47
MD5 fb0405fba007c3ced639c89bca19caae
BLAKE2b-256 911b0c2c59acb16c5d3060d0c8c264211f52fa5153ff4783e1dcf6f2a9e0d088

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