Skip to content

Commit

Permalink
Adds zipkin.internal.Span2
Browse files Browse the repository at this point in the history
This adds an internal copy of the new span data structure defined 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 b40b50b commit d81aede
Show file tree
Hide file tree
Showing 4 changed files with 571 additions and 0 deletions.
36 changes: 36 additions & 0 deletions benchmarks/src/main/java/zipkin/benchmarks/SpanBenchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import zipkin.Endpoint;
import zipkin.Span;
import zipkin.TraceKeys;
import zipkin.internal.Span2;
import zipkin.internal.Util;

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

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

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

@Benchmark
Expand Down Expand Up @@ -104,6 +107,39 @@ public Span buildClientOnlySpan_clear() {
return buildClientOnlySpan(sharedBuilder.clear());
}

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

static Span2 buildClientOnlySpan2(Span2.Builder builder) {
return builder
.traceId(traceId)
.parentId(traceId)
.id(spanId)
.name("get")
.kind(Span2.Kind.CLIENT)
.localEndpoint(frontend)
.remoteEndpoint(backend)
.timestamp(1472470996199000L)
.duration(207000L)
.addAnnotation(1472470996238000L, Constants.WIRE_SEND)
.addAnnotation(1472470996403000L, Constants.WIRE_RECV)
.putTag(TraceKeys.HTTP_PATH, "/api")
.putTag("clnt/finagle.version", "6.45.0")
.build();
}

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

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

@Benchmark
public Span buildRpcSpan() {
return Span.builder() // web calls app
Expand Down
6 changes: 6 additions & 0 deletions zipkin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
</properties>

<dependencies>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down
Loading

0 comments on commit d81aede

Please sign in to comment.