Skip to content

Commit 4a3be37

Browse files
rethabjonatan-ivanov
authored andcommitted
perf(tracing): short circuit matching baggage key values
Signed-off-by: Reto <[email protected]>
1 parent 4dc6911 commit 4a3be37

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

micrometer-tracing/src/main/java/io/micrometer/tracing/handler/RevertingScope.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ private static Collection<KeyValue> matchingBaggageKeyValues(Tracer tracer, Cont
110110
for (String remoteField : tracer.getBaggageFields()) {
111111
lowerCaseRemoteFields.add(remoteField.toLowerCase());
112112
}
113+
114+
if (lowerCaseRemoteFields.isEmpty()) {
115+
return Collections.emptyList();
116+
}
117+
113118
Collection<KeyValue> baggageKeyValues = new ArrayList<>();
114119
for (KeyValue keyValue : context.getAllKeyValues()) {
115120
if (lowerCaseRemoteFields.contains(keyValue.getKey().toLowerCase())) {

0 commit comments

Comments
 (0)