Java Code Examples for io.opentracing.contrib.jdbc.parser.URLParser#parser()
The following examples show how to use
io.opentracing.contrib.jdbc.parser.URLParser#parser() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TracingDriver.java From java-jdbc with Apache License 2.0 | 5 votes |
@Override public Connection connect(String url, Properties info) throws SQLException { // if there is no url, we have problems if (url == null) { throw new SQLException("url is required"); } final Set<String> ignoreStatements; final boolean withActiveSpanOnly; if (interceptorMode) { withActiveSpanOnly = TracingDriver.withActiveSpanOnly; ignoreStatements = TracingDriver.ignoreStatements; } else if (acceptsURL(url)) { withActiveSpanOnly = url.contains(WITH_ACTIVE_SPAN_ONLY); ignoreStatements = extractIgnoredStatements(url); } else { return null; } url = extractRealUrl(url); // find the real driver for the URL final Driver wrappedDriver = findDriver(url); final Tracer currentTracer = getTracer(); final ConnectionInfo connectionInfo = URLParser.parser(url); final Span span = buildSpan("AcquireConnection", "", connectionInfo, withActiveSpanOnly, Collections.<String>emptySet(), currentTracer); final Connection connection; try (Scope ignored = currentTracer.activateSpan(span)) { connection = wrappedDriver.connect(url, info); } finally { span.finish(); } return WrapperProxy .wrap(connection, new TracingConnection(connection, connectionInfo, withActiveSpanOnly, ignoreStatements, currentTracer)); }
Example 2
Source File: TracingDataSource.java From che with Eclipse Public License 2.0 | 5 votes |
public TracingDataSource(DataSource delegate) { this.delegate = delegate; try (Connection connection = delegate.getConnection()) { connectionInfo = URLParser.parser(connection.getMetaData().getURL()); LOG.debug( "URL {} connectionInfo {}", connection.getMetaData().getURL(), connectionInfo.getPeerService()); } catch (SQLException e) { throw new RuntimeException(e); } }