opentelemetry-python-contrib/processor/opentelemetry-processor-bag...
Emídio Neto 54882871b9
add official support to Python 3.13 (#3134)
* add py313 to tox

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix wrong identation troveclassifiers

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix pyramid, django

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix httpx

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix httpx, grpc and add vertex

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* generate-workflows

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix generate-workflows

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix celery and psycopg

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* add changelog

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* Update CHANGELOG.md

* Update tox.ini

---------

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
2024-12-31 16:08:20 +00:00
..
src/opentelemetry/processor/baggage Update version to 1.30.0.dev/0.51b0.dev (#3092) 2024-12-12 11:17:53 +00:00
tests Add key predicate to baggage span processor (#2535) 2024-05-28 12:49:00 -06:00
LICENSE new(opentelemetry-processor-baggage): add new component (#2436) 2024-04-25 10:25:34 -05:00
README.rst Update README.rst - Fix Markdown (#3156) 2024-12-31 16:31:33 +01:00
pyproject.toml add official support to Python 3.13 (#3134) 2024-12-31 16:08:20 +00:00
test-requirements.txt Add missing requirements and test processor baggage in CI (#2717) 2024-07-29 16:37:44 -06:00

README.rst

OpenTelemetry Baggage Span Processor
====================================

|pypi|

.. |pypi| image:: https://badge.fury.io/py/opentelemetry-processor-baggage.svg
   :target: https://pypi.org/project/opentelemetry-processor-baggage/

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
----------
* `OpenTelemetry Project <https://opentelemetry.io/>`_