Skip to content

Commit 194a640

Browse files
Add docs
1 parent 0bf5874 commit 194a640

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

baggage-processor/README.md

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,63 @@
11
# OpenTelemetry Baggage Span Processor
22

3-
The BaggageSpanProcessor reads entries stored in Baggage from the parent context
4-
and adds the baggage keys and values to the `Span` as attributes on start.
3+
The `BaggageSpanProcessor` and `BaggageLogRecordPRocessor` read entries stored in Baggage from the
4+
parent context and adds the baggage keys and values to the `Span`, respectively `LogRecord`, as
5+
attributes on start, respectively emit.
56

6-
Add this span processor to a tracer provider.
7+
Add this span and log processors to the tracer and logger providers.
78

89
Warning!
910

1011
To repeat: a consequence of adding data to Baggage is that the keys and values
11-
will appear in all outgoing trace context headers from the application.
12+
will appear in all outgoing trace and log context headers from the application.
1213

1314
Do not put sensitive information in Baggage.
1415

1516
## Usage
1617

17-
Add the span processor when configuring the tracer provider.
18+
Add the span and log processor when configuring the tracer and logger providers.
1819

19-
To configure the span processor to copy all baggage entries during configuration:
20+
To configure the span and log processors to copy all baggage entries during configuration:
2021

2122
```java
2223
import io.opentelemetry.contrib.baggage.processor;
2324
// ...
2425

25-
Tracer tracer = SdkTracerProvider.builder()
26-
.addSpanProcessor(new BaggageSpanProcessor(BaggageSpanProcessor.allowAllBaggageKeys))
27-
.build()
26+
TracerProvider tracerProvider = SdkTracerProvider.builder()
27+
.addSpanProcessor(BaggageSpanProcessor.allowAllBaggageKeys())
28+
.build();
29+
30+
LoggerProvider loggerProvider = SdkLoggerProvider.builder()
31+
.addLogRecordProcessor(BaggageLogRecordProcessor.allowAllBaggageKeys())
32+
.build();
2833
```
2934

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

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

3439
```java
35-
new BaggageSpanProcessor(baggageKey -> baggageKey.startsWith("my-key"))
40+
new BaggageSpanProcessor(baggageKey -> baggageKey.startsWith("my-key"));
41+
new BaggageLogRecordProcessor(baggageKey -> baggageKey.startsWith("my-key"));
3642
```
3743

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

4046
```java
4147
Pattern pattern = Pattern.compile("^key.+");
42-
new BaggageSpanProcessor(baggageKey -> pattern.matcher(baggageKey).matches())
48+
new BaggageSpanProcessor(baggageKey -> pattern.matcher(baggageKey).matches());
49+
new BaggageLogRecordProcessor(baggageKey -> pattern.matcher(baggageKey).matches());
4350
```
4451

4552
## Usage with SDK auto-configuration
4653

47-
If you are using the OpenTelemetry SDK auto-configuration, you can add the span processor this
48-
library to configure the span processor.
54+
If you are using the OpenTelemetry SDK auto-configuration, you can add the span and log baggage
55+
processors through configuration.
4956

50-
| Property | Description |
51-
|------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
52-
| otel.java.experimental.span-attributes.copy-from-baggage.include | Add baggage entries as span attributes, e.g. `key1,key2` or `*` to add all baggage items as keys. |
57+
| Property | Description |
58+
|--------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
59+
| `otel.java.experimental.span-attributes.copy-from-baggage.include` | Add baggage entries as span attributes, e.g. `key1,key2` or `*` to add all baggage items as keys. |
60+
| `otel.java.experimental.log-attributes.copy-from-baggage.include` | Add baggage entries as log attributes, e.g. `key1,key2` or `*` to add all baggage items as keys. |
5361

5462
## Component owners
5563

0 commit comments

Comments
 (0)