Skip to content
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

Set endpoint for remove service #15

Closed
eirslett opened this issue Apr 11, 2014 · 4 comments
Closed

Set endpoint for remove service #15

eirslett opened this issue Apr 11, 2014 · 4 comments

Comments

@eirslett
Copy link
Contributor

I want to implement a JDBC pool monitor that intercepts SQL requests and traces them. However, they are logged as coming from my own service (naturally) but I want them to appear in Zipkin as "Postgresql" , just like Twitter has overriden traces and called them "Memcached" in this example:

http://twitter.github.io/zipkin/images/web-screenshot.png

How can I override the endpoint configuration from the client side?

@kristofa
Copy link
Member

Hi,

Sorry for not picking this up quickly. I'll look into it and come back to you later this week.

Kristof

@kristofa
Copy link
Member

Hi,

Currently there is no way to provide a custom endpoint in the ClientTracer api when creating a new span. ClientTracerImpl uses the endpoint provided by ServerAndClientSpanState which is submitted through the constructor. However the api could be extended to support what you need.

In the RestEasy integration the endpoint is set once when the first request is intercepted.

Off course when you create your 'Postgresql' span you can do: clientTracer.startNewSpan("Postgresql") so you still will see that it is a request to postgres. But I guess you have figured that out.

I'm interested in your JDBC pool monitor :) can you explain how it works and in which frameworks it integrates?

@eirslett
Copy link
Contributor Author

You're right - the API needs some extension, so you can override the endpoint for a given span.
clientTracer.overrideEndpointForThisSpan("db.mysite.com", 5432, "Postgresql");
(just a suggestion)

What you need is a hook to execute before a database command (with the given SQL query) and a hook just after it is executed. The vanilla JDBC API isn't exactly very extension-friendly, but there are some tools/libraries out there:

You can use log4jdbc to wrap your DataSource. You provide a Brave tracer as a logger to log4jdbc. Simple as that!

Or eventually (as we have done, since we run stuff on Tomcat) extend JdbcInterceptor from Tomcat's jdbc pool.

Our implementation is only about 30 lines of code, but it's not open-sourceable, since it depends on some other internal utilities.

@kristofa
Copy link
Member

Fix merged. Close issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants