@@ -26,7 +26,7 @@ configured. If the external services also have a Baggage span
26
26
processor, the keys and values will appear in those child spans as
27
27
well.
28
28
29
- ⚠ Warning ⚠️
29
+ [!WARNING]
30
30
31
31
Do not put sensitive information in Baggage.
32
32
@@ -39,25 +39,32 @@ Add the span processor when configuring the tracer provider.
39
39
40
40
To configure the span processor to copy all baggage entries during configuration:
41
41
42
- ```python
43
- from opentelemetry.processor.baggage import BaggageSpanProcessor, ALLOW_ALL_BAGGAGE_KEYS
42
+ ::
43
+
44
+ from opentelemetry.processor.baggage import BaggageSpanProcessor, ALLOW_ALL_BAGGAGE_KEYS
45
+
46
+ tracer_provider = TracerProvider()
47
+ tracer_provider.add_span_processor(BaggageSpanProcessor(ALLOW_ALL_BAGGAGE_KEYS))
44
48
45
- tracer_provider = TracerProvider()
46
- tracer_provider.add_span_processor(BaggageSpanProcessor(ALLOW_ALL_BAGGAGE_KEYS))
47
- ` ``
48
49
49
50
Alternatively, you can provide a custom baggage key predicate to select which baggage keys you want to copy.
50
51
51
52
For example, to only copy baggage entries that start with `my-key `:
52
53
53
- ```python
54
- starts_with_predicate = lambda baggage_key: baggage_key.startswith("my-key")
55
- tracer_provider.add_span_processor(BaggageSpanProcessor(starts_with_predicate))
56
- ` ``
54
+ ::
55
+
56
+ starts_with_predicate = lambda baggage_key: baggage_key.startswith("my-key")
57
+ tracer_provider.add_span_processor(BaggageSpanProcessor(starts_with_predicate))
58
+
57
59
58
60
For example, to only copy baggage entries that match the regex `^key.+ `:
59
61
60
- ```python
61
- regex_predicate = lambda baggage_key: baggage_key.startswith("^key.+")
62
- tracer_provider.add_span_processor(BaggageSpanProcessor(regex_predicate))
63
- ` ``
62
+ ::
63
+
64
+ regex_predicate = lambda baggage_key: baggage_key.startswith("^key.+")
65
+ tracer_provider.add_span_processor(BaggageSpanProcessor(regex_predicate))
66
+
67
+
68
+ References
69
+ ----------
70
+ * `OpenTelemetry Project <https://opentelemetry.io/ >`_
0 commit comments