-
Notifications
You must be signed in to change notification settings - Fork 714
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
Adds Cassandra client and server integration #414
Conversation
|
||
// By default, B3 style is used, so instrumented clients do something like this | ||
Map<String, ByteBuffer> payload = new LinkedHashMap<>(); | ||
payload.set("X-B3-TraceId", byteBuffer("463ac35c9f6413ad")); |
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.
note that brave allows you to change the propagation format. I intentionally decided to not go with the finagle binary encoding as most people don't understand what that is. B3 is reasonably well documented, so a better default IMHO.
e79581a
to
1f18ddb
Compare
1f18ddb
to
4df48db
Compare
a20c40d
to
e6e3cc5
Compare
buffed the |
I'm going to rename CassandraDriverX to CassandraClientX in a separate commit. @llinder etc let me know if you disagree with this choice. |
e6e3cc5
to
f9fd710
Compare
OK I think this is good for a first cut. I'll integrate in zipkin and if it works have no more changes planned for the initial impl. We can always add more functionality later (and likely will need to) |
73fa549
to
0f3eca9
Compare
updated to use the SpanCustomizer type |
3ee0eba
to
8f0a91a
Compare
I'm not going to merge this until some folks savvy with cassandra have a chance to play around with it. |
8f0a91a
to
00f77e0
Compare
This contains tracing instrumentation for [Cassandra](https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/tracing/Tracing.java) and the [DataStax Java Driver](https://github.com/datastax/java-driver). `brave.cassandra.Tracing` extracts trace state from the custom payload of incoming requests. How long each request takes, each suboperation, and relevant tags like the session ID are reported to Zipkin. `brave.cassandra.driver.TracingSession` tracks the client-side of cassandra and adds trace context to the custom payload of outgoing requests. If server integration is in place, cassandra will contribute data to these RPC spans.
ps considering the scope of this includes 3 modules, it might make more sense to bump this to a separate repository brave-cassandra. Any thoughts? |
👍 to new repo if there will be a bunch of churn on that. Not sure what the cadence is for the cassandra project |
Separate repository sounds good to me. |
Looks like a solid start. I will give this a go in one of our services in pre-production as soon as I can. Just want to finish up the Ratpack work first. |
if (!span.isNoop()) parser.request(statement, span.kind(CLIENT)); | ||
|
||
// o.a.c.tracing.Tracing.newSession must use the same propagation format | ||
if (version.compareTo(ProtocolVersion.V4) >= 0) { |
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.
does it break the request if outgoingPayload is added to it against a server that doesn't support it (ie < V4) ?
(if not, then why not just add it anyway…)
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.
you'd know better than me :) To test this though, I suppose we could add an invoker test that uses an older version of cassandra..
span.finish(); | ||
throw e; | ||
} | ||
Futures.addCallback(result, new FutureCallback<ResultSet>() { |
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.
have we any idea on the impact adding all the callbacks will cause.
EG in a client that processes 10k+ requests per second this could cause trouble, and a suitable load-shedding mechanism be appropriate.
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.
heh actually looking at the code, this is a bit silly.. I am checking span.isNoop for each callback. Will buff this out and move the conditional in front. I don't think we'd want to sample 10K spans/second, so this should take care of that concern.
Anyway, you highlight something which is that we don't yet have benchmarks on this for normal vs instrumented case.
+public final class CassandraTraceKeys {
it's interesting that you use final class here, as appropriate, yet not
on the other class.
i would not presume that the other classes are designed for being
subclassed (which are in fact broadening the API being published beyond
what you're probably intending it to be.)
This is just a habit for constant files, i wouldn't read too much into
that. If someone were subclassing, they could I guess make a subclass of
TraceKeys.. wasn't thinking about that.
The other class is subclassable mainly as it seems very likely to need it.
I mentioned some notes in the type doc about configuration maybe being
something not awesome with system properties. Another thing is how
subordinate work is recorded.. right now, for simplicity and also to keep
traces from getting too "bottom heavy", I put annotations instead of child
spans. Subclassing would allow someone to override that, and since it is
likely they'll need to override the construction of the type anyway (bc it
is literally new'ed) seemed to fit.
I suspect this code will flex a bit before final, but there were my
thoughts going into it..
|
Tracing in Cassandra is actively maintained, ex there are some notes about
things that work in 3.11. I suspect it will actually be the testing and
focus concerns that make this more sensible as a separate repo beyond just
the several modules reason.
For example, we will likely need a matrix build at some point albeit via
maven invoker or docker. This is easier as a separate repo.
On focus, there is a lot of activity in brave unrelated to cassandra.
Another repo could keep the spam level down a bit.
…On 16 May 2017 3:07 am, "Brian Devins" ***@***.***> wrote:
👍 to new repo if there will be a bunch of churn on that. Not sure what
the cadence is for the cassandra project
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#414 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD61yOot5j9_WvwwFc7paLgVoL93Ljgks5r6KJcgaJpZM4NZGpK>
.
|
ZipkinTraceState state = (ZipkinTraceState) get(); | ||
if (state != null) state.incoming.finish(); | ||
} | ||
|
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.
how come you didn't also override public void doneWithLocalSession(TraceState)
?
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.
possibly an oversight?
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.
Or public TraceState initializeFromMessage(final MessageIn<?> message)
?
Or public Map<String, byte[]> getTraceHeaders()
(by not implementing outbound tracing, you won't be getting the tracing across the nodes within the cluster)
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.
honestly I only implemented barebones to get things off the ground. Notably there's a lot of moving parts just in basics, so I was hoping to get something together that people can contribute to to add more features.
|
||
@Override protected final TraceState newTraceState(InetAddress coordinator, UUID sessionId, | ||
TraceType traceType) { | ||
throw new AssertionError(); |
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 is this an AssertionError?
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.
because this method shouldn't be called because we override what calls it. That said, if the upstream code drifts that could cease to be the case.
I've moved all this code here for future updates. feel free to adjust anything! https://github.com/openzipkin/brave-cassandra |
added openzipkin/brave-cassandra#1 to not lose
this point
|
ok! the brave-cassandra repo is in business. For example, you can grab the snapshot cassandra jar here http://oss.jfrog.org/oss-snapshot-local/io/zipkin/brave/cassandra/brave-instrumentation-cassandra/0.0.1-SNAPSHOT/ Thanks for the review folks, and please direct all future things here, por favor! https://github.com/openzipkin/brave-cassandra |
This contains tracing instrumentation for Cassandra and the DataStax Java Driver.
brave.cassandra.Tracing
extracts trace state from the custom payloadof incoming requests. How long each request takes, each suboperation,
and relevant tags like the session ID are reported to Zipkin.
brave.cassandra.driver.TracingSession
tracks the client-side of cassandra andadds trace context to the custom payload of outgoing requests. If
server integration is in place, cassandra will contribute data to these
RPC spans.