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

In interceptor mode, TracingDriver#acceptsURL should accept URLs without "tracing:" #68

Closed
yisheng-liang opened this issue Feb 21, 2020 · 5 comments · Fixed by #69
Closed

Comments

@yisheng-liang
Copy link
Contributor

Interceptor mode may not work in some cases. For instance, if another wrapper driver calls Driver#acceptsURL for each registered driver in order to find an underlying driver, it won't see TracingDriver unless the JDBC URL has been rewritten to have the jdbc:tracing: prefix.

Simple fix is to change TracingDriver#acceptsURL to be:

  @Override
  public boolean acceptsURL(String url) throws SQLException {
    return url != null && (
        url.startsWith(getUrlPrefix()) || 
        (interceptorMode && url.startsWith("jdbc:"))
    );
  }
@malafeev
Copy link
Contributor

that's not so simple.
acceptsURL(...) is used in TracingDriver.connect(...):
https://github.com/opentracing-contrib/java-jdbc/blob/master/src/main/java/io/opentracing/contrib/jdbc/TracingDriver.java#L153

this if statement also should be modified to explicitly accept urls only with "jdbc:tracing:"

@yisheng-liang
Copy link
Contributor Author

We could modify TracingDriver#connect such that it doesn't try to parse the url if interceptorMode is true. Just need to move around those if branches like this:

if (interceptorMode) {
    withActiveSpanOnly = TracingDriver.withActiveSpanOnly;
    ignoreStatements = TracingDriver.ignoreStatements;
} else if (acceptsURL(url)) {
    withActiveSpanOnly = url.contains(WITH_ACTIVE_SPAN_ONLY);
    ignoreStatements = extractIgnoredStatements(url);
    url = extractRealUrl(url);
} else {
    return null;
}

I think this makes sense. Since in interceptor mode, the driver is supposed to be able to intercept JDBC operations without the need of modifying JDBC URLs, so it should not even try to find traceWithActiveSpanOnly or ignoreForTracing from the URLs.

@malafeev
Copy link
Contributor

@yisheng-liang would you like to submit PR?

@yisheng-liang
Copy link
Contributor Author

Are you going to cut a new release soon? Releases were cut in January quite often but nothing in February.

@malafeev
Copy link
Contributor

malafeev commented Mar 3, 2020

0.2.9 is released

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

Successfully merging a pull request may close this issue.

2 participants