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
Initialize Brave Zipkin tracing for Dropwizard servers and JAX RS clients #235
Conversation
…ents Introduces a Tracer wrapping Brave to produce Zipkin traces and spans to the "tracing" slf4j logger. Typically a Dropwizard server should call `com.palantir.remoting1.servers.DropwizardServers#configure` as part of startup initialization, which will take care of registering the Brave singleton tracer in `com.palantir.remoting1.servers.Tracers#activeTracer` as a Jersey server interceptor. JAX RS clients created via `com.palantir.remoting1.jaxrs.JaxRsClient# builder(com.palantir.remoting1.clients.ClientConfig)` will inherit the active tracer by default, or can provide their own via `ClientConfig`. Similarly the Tracer allows for initiating local traces with its API.
@uschi2000 @markelliot @clockfort for SA |
We still need to fix the span collection plumbing, sampling configuration, and a few more things, but I'm considering those for a followup PR for now. |
before I start reading the code changes: what's the high-level goal of this change? |
Rob, the high level goal is to provide a single unified Brave instance to Dropwizard based applications so that they can do local tracing, and inherit the proper incoming server trace & span as top level local spans' parents. |
Got it, thanks On Thu, Sep 22, 2016 at 4:01 PM David Schlosnagle notifications@github.com
|
This will require some tweaking as http-remoting is shading some Brave components which causes the following issue when using this:
Might also be worth separating the tracing initialization from the other aspects in |
Hmm, I find this all very hard to understand :( There's a strange mixture between static state (e.g., (Or maybe I'm just not getting the point...) |
@@ -57,32 +60,45 @@ private DropwizardTracingFilters() {} | |||
* TODO(rfink) Is there a more stable way to retrieve IP/Port information? | |||
*/ | |||
static void registerTracers(Environment environment, Configuration config, String tracerName) { | |||
ServerTracer serverTracer = getServerTracer(extractIp(config), extractPort(config), tracerName); | |||
final BraveTracer tracer = getOrCreateBraveTracer(config, tracerName); |
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.
final isn't normally used in this codebase
private final Brave brave; | ||
private final SpanId spanId; | ||
|
||
@SuppressWarnings("WeakerAccess") // public API |
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.
this is to suppress the intelliJ hint?
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.
Yes, this suppresses an IntelliJ warning since this is unused in this project
@Test | ||
public void traceCallable() throws Exception { | ||
@SuppressWarnings("unchecked") // yay generic type erasure | ||
Callable<String> mockCallable = mock(Callable.class); |
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.
can get around this with annotation-based mocking:
@Mock
private Foo<Bar> foo;
/** | ||
* Begins a trace context for the specified component and operation. | ||
* | ||
* @param component component name |
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.
remove
* @param component component name | ||
* @param operation operation name | ||
* | ||
* @return new trace context |
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.
remove
/** | ||
* Utility methods for tracing components and operations. | ||
*/ | ||
@SuppressWarnings("WeakerAccess") |
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.
not a fan of this
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.
Still struggling with the semi-coupled nature of our Tracers wrapper and the Brave implementation. Is there a particular reason we need to wrap Brave?
*/ | ||
TraceContext begin(String component, String operation); | ||
|
||
Class<? extends TraceContext> getContextClass(); |
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.
why do we need this?
I'd be fine with exposing Brave directly to both servers (and possibly clients) for use as needed for local tracing -- my main goal here is to get the inheritable state shared across server, client, and local tracers, as well as have a consistent mechanism for configuring the Brave instance to sample & collect spans, so that we can have the configuration injected via service discovery. The main concern for exposing Brave here is that we're tying ourselves to a concrete API. I don't have strong objections to that as I think we can handle breaks and incompatibility as needed for our own http-remoting consumers. Another option might be to use the |
The current PR feels like a limbo with some parts wrapped in our own API On Wed, Sep 28, 2016 at 7:26 PM David Schlosnagle notifications@github.com
|
(Sorry, I have to run now.) On Wed, Sep 28, 2016 at 7:31 PM Robert Fink rf@robertfink.de wrote:
|
I think the challenge with this PR is that it's not a full-measure for wrapping Brave. My basic stance (and I don't feel strongly about which of these to choose) is that we need to either:
If I had to choose, I'd prefer 2. |
@markelliot I don't really want to wrap Brave, I'd rather inject it into all of the places that we want to do tracing, but a lot of the http-remoting APIs currently prevent that and make this more difficult than it needs to be -- e.g. we need to push the trace config into the JaxRs ClientConfig so that tracing there knows what to trace and where to push it. This is made more difficult by the shading done by http-remoting and dependency limitations, which is how I ended up with this PR for the time being. |
Not sure I grok what you're saying – we own all of the JaxRs code, so we could in theory make this simpler? |
I have a cleanup that I think is cleaner -- it will add brace-core and brace-okhttp dependency for http-clients-api. |
Cheers David On Sun, Oct 2, 2016, 13:24 David Schlosnagle notifications@github.com
|
See also #115 |
###### _excavator_ is a bot for automating changes across repositories. Changes produced by the roomba/roomba-lint check. {runtimeCheckDesc} To enable or disable this check, please contact the maintainers of Excavator.
Introduces a Tracer wrapping Brave to produce Zipkin traces and spans to the "tracing" slf4j logger.
Typically a Dropwizard server should call
com.palantir.remoting1.servers.DropwizardServers#configure
as part of startup initialization, which will take care of registering the Brave singleton tracer incom.palantir.remoting1.servers.Tracers#activeTracer
as a Jersey server interceptor.JAX RS clients created via
com.palantir.remoting1.jaxrs.JaxRsClient#builder(com.palantir.remoting1.clients.ClientConfig)
will inherit the active tracer by default, or can provide their own viaClientConfig
.Similarly the Tracer allows for initiating local traces with its API.
Addresses #115