Skip to content

Commit

Permalink
Adds BaggagePropagation benchmarks for decorate (#1425)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <adrian@tetrate.io>
  • Loading branch information
codefromthecrypt authored Mar 13, 2024
1 parent b7ece7b commit 69e30f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions instrumentation/benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>
<!-- IntelliJ doesn't know to use annotation processing on tests without this -->
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.amazonaws</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package brave.baggage;

import brave.baggage.BaggagePropagationConfig.SingleBaggageField;
import brave.internal.InternalPropagation;
import brave.internal.codec.HexCodec;
import brave.propagation.B3Propagation;
import brave.propagation.Propagation;
Expand Down Expand Up @@ -65,6 +66,8 @@ public class BaggagePropagationBenchmarks {
}
};

static final TraceContext contextWithBaggage = extractor.extract(incoming).context();

static final Map<String, String> incomingNoBaggage = new LinkedHashMap<String, String>() {
{
injector.inject(context, this);
Expand All @@ -73,6 +76,14 @@ public class BaggagePropagationBenchmarks {

static final Map<String, String> nothingIncoming = Collections.emptyMap();

@Benchmark public TraceContext decorate() {
return factory.decorate(InternalPropagation.instance.shallowCopy(context));
}

@Benchmark public TraceContext decorate_withBaggage() {
return factory.decorate(InternalPropagation.instance.shallowCopy(contextWithBaggage));
}

@Benchmark public void inject() {
Map<String, String> request = new LinkedHashMap<>();
injector.inject(context, request);
Expand Down

0 comments on commit 69e30f3

Please sign in to comment.