Skip to content

Commit 53862b8

Browse files
committed
preserve exisiting api compatibility
1 parent bd5a559 commit 53862b8

3 files changed

Lines changed: 26 additions & 14 deletions

File tree

baggage-processor/README.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,25 @@ To configure the span and log processors to copy all baggage entries during conf
6363

6464
```java
6565
import io.opentelemetry.contrib.baggage.processor;
66+
6667
// ...
6768
6869
TracerProvider tracerProvider = SdkTracerProvider.builder()
69-
.addSpanProcessor(BaggageSpanProcessor.allowAllBaggageKeys())
70+
.addSpanProcessor(new BaggageSpanProcessor(Collections.singletonList("*"), null))
7071
.build();
7172
7273
LoggerProvider loggerProvider = SdkLoggerProvider.builder()
73-
.addLogRecordProcessor(BaggageLogRecordProcessor.allowAllBaggageKeys())
74+
.addLogProcessor(new BaggageLogProcessor(Collections.singletonList("*"), null))
7475
.build();
7576
```
7677

77-
Alternatively, you can provide a custom baggage key predicate to select which baggage keys you want to copy.
78-
79-
For example, to only copy baggage entries that start with `my-key`:
80-
81-
```java
82-
new BaggageSpanProcessor(baggageKey -> baggageKey.startsWith("my-key"));
83-
new BaggageLogRecordProcessor(baggageKey -> baggageKey.startsWith("my-key"));
84-
```
78+
Alternatively, you can provide a custom baggage key wildcard to select which baggage keys you want to copy.
8579

86-
For example, to only copy baggage entries that match the regex `^key.+`:
80+
For example, to only copy baggage entries that start with `my-key` and ignore keys that end with `*-ignored`
8781

8882
```java
89-
Pattern pattern = Pattern.compile("^key.+");
90-
new BaggageSpanProcessor(baggageKey -> pattern.matcher(baggageKey).matches());
91-
new BaggageLogRecordProcessor(baggageKey -> pattern.matcher(baggageKey).matches());
83+
new BaggageSpanProcessor(singletonList("my-key*"), singletonList("*-ignored"));
84+
new BaggageLogRecordProcessor(singletonList("my-key*"), singletonList("*-ignored"));
9285
```
9386

9487
## Component owners

baggage-processor/src/main/java/io/opentelemetry/contrib/baggage/processor/BaggageLogRecordProcessor.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ public BaggageLogRecordProcessor(
4444
this.baggageKeyPredicate = IncludeExcludePredicate.createPatternMatching(included, excluded);
4545
}
4646

47+
/**
48+
* @deprecated use {@code new BaggageLogRecordProcessor(Collections.singletonList("*),null)}
49+
* instead
50+
* @return baggage log processor including all attributes
51+
*/
52+
@Deprecated
53+
public static BaggageLogRecordProcessor allowAllBaggageKeys() {
54+
return new BaggageLogRecordProcessor(excluded -> true);
55+
}
56+
4757
@Override
4858
public void onEmit(Context context, ReadWriteLogRecord logRecord) {
4959
Baggage.fromContext(context)

baggage-processor/src/main/java/io/opentelemetry/contrib/baggage/processor/BaggageSpanProcessor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ public BaggageSpanProcessor(
4444
this.baggageKeyPredicate = IncludeExcludePredicate.createPatternMatching(included, excluded);
4545
}
4646

47+
/**
48+
* @deprecated use {@code new BaggageSpanProcessor(Collections.singletonList("*),null)} instead
49+
* @return baggage span processor including all attributes
50+
*/
51+
@Deprecated
52+
public static BaggageSpanProcessor allowAllBaggageKeys() {
53+
return new BaggageSpanProcessor(baggageKey -> true);
54+
}
55+
4756
@Override
4857
public void onStart(Context parentContext, ReadWriteSpan span) {
4958
Baggage.fromContext(parentContext)

0 commit comments

Comments
 (0)