-
Notifications
You must be signed in to change notification settings - Fork 39
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
OT API using Brave 4 #14
Merged
codefromthecrypt
merged 17 commits into
openzipkin-contrib:master
from
DealerDotCom:brave4
Feb 4, 2017
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f99fdab
Add retrolambda and update to brave 4
b6848db
Adding stup classes using plain interfaces instead of abstract classe…
886455f
Javadoc fixes. TODOs. BraveTracer calling BraveSpanBuilder.
d9d6cf7
I like this better
ebd3892
Copied the existing impl out of the io.zipkin.brave:brave tests
b0e13e3
Finished copying the existing impl out of the io.zipkin.brave:brave t…
568bbb1
Bring in the test from brave:brave
01a28f3
Fix licenses
1c5b8b8
Make exception messages the same
f422130
That needs to be public for actually using this thing
28b15cc
The constructor can be private also
ba16059
Code review changes
05cc1ab
Better context object construction
d88970e
Code review changes, finalizing all types. Should be closer. Needs mo…
00cc6c8
Better block comment for BraveTracer
8bd0a29
More documentation
113631c
Modify startup section of readme
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -30,6 +30,14 @@ | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding> | ||
|
||
<!-- default bytecode version for src/main --> | ||
<main.java.version>1.7</main.java.version> | ||
<main.signature.artifact>java17</main.signature.artifact> | ||
|
||
<!-- default bytecode version for src/test --> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
|
||
<main.basedir>${project.basedir}</main.basedir> | ||
</properties> | ||
|
||
|
@@ -80,19 +88,16 @@ | |
<dependencies> | ||
<dependency> | ||
<groupId>io.opentracing</groupId> | ||
<artifactId>opentracing-impl</artifactId> | ||
<artifactId>opentracing-api</artifactId> | ||
<version>0.20.7</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.zipkin.brave</groupId> | ||
<artifactId>brave-core</artifactId> | ||
<version>3.17.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.zipkin.brave</groupId> | ||
<artifactId>brave-http</artifactId> | ||
<version>3.17.0</version> | ||
<artifactId>brave</artifactId> | ||
<version>4.0.3</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
|
@@ -105,6 +110,12 @@ | |
<version>1.10.19</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<version>3.6.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
|
@@ -113,9 +124,10 @@ | |
<plugin> | ||
<inherited>true</inherited> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.6.0</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
|
@@ -125,12 +137,30 @@ | |
<goal>compile</goal> | ||
</goals> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>net.orfjackal.retrolambda</groupId> | ||
<artifactId>retrolambda-maven-plugin</artifactId> | ||
<version>2.4.0</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>process-main</goal> | ||
</goals> | ||
<configuration> | ||
<target>${main.java.version}</target> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks good |
||
<fork>false</fork> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<!-- Language-level aside, make sure Java 9 types and methods aren't used --> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
|
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,218 @@ | ||
/** | ||
* Copyright 2016-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 brave.opentracing; | ||
|
||
import io.opentracing.Span; | ||
import io.opentracing.SpanContext; | ||
|
||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
/** | ||
* Holds the {@linkplain brave.Span} used by the underlying {@linkplain brave.Tracer}.\ | ||
* | ||
* <p>This type also includes hooks to integrate with the underlying {@linkplain brave.Tracer}. | ||
* Ex you can access the underlying span with {@link #unwrap} | ||
*/ | ||
public final class BraveSpan implements Span { | ||
|
||
/** | ||
* Converts an existing {@linkplain brave.Span} for use in OpenTracing apis | ||
*/ | ||
static BraveSpan wrap(brave.Span span) { | ||
if (span == null) throw new NullPointerException("span == null"); | ||
return new BraveSpan(span); | ||
} | ||
|
||
/** | ||
* Converts an existing {@linkplain brave.Span} for use in OpenTracing apis | ||
*/ | ||
public final brave.Span unwrap() { | ||
return delegate; | ||
} | ||
|
||
private final brave.Span delegate; | ||
private final SpanContext context; | ||
|
||
private BraveSpan(brave.Span delegate) { | ||
this.delegate = delegate; | ||
this.context = BraveSpanContext.wrap(delegate.context()); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public SpanContext context() { | ||
return context; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void finish() { | ||
delegate.finish(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void finish(long finishMicros) { | ||
delegate.finish(finishMicros); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void close() { | ||
delegate.close(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Span setTag(String key, String value) { | ||
delegate.tag(key, value); | ||
return this; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Span setTag(String key, boolean value) { | ||
return setTag(key, Boolean.toString(value)); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Span setTag(String key, Number value) { | ||
return setTag(key, value.toString()); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Span log(Map<String, ?> fields) { | ||
if (fields.isEmpty()) return this; | ||
// in real life, do like zipkin-go-opentracing: "key1=value1 key2=value2" | ||
return log(toAnnotation(fields)); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Span log(long timestampMicroseconds, Map<String, ?> fields) { | ||
if (fields.isEmpty()) return this; | ||
// in real life, do like zipkin-go-opentracing: "key1=value1 key2=value2" | ||
return log(timestampMicroseconds, toAnnotation(fields)); | ||
} | ||
|
||
/** | ||
* Converts a map to a string of form: "key1=value1 key2=value2" | ||
*/ | ||
static String toAnnotation(Map<String, ?> fields) { | ||
// special-case the "event" field which is similar to the semantics of a zipkin annotation | ||
Object event = fields.get("event"); | ||
if (event != null && fields.size() == 1) return event.toString(); | ||
|
||
return joinOnEqualsSpace(fields); | ||
} | ||
|
||
static String joinOnEqualsSpace(Map<String, ?> fields) { | ||
if (fields.isEmpty()) return ""; | ||
|
||
StringBuilder result = new StringBuilder(); | ||
for (Iterator<? extends Map.Entry<String, ?>> i = fields.entrySet().iterator(); i.hasNext(); ) { | ||
Map.Entry<String, ?> next = i.next(); | ||
result.append(next.getKey()).append('=').append(next.getValue()); | ||
if (i.hasNext()) result.append(' '); | ||
} | ||
return result.toString(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Span log(String event) { | ||
delegate.annotate(event); | ||
return this; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Span log(long timestampMicroseconds, String event) { | ||
delegate.annotate(timestampMicroseconds, event); | ||
return this; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Span log(String eventName, Object ignored) { | ||
return log(eventName); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Span log(long timestampMicroseconds, String eventName, Object ignored) { | ||
return log(timestampMicroseconds, eventName); | ||
} | ||
|
||
/** | ||
* This is a NOOP as neither <a href="https://github.com/openzipkin/b3-propagation">B3</a> | ||
* nor Brave include baggage support. | ||
*/ | ||
// OpenTracing could one day define a way to plug-in arbitrary baggage handling similar to how | ||
// it has feature-specific apis like active-span | ||
@Override | ||
public Span setBaggageItem(String key, String value) { | ||
// brave does not support baggage | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns null as neither <a href="https://github.com/openzipkin/b3-propagation">B3</a> | ||
* nor Brave include baggage support. | ||
*/ | ||
// OpenTracing could one day define a way to plug-in arbitrary baggage handling similar to how | ||
// it has feature-specific apis like active-span | ||
@Override | ||
public String getBaggageItem(String key) { | ||
return null; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Span setOperationName(String operationName) { | ||
delegate.name(operationName); | ||
return this; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add or replace the root README with one that looks like the one from openzipkin/brave/brave (particularly the section about converting in-out from brave 3, as this is similar to converting in and out of opentracing)