-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds an internal copy of a span conversion utility mentioned in issue #1499. This is starting internal to ease review and allow incremental progress. The first consumer will be dependency linking.
- Loading branch information
Adrian Cole
committed
Jul 27, 2017
1 parent
d81aede
commit f1066de
Showing
3 changed files
with
901 additions
and
0 deletions.
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
benchmarks/src/main/java/zipkin/benchmarks/Span2ConverterBenchmarks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/** | ||
* Copyright 2015-2017 The OpenZipkin Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package zipkin.benchmarks; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.Threads; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
import org.openjdk.jmh.runner.Runner; | ||
import org.openjdk.jmh.runner.RunnerException; | ||
import org.openjdk.jmh.runner.options.Options; | ||
import org.openjdk.jmh.runner.options.OptionsBuilder; | ||
import zipkin.Annotation; | ||
import zipkin.BinaryAnnotation; | ||
import zipkin.Constants; | ||
import zipkin.Endpoint; | ||
import zipkin.Span; | ||
import zipkin.TraceKeys; | ||
import zipkin.internal.Span2; | ||
import zipkin.internal.Span2Converter; | ||
import zipkin.internal.Util; | ||
|
||
@Measurement(iterations = 5, time = 1) | ||
@Warmup(iterations = 10, time = 1) | ||
@Fork(3) | ||
@BenchmarkMode(Mode.Throughput) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
@State(Scope.Thread) | ||
@Threads(1) | ||
public class Span2ConverterBenchmarks { | ||
Endpoint frontend = Endpoint.create("frontend", 127 << 24 | 1); | ||
Endpoint backend = Endpoint.builder() | ||
.serviceName("backend") | ||
.ipv4(192 << 24 | 168 << 16 | 99 << 8 | 101) | ||
.port(9000) | ||
.build(); | ||
|
||
Span shared = Span.builder() | ||
.traceIdHigh(Util.lowerHexToUnsignedLong("7180c278b62e8f6a")) | ||
.traceId(Util.lowerHexToUnsignedLong("216a2aea45d08fc9")) | ||
.parentId(Util.lowerHexToUnsignedLong("6b221d5bc9e6496c")) | ||
.id(Util.lowerHexToUnsignedLong("5b4185666d50f68b")) | ||
.name("get") | ||
.timestamp(1472470996199000L) | ||
.duration(207000L) | ||
.addAnnotation(Annotation.create(1472470996199000L, Constants.CLIENT_SEND, frontend)) | ||
.addAnnotation(Annotation.create(1472470996238000L, Constants.WIRE_SEND, frontend)) | ||
.addAnnotation(Annotation.create(1472470996250000L, Constants.SERVER_RECV, backend)) | ||
.addAnnotation(Annotation.create(1472470996350000L, Constants.SERVER_SEND, backend)) | ||
.addAnnotation(Annotation.create(1472470996403000L, Constants.WIRE_RECV, frontend)) | ||
.addAnnotation(Annotation.create(1472470996406000L, Constants.CLIENT_RECV, frontend)) | ||
.addBinaryAnnotation(BinaryAnnotation.create(TraceKeys.HTTP_PATH, "/api", frontend)) | ||
.addBinaryAnnotation(BinaryAnnotation.create(TraceKeys.HTTP_PATH, "/backend", backend)) | ||
.addBinaryAnnotation(BinaryAnnotation.create("clnt/finagle.version", "6.45.0", frontend)) | ||
.addBinaryAnnotation(BinaryAnnotation.create("srv/finagle.version", "6.44.0", backend)) | ||
.addBinaryAnnotation(BinaryAnnotation.address(Constants.CLIENT_ADDR, frontend)) | ||
.addBinaryAnnotation(BinaryAnnotation.address(Constants.SERVER_ADDR, backend)) | ||
.build(); | ||
|
||
Span server = Span.builder() | ||
.traceIdHigh(Util.lowerHexToUnsignedLong("7180c278b62e8f6a")) | ||
.traceId(Util.lowerHexToUnsignedLong("216a2aea45d08fc9")) | ||
.parentId(Util.lowerHexToUnsignedLong("6b221d5bc9e6496c")) | ||
.id(Util.lowerHexToUnsignedLong("5b4185666d50f68b")) | ||
.name("get") | ||
.addAnnotation(Annotation.create(1472470996250000L, Constants.SERVER_RECV, backend)) | ||
.addAnnotation(Annotation.create(1472470996350000L, Constants.SERVER_SEND, backend)) | ||
.addBinaryAnnotation(BinaryAnnotation.create(TraceKeys.HTTP_PATH, "/backend", backend)) | ||
.addBinaryAnnotation(BinaryAnnotation.create("srv/finagle.version", "6.44.0", backend)) | ||
.addBinaryAnnotation(BinaryAnnotation.address(Constants.CLIENT_ADDR, frontend)) | ||
.build(); | ||
|
||
Span2 server2 = Span2.builder() | ||
.traceId("7180c278b62e8f6a216a2aea45d08fc9") | ||
.parentId("6b221d5bc9e6496c") | ||
.id("5b4185666d50f68b") | ||
.name("get") | ||
.kind(Span2.Kind.SERVER) | ||
.shared(true) | ||
.localEndpoint(backend) | ||
.remoteEndpoint(frontend) | ||
.timestamp(1472470996250000L) | ||
.duration(100000L) | ||
.putTag(TraceKeys.HTTP_PATH, "/backend") | ||
.putTag("srv/finagle.version", "6.44.0") | ||
.build(); | ||
|
||
@Benchmark public List<Span2> fromSpan_splitShared() { | ||
return Span2Converter.fromSpan(shared); | ||
} | ||
|
||
@Benchmark public List<Span2> fromSpan() { | ||
return Span2Converter.fromSpan(server); | ||
} | ||
|
||
@Benchmark public Span toSpan() { | ||
return Span2Converter.toSpan(server2); | ||
} | ||
|
||
// Convenience main entry-point | ||
public static void main(String[] args) throws RunnerException { | ||
Options opt = new OptionsBuilder() | ||
.include(".*" + Span2ConverterBenchmarks.class.getSimpleName() + ".*") | ||
.build(); | ||
|
||
new Runner(opt).run(); | ||
} | ||
} |
Oops, something went wrong.