@@ -0,0 +1,2238 @@
+/*%0A * Copyright The OpenTelemetry Authors%0A * SPDX-License-Identifier: Apache-2.0%0A */%0A%0Apackage io.opentelemetry.sdk.trace;%0A%0Aimport io.opentelemetry.api.trace.Span;%0Aimport io.opentelemetry.api.trace.SpanBuilder;%0Aimport io.opentelemetry.api.trace.Tracer;%0Aimport io.opentelemetry.sdk.trace.samplers.Sampler;%0Aimport java.util.concurrent.TimeUnit;%0Aimport org.openjdk.jmh.annotations.Benchmark;%0Aimport org.openjdk.jmh.annotations.BenchmarkMode;%0Aimport org.openjdk.jmh.annotations.Fork;%0Aimport org.openjdk.jmh.annotations.Level;%0Aimport org.openjdk.jmh.annotations.Measurement;%0Aimport org.openjdk.jmh.annotations.Mode;%0Aimport org.openjdk.jmh.annotations.OutputTimeUnit;%0Aimport org.openjdk.jmh.annotations.Scope;%0Aimport org.openjdk.jmh.annotations.Setup;%0Aimport org.openjdk.jmh.annotations.State;%0Aimport org.openjdk.jmh.annotations.Threads;%0Aimport org.openjdk.jmh.annotations.Warmup;%0A%0A@State(Scope.Benchmark)%0Apublic class ExceptionBenchmark %7B%0A  private static SpanBuilder spanBuilder;%0A%0A  @Setup(Level.Trial)%0A  public final void setup() %7B%0A    SdkTracerProvider tracerProvider =%0A        SdkTracerProvider.builder().setSampler(Sampler.alwaysOn()).build();%0A%0A    Tracer tracer = tracerProvider.get(%22benchmarkTracer%22);%0A    spanBuilder = tracer.spanBuilder(%22benchmarkSpanBuilder%22);%0A  %7D%0A%0A  @Benchmark%0A  @Threads(value = 1)%0A  @Fork(1)%0A  @Warmup(iterations = 5, time = 1)%0A  @Measurement(iterations = 10, time = 1)%0A  @OutputTimeUnit(TimeUnit.NANOSECONDS)%0A  @BenchmarkMode(Mode.AverageTime)%0A  public Span createSpan() %7B%0A    Span span = spanBuilder.startSpan();%0A    span.end();%0A    return span;%0A  %7D%0A%0A  @Benchmark%0A  @Threads(value = 1)%0A  @Fork(1)%0A  @Warmup(iterations = 5, time = 1)%0A  @Measurement(iterations = 10, time = 1)%0A  @OutputTimeUnit(TimeUnit.NANOSECONDS)%0A  @BenchmarkMode(Mode.AverageTime)%0A  public Span createSpanAndRecordException() %7B%0A    Span span = spanBuilder.startSpan();%0A    span.recordException(new RuntimeException());%0A    span.end();%0A    return span;%0A  %7D%0A%0A  @Benchmark%0A  @Threads(value = 1)%0A  @Fork(1)%0A  @Warmup(iterations = 5, time = 1)%0A  @Measurement(iterations = 10, time = 1)%0A  @OutputTimeUnit(TimeUnit.NANOSECONDS)%0A  @BenchmarkMode(Mode.AverageTime)%0A  public RuntimeException createException() %7B%0A    return new RuntimeException();%0A  %7D%0A%7D%0A

Add benchmark for recording exception on a span (#3262)