Skip to content

Commit

Permalink
Updates to Zipkin 2 (openzipkin#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
adriancole committed Sep 12, 2017
1 parent 4a47d68 commit 4245a88
Show file tree
Hide file tree
Showing 72 changed files with 272 additions and 197 deletions.
2 changes: 1 addition & 1 deletion archive/brave-apache-http-interceptors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>
<artifactId>brave-apache-http-interceptors</artifactId>
<name>archive/brave-apache-http-interceptors</name>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-core-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave-core-spring</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-grpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>brave-parent</artifactId>
<groupId>io.zipkin.brave</groupId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>
<artifactId>brave-grpc</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-http-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>brave-parent</artifactId>
<groupId>io.zipkin.brave</groupId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>
<artifactId>brave-http-tests</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave-http</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-jaxrs2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>brave-parent</artifactId>
<groupId>io.zipkin.brave</groupId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>
<artifactId>brave-jaxrs2</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-jersey/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>brave-parent</artifactId>
<groupId>io.zipkin.brave</groupId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>
<artifactId>brave-jersey</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-mysql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>brave-parent</artifactId>
<groupId>io.zipkin.brave</groupId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>
<artifactId>brave-mysql</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-okhttp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>brave-parent</artifactId>
<groupId>io.zipkin.brave</groupId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.TreeMap;
import java.util.logging.Logger;
import zipkin.Span;
import zipkin2.internal.Node;

import static java.util.Arrays.asList;

Expand All @@ -24,7 +25,8 @@ public static List<Span> washIds(List<Span> trace) {
Node.TreeBuilder<Span> treeBuilder = new Node.TreeBuilder<>(logger, Util.toLowerHex(traceId));
for (Span span : trace) {
map.put(span, span);
treeBuilder.addNode(span.parentId, span.id, span);
treeBuilder.addNode(span.parentId != null ? Util.toLowerHex(span.parentId) : null,
Util.toLowerHex(span.id), span);
}

// traverse the tree breadth-first, and replace the ids with incrementing ones
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-p6spy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>brave-parent</artifactId>
<groupId>io.zipkin.brave</groupId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>
<artifactId>brave-p6spy</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-resteasy-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave-resteasy-spring</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-resteasy3-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave-resteasy3-spring</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-sampler-zookeeper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave-sampler-zookeeper</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-spancollector-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave-spancollector-http</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-spancollector-kafka/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave-spancollector-kafka</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-spancollector-local/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave-spancollector-local</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-spancollector-scribe/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave-spancollector-scribe</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-sparkjava/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>brave-parent</artifactId>
<groupId>io.zipkin.brave</groupId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion archive/brave-spring-resttemplate-interceptors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave-spring-resttemplate-interceptors</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-spring-web-servlet-interceptor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave-spring-web-servlet-interceptor</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion archive/brave-web-servlet-filter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>brave-parent</artifactId>
<groupId>io.zipkin.brave</groupId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion brave-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
6 changes: 3 additions & 3 deletions brave/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ http (as opposed to Kafka).
```java
// Configure a reporter, which controls how often spans are sent
// (the dependency is io.zipkin.reporter:zipkin-sender-okhttp3)
sender = OkHttpSender.create("http://127.0.0.1:9411/api/v1/spans");
reporter = AsyncReporter.create(sender);
sender = OkHttpSender.json("http://127.0.0.1:9411/api/v2/spans");
spanReporter = AsyncReporter.v2(sender);
// Create a tracing component with the service name you want to see in Zipkin.
tracing = Tracing.newBuilder()
.localServiceName("my-service")
.reporter(reporter)
.spanReporter(spanReporter)
.build();

// Tracing exposes objects you might need, most importantly the tracer
Expand Down
7 changes: 3 additions & 4 deletions brave/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave-parent</artifactId>
<version>4.6.1-SNAPSHOT</version>
<version>4.7.0-SNAPSHOT</version>
</parent>

<artifactId>brave</artifactId>
Expand Down Expand Up @@ -142,12 +142,11 @@
</artifactSet>
<filters>
<filter>
<!-- Shade references to v2 until zipkin2 is out -->
<!-- Shade references to internal classes -->
<artifact>io.zipkin.java:zipkin</artifact>
<includes>
<include>zipkin/internal/v2/*Span*.class</include>
<include>zipkin/internal/V2SpanConverter*.class</include>
<!-- TODO: v2 currently indirectly references Util -->
<!-- TODO: V2 currently indirectly references Util -->
<include>zipkin/internal/Util.class</include>
</includes>
<excludes>
Expand Down
2 changes: 1 addition & 1 deletion brave/src/main/java/brave/NoopSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import brave.propagation.TraceContext;
import com.google.auto.value.AutoValue;
import zipkin.Endpoint;
import zipkin2.Endpoint;

@AutoValue
abstract class NoopSpan extends Span {
Expand Down
2 changes: 1 addition & 1 deletion brave/src/main/java/brave/RealSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import brave.internal.recorder.Recorder;
import brave.propagation.TraceContext;
import com.google.auto.value.AutoValue;
import zipkin.Endpoint;
import zipkin2.Endpoint;

/** This wraps the public api and guards access to a mutable span. */
@AutoValue
Expand Down
31 changes: 20 additions & 11 deletions brave/src/main/java/brave/Span.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package brave;

import brave.propagation.TraceContext;
import zipkin.Endpoint;
import zipkin2.Endpoint;

/**
* Used to model the latency of an operation.
Expand All @@ -25,8 +25,8 @@ public enum Kind {
CLIENT,
SERVER,
/**
* When present, {@link #start()} is the moment a producer sent a message to a destination.
* A duration between {@link #start()} and {@link #finish()} may imply batching delay. {@link
* When present, {@link #start()} is the moment a producer sent a message to a destination. A
* duration between {@link #start()} and {@link #finish()} may imply batching delay. {@link
* #remoteEndpoint(Endpoint)} indicates the destination, such as a broker.
*
* <p>Unlike {@link #CLIENT}, messaging spans never share a span ID. For example, the {@link
Expand All @@ -35,9 +35,9 @@ public enum Kind {
*/
PRODUCER,
/**
* When present, {@link #start()} is the moment a consumer received a message from an
* origin. A duration between {@link #start()} and {@link #finish()} may imply a processing backlog.
* while {@link #remoteEndpoint(Endpoint)} indicates the origin, such as a broker.
* When present, {@link #start()} is the moment a consumer received a message from an origin. A
* duration between {@link #start()} and {@link #finish()} may imply a processing backlog. while
* {@link #remoteEndpoint(Endpoint)} indicates the origin, such as a broker.
*
* <p>Unlike {@link #SERVER}, messaging spans never share a span ID. For example, the {@link
* #PRODUCER} of this message is the {@link TraceContext#parentId()} of this span.
Expand Down Expand Up @@ -70,8 +70,8 @@ public enum Kind {

/**
* The kind of span is optional. When set, it affects how a span is reported. For example, if the
* kind is {@link Kind#SERVER}, the span's start timestamp is implicitly annotated as "sr"
* and that plus its duration as "ss".
* kind is {@link Kind#SERVER}, the span's start timestamp is implicitly annotated as "sr" and
* that plus its duration as "ss".
*/
public abstract Span kind(Kind kind);

Expand All @@ -84,6 +84,15 @@ public enum Kind {
/** {@inheritDoc} */
@Override public abstract Span tag(String key, String value);

/**
* @deprecated use {@link #remoteEndpoint(Endpoint)}, possibly with {@link zipkin.Endpoint#toV2()}
*/
@Deprecated
public final Span remoteEndpoint(zipkin.Endpoint endpoint) {
if (isNoop()) return this;
return remoteEndpoint(endpoint.toV2());
}

/**
* For a client span, this would be the server's address.
*
Expand Down Expand Up @@ -118,9 +127,9 @@ public enum Kind {
/**
* Reports the span, even if unfinished. Most users will not call this method.
*
* <p>This primarily supports two use cases: one-way spans and orphaned spans.
* For example, a one-way span can be modeled as a span where one tracer calls start and another
* calls finish. In order to report that span from its origin, flush must be called.
* <p>This primarily supports two use cases: one-way spans and orphaned spans. For example, a
* one-way span can be modeled as a span where one tracer calls start and another calls finish. In
* order to report that span from its origin, flush must be called.
*
* <p>Another example is where a user didn't call finish within a deadline or before a shutdown
* occurs. By flushing, you can report what was in progress.
Expand Down
Loading

0 comments on commit 4245a88

Please sign in to comment.