Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organizes v2 classes into corresponding internal packages #1702

Merged
merged 1 commit into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 24 additions & 25 deletions benchmarks/src/main/java/zipkin/benchmarks/CodecBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
import org.openjdk.jmh.runner.options.OptionsBuilder;
import zipkin.Codec;
import zipkin.Endpoint;
import zipkin.Span;
import zipkin.internal.Span2;
import zipkin.internal.v2.Span;
import zipkin.internal.v2.codec.MessageEncoder;
import zipkin.internal.v2.codec.Decoder;
import zipkin.internal.v2.codec.Encoder;
Expand All @@ -66,22 +65,22 @@ public class CodecBenchmarks {
static final TBinaryProtocol.Factory TBINARY_PROTOCOL_FACTORY = new TBinaryProtocol.Factory();

static final byte[] localSpanJson = read("/span-local.json");
static final Span localSpan = Codec.JSON.readSpan(localSpanJson);
static final zipkin.Span localSpan = Codec.JSON.readSpan(localSpanJson);
static final byte[] localSpanThrift = Codec.THRIFT.writeSpan(localSpan);
static final com.twitter.zipkin.thriftjava.Span localSpanLibThrift = deserialize(localSpanThrift);

@Benchmark
public Span readLocalSpan_json_zipkin() {
public zipkin.Span readLocalSpan_json_zipkin() {
return Codec.JSON.readSpan(localSpanJson);
}

@Benchmark
public Span readLocalSpan_thrift_zipkin() {
public zipkin.Span readLocalSpan_thrift_zipkin() {
return Codec.THRIFT.readSpan(localSpanThrift);
}

@Benchmark
public Span readLocalSpan_thrift_libthrift() {
public zipkin.Span readLocalSpan_thrift_libthrift() {
return toZipkinSpan(deserialize(localSpanThrift));
}

Expand All @@ -101,36 +100,36 @@ public byte[] writeLocalSpan_thrift_libthrift() throws TException {
}

static final byte[] clientSpanJson = read("/span-client.json");
static final Span clientSpan = Codec.JSON.readSpan(clientSpanJson);
static final zipkin.Span clientSpan = Codec.JSON.readSpan(clientSpanJson);
static final byte[] clientSpanThrift = Codec.THRIFT.writeSpan(clientSpan);
static final com.twitter.zipkin.thriftjava.Span clientSpanLibThrift =
deserialize(clientSpanThrift);
static final List<Span> tenClientSpans = Collections.nCopies(10, clientSpan);
static final List<zipkin.Span> tenClientSpans = Collections.nCopies(10, clientSpan);
static final byte[] tenClientSpansJson = Codec.JSON.writeSpans(tenClientSpans);
static final byte[] tenClientSpansThrift = Codec.THRIFT.writeSpans(tenClientSpans);

@Benchmark
public Span readClientSpan_json_zipkin() {
public zipkin.Span readClientSpan_json_zipkin() {
return Codec.JSON.readSpan(clientSpanJson);
}

@Benchmark
public List<Span> readTenClientSpans_json_zipkin() {
public List<zipkin.Span> readTenClientSpans_json_zipkin() {
return Codec.JSON.readSpans(tenClientSpansJson);
}

@Benchmark
public Span readClientSpan_thrift_zipkin() {
public zipkin.Span readClientSpan_thrift_zipkin() {
return Codec.THRIFT.readSpan(clientSpanThrift);
}

@Benchmark
public List<Span> readTenClientSpans_thrift_zipkin() {
public List<zipkin.Span> readTenClientSpans_thrift_zipkin() {
return Codec.THRIFT.readSpans(tenClientSpansThrift);
}

@Benchmark
public Span readClientSpan_thrift_libthrift() {
public zipkin.Span readClientSpan_thrift_libthrift() {
return toZipkinSpan(deserialize(clientSpanThrift));
}

Expand Down Expand Up @@ -159,13 +158,13 @@ public byte[] writeClientSpan_thrift_libthrift() throws TException {
return serialize(clientSpanLibThrift);
}

static final Span2 span2 = Decoder.JSON.decodeList(read("/span2.json")).get(0);
static final Span span2 = Decoder.JSON.decodeList(read("/span2.json")).get(0);
static final byte[] tenClientSpan2sJson = MessageEncoder.JSON_BYTES.encode(
Collections.nCopies(10, span2).stream().map(Encoder.JSON::encode).collect(Collectors.toList())
);

@Benchmark
public List<Span2> readTenClientSpans_json_span2() {
public List<Span> readTenClientSpans_json_span2() {
return Decoder.JSON.decodeList(tenClientSpan2sJson);
}

Expand All @@ -175,22 +174,22 @@ public byte[] writeClientSpan_json_span2() {
}

static final byte[] rpcSpanJson = read("/span-rpc.json");
static final Span rpcSpan = Codec.JSON.readSpan(rpcSpanJson);
static final zipkin.Span rpcSpan = Codec.JSON.readSpan(rpcSpanJson);
static final byte[] rpcSpanThrift = Codec.THRIFT.writeSpan(rpcSpan);
static final com.twitter.zipkin.thriftjava.Span rpcSpanLibThrift = deserialize(rpcSpanThrift);

@Benchmark
public Span readRpcSpan_json_zipkin() {
public zipkin.Span readRpcSpan_json_zipkin() {
return Codec.JSON.readSpan(rpcSpanJson);
}

@Benchmark
public Span readRpcSpan_thrift_zipkin() {
public zipkin.Span readRpcSpan_thrift_zipkin() {
return Codec.THRIFT.readSpan(rpcSpanThrift);
}

@Benchmark
public Span readRpcSpan_thrift_libthrift() {
public zipkin.Span readRpcSpan_thrift_libthrift() {
return toZipkinSpan(deserialize(rpcSpanThrift));
}

Expand All @@ -210,22 +209,22 @@ public byte[] writeRpcSpan_thrift_libthrift() throws TException {
}

static final byte[] rpcV6SpanJson = read("/span-rpc-ipv6.json");
static final Span rpcV6Span = Codec.JSON.readSpan(rpcV6SpanJson);
static final zipkin.Span rpcV6Span = Codec.JSON.readSpan(rpcV6SpanJson);
static final byte[] rpcV6SpanThrift = Codec.THRIFT.writeSpan(rpcV6Span);
static final com.twitter.zipkin.thriftjava.Span rpcV6SpanLibThrift = deserialize(rpcV6SpanThrift);

@Benchmark
public Span readRpcV6Span_json_zipkin() {
public zipkin.Span readRpcV6Span_json_zipkin() {
return Codec.JSON.readSpan(rpcV6SpanJson);
}

@Benchmark
public Span readRpcV6Span_thrift_zipkin() {
public zipkin.Span readRpcV6Span_thrift_zipkin() {
return Codec.THRIFT.readSpan(rpcV6SpanThrift);
}

@Benchmark
public Span readRpcV6Span_thrift_libthrift() {
public zipkin.Span readRpcV6Span_thrift_libthrift() {
return toZipkinSpan(deserialize(rpcV6SpanThrift));
}

Expand Down Expand Up @@ -282,8 +281,8 @@ private static com.twitter.zipkin.thriftjava.Span deserialize(byte[] serialized)
* uses immutable collections, etc. When comparing codec, make sure you copy-out as structs like
* libthrift do no validation, which is cheaper, but not usable in zipkin.
*/
private static Span toZipkinSpan(com.twitter.zipkin.thriftjava.Span libthriftSpan) {
Span.Builder builder = Span.builder()
private static zipkin.Span toZipkinSpan(com.twitter.zipkin.thriftjava.Span libthriftSpan) {
zipkin.Span.Builder builder = zipkin.Span.builder()
.traceId(libthriftSpan.trace_id)
.id(libthriftSpan.id)
.parentId(libthriftSpan.isSetParent_id() ? libthriftSpan.parent_id : null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@
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.v2.Span;
import zipkin.internal.V2SpanConverter;
import zipkin.internal.Util;

@Measurement(iterations = 5, time = 1)
Expand All @@ -54,7 +53,7 @@ public class Span2ConverterBenchmarks {
.port(9000)
.build();

Span shared = Span.builder()
zipkin.Span shared = zipkin.Span.builder()
.traceIdHigh(Util.lowerHexToUnsignedLong("7180c278b62e8f6a"))
.traceId(Util.lowerHexToUnsignedLong("216a2aea45d08fc9"))
.parentId(Util.lowerHexToUnsignedLong("6b221d5bc9e6496c"))
Expand All @@ -76,7 +75,7 @@ public class Span2ConverterBenchmarks {
.addBinaryAnnotation(BinaryAnnotation.address(Constants.SERVER_ADDR, backend))
.build();

Span server = Span.builder()
zipkin.Span server = zipkin.Span.builder()
.traceIdHigh(Util.lowerHexToUnsignedLong("7180c278b62e8f6a"))
.traceId(Util.lowerHexToUnsignedLong("216a2aea45d08fc9"))
.parentId(Util.lowerHexToUnsignedLong("6b221d5bc9e6496c"))
Expand All @@ -89,12 +88,12 @@ public class Span2ConverterBenchmarks {
.addBinaryAnnotation(BinaryAnnotation.address(Constants.CLIENT_ADDR, frontend))
.build();

Span2 server2 = Span2.builder()
Span server2 = Span.builder()
.traceId("7180c278b62e8f6a216a2aea45d08fc9")
.parentId("6b221d5bc9e6496c")
.id("5b4185666d50f68b")
.name("get")
.kind(Span2.Kind.SERVER)
.kind(Span.Kind.SERVER)
.shared(true)
.localEndpoint(backend)
.remoteEndpoint(frontend)
Expand All @@ -104,16 +103,16 @@ public class Span2ConverterBenchmarks {
.putTag("srv/finagle.version", "6.44.0")
.build();

@Benchmark public List<Span2> fromSpan_splitShared() {
return Span2Converter.fromSpan(shared);
@Benchmark public List<Span> fromSpan_splitShared() {
return V2SpanConverter.fromSpan(shared);
}

@Benchmark public List<Span2> fromSpan() {
return Span2Converter.fromSpan(server);
@Benchmark public List<Span> fromSpan() {
return V2SpanConverter.fromSpan(server);
}

@Benchmark public Span toSpan() {
return Span2Converter.toSpan(server2);
@Benchmark public zipkin.Span toSpan() {
return V2SpanConverter.toSpan(server2);
}

// Convenience main entry-point
Expand Down
37 changes: 18 additions & 19 deletions benchmarks/src/main/java/zipkin/benchmarks/SpanBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
import zipkin.BinaryAnnotation;
import zipkin.Constants;
import zipkin.Endpoint;
import zipkin.Span;
import zipkin.TraceKeys;
import zipkin.internal.Span2;
import zipkin.internal.v2.Span;
import zipkin.internal.Util;

@Measurement(iterations = 5, time = 1)
Expand All @@ -50,17 +49,17 @@ public class SpanBenchmarks {
static final Endpoint app =
Endpoint.builder().serviceName("app").ipv4(172 << 24 | 17 << 16 | 2).port(8080).build();

final Span.Builder sharedBuilder;
final Span2.Builder shared2Builder;
final zipkin.Span.Builder sharedBuilder;
final Span.Builder shared2Builder;

public SpanBenchmarks() {
sharedBuilder = buildClientOnlySpan(Span.builder()).toBuilder();
sharedBuilder = buildClientOnlySpan(zipkin.Span.builder()).toBuilder();
shared2Builder = buildClientOnlySpan2().toBuilder();
}

@Benchmark
public Span buildLocalSpan() {
return Span.builder()
public zipkin.Span buildLocalSpan() {
return zipkin.Span.builder()
.traceId(1L)
.id(1L)
.name("work")
Expand All @@ -80,11 +79,11 @@ public Span buildLocalSpan() {
.build();

@Benchmark
public Span buildClientOnlySpan() {
return buildClientOnlySpan(Span.builder());
public zipkin.Span buildClientOnlySpan() {
return buildClientOnlySpan(zipkin.Span.builder());
}

static Span buildClientOnlySpan(Span.Builder builder) {
static zipkin.Span buildClientOnlySpan(zipkin.Span.Builder builder) {
return builder
.traceId(traceId)
.parentId(traceId)
Expand All @@ -103,22 +102,22 @@ static Span buildClientOnlySpan(Span.Builder builder) {
}

@Benchmark
public Span buildClientOnlySpan_clear() {
public zipkin.Span buildClientOnlySpan_clear() {
return buildClientOnlySpan(sharedBuilder.clear());
}

@Benchmark
public Span2 buildClientOnlySpan2() {
return buildClientOnlySpan2(Span2.builder());
public Span buildClientOnlySpan2() {
return buildClientOnlySpan2(Span.builder());
}

static Span2 buildClientOnlySpan2(Span2.Builder builder) {
static Span buildClientOnlySpan2(Span.Builder builder) {
return builder
.traceId(traceId)
.parentId(traceId)
.id(spanId)
.name("get")
.kind(Span2.Kind.CLIENT)
.kind(Span.Kind.CLIENT)
.localEndpoint(frontend)
.remoteEndpoint(backend)
.timestamp(1472470996199000L)
Expand All @@ -131,18 +130,18 @@ static Span2 buildClientOnlySpan2(Span2.Builder builder) {
}

@Benchmark
public Span2 buildClientOnlySpan2_clear() {
public Span buildClientOnlySpan2_clear() {
return buildClientOnlySpan2(shared2Builder.clear());
}

@Benchmark
public Span2 buildClientOnlySpan2_clone() {
public Span buildClientOnlySpan2_clone() {
return shared2Builder.clone().build();
}

@Benchmark
public Span buildRpcSpan() {
return Span.builder() // web calls app
public zipkin.Span buildRpcSpan() {
return zipkin.Span.builder() // web calls app
.traceId(1L)
.id(2L)
.parentId(1L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import zipkin.collector.InMemoryCollectorMetrics;
import zipkin.collector.kafka.KafkaCollector.Builder;
import zipkin.internal.ApplyTimestampAndDuration;
import zipkin.internal.Span2Converter;
import zipkin.internal.V2SpanConverter;
import zipkin.internal.v2.codec.MessageEncoder;
import zipkin.internal.v2.codec.Encoder;
import zipkin.storage.AsyncSpanConsumer;
Expand Down Expand Up @@ -148,8 +148,8 @@ public void messageWithMultipleSpans_json2() throws Exception {
);

byte[] message = MessageEncoder.JSON_BYTES.encode(asList(
Encoder.JSON.encode(Span2Converter.fromSpan(spans.get(0)).get(0)),
Encoder.JSON.encode(Span2Converter.fromSpan(spans.get(1)).get(0))
Encoder.JSON.encode(V2SpanConverter.fromSpan(spans.get(0)).get(0)),
Encoder.JSON.encode(V2SpanConverter.fromSpan(spans.get(1)).get(0))
));

producer.send(new KeyedMessage<>(builder.topic, message));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import zipkin.collector.InMemoryCollectorMetrics;
import zipkin.collector.kafka10.KafkaCollector.Builder;
import zipkin.internal.ApplyTimestampAndDuration;
import zipkin.internal.Span2Converter;
import zipkin.internal.V2SpanConverter;
import zipkin.internal.v2.codec.MessageEncoder;
import zipkin.internal.v2.codec.Encoder;
import zipkin.storage.AsyncSpanConsumer;
Expand Down Expand Up @@ -202,8 +202,8 @@ public void messageWithMultipleSpans_json2() throws Exception {
);

byte[] message = MessageEncoder.JSON_BYTES.encode(asList(
Encoder.JSON.encode(Span2Converter.fromSpan(spans.get(0)).get(0)),
Encoder.JSON.encode(Span2Converter.fromSpan(spans.get(1)).get(0))
Encoder.JSON.encode(V2SpanConverter.fromSpan(spans.get(0)).get(0)),
Encoder.JSON.encode(V2SpanConverter.fromSpan(spans.get(1)).get(0))
));

produceSpans(message, builder.topic);
Expand Down
4 changes: 2 additions & 2 deletions zipkin-junit/src/main/java/zipkin/junit/ZipkinDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import zipkin.SpanDecoder;
import zipkin.collector.Collector;
import zipkin.collector.CollectorMetrics;
import zipkin.internal.Span2JsonSpanDecoder;
import zipkin.internal.V2JsonSpanDecoder;
import zipkin.storage.Callback;
import zipkin.storage.QueryRequest;
import zipkin.storage.SpanStore;
Expand All @@ -37,7 +37,7 @@
import static zipkin.internal.Util.lowerHexToUnsignedLong;

final class ZipkinDispatcher extends Dispatcher {
static final SpanDecoder JSON2_DECODER = new Span2JsonSpanDecoder();
static final SpanDecoder JSON2_DECODER = new V2JsonSpanDecoder();

private final SpanStore store;
private final Collector consumer;
Expand Down
Loading