@@ -0,0 +1,3034 @@
+/*%0A * Copyright 2020, OpenTelemetry Authors%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage io.opentelemetry.sdk.trace;%0A%0Aimport io.opentelemetry.sdk.OpenTelemetrySdk;%0Aimport io.opentelemetry.trace.Span.Kind;%0Aimport io.opentelemetry.trace.Status;%0Aimport java.util.concurrent.TimeUnit;%0Aimport org.openjdk.jmh.annotations.Benchmark;%0Aimport org.openjdk.jmh.annotations.Fork;%0Aimport org.openjdk.jmh.annotations.Level;%0Aimport org.openjdk.jmh.annotations.Measurement;%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 SpanBenchmark %7B%0A%0A  private final TracerSdk tracerSdk = OpenTelemetrySdk.getTracerProvider().get(%22benchmarkTracer%22);%0A  private RecordEventsReadableSpan span;%0A%0A  @Setup(Level.Trial)%0A  public final void setup() %7B%0A    SpanBuilderSdk spanBuilderSdk =%0A        (SpanBuilderSdk)%0A            tracerSdk%0A                .spanBuilder(%22benchmarkSpan%22)%0A                .setSpanKind(Kind.CLIENT)%0A                .setAttribute(%22key%22, %22value%22);%0A    span = (RecordEventsReadableSpan) spanBuilderSdk.startSpan();%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.MILLISECONDS)%0A  public void addAttributesEventsStatusEnd_01Thread() %7B%0A    doSpanWork(span);%0A  %7D%0A%0A  @Benchmark%0A  @Threads(value = 5)%0A  @Fork(1)%0A  @Warmup(iterations = 5, time = 1)%0A  @Measurement(iterations = 10, time = 1)%0A  @OutputTimeUnit(TimeUnit.MILLISECONDS)%0A  public void addAttributesEventsStatusEnd_05Threads() %7B%0A    doSpanWork(span);%0A  %7D%0A%0A  @Benchmark%0A  @Threads(value = 2)%0A  @Fork(1)%0A  @Warmup(iterations = 5, time = 1)%0A  @Measurement(iterations = 10, time = 1)%0A  @OutputTimeUnit(TimeUnit.MILLISECONDS)%0A  public void addAttributesEventsStatusEnd_02Threads() %7B%0A    doSpanWork(span);%0A  %7D%0A%0A  @Benchmark%0A  @Threads(value = 10)%0A  @Fork(1)%0A  @Warmup(iterations = 5, time = 1)%0A  @Measurement(iterations = 10, time = 1)%0A  @OutputTimeUnit(TimeUnit.MILLISECONDS)%0A  public void addAttributesEventsStatusEnd_10Threads() %7B%0A    doSpanWork(span);%0A  %7D%0A%0A  private static void doSpanWork(RecordEventsReadableSpan span) %7B%0A    span.setAttribute(%22longAttribute%22, 33L);%0A    span.setAttribute(%22stringAttribute%22, %22test_value%22);%0A    span.setStatus(Status.OK);%0A%0A    span.addEvent(%22testEvent%22);%0A    span.end();%0A  %7D%0A%7D%0A

Add a very basic benchmark for the span implementation (#1012)