io.opentracing.contrib.jdbc.parser.URLParser Java Examples
The following examples show how to use
io.opentracing.contrib.jdbc.parser.URLParser.
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: JdbcAspect.java From java-spring-cloud with Apache License 2.0 | 5 votes |
/** * Intercepts calls to {@link DataSource#getConnection()} (and related), wrapping the outcome in a * {@link TracingConnection} proxy * * @param pjp the intercepted join point * @return a new {@link TracingConnection} proxy wrapping the result of the joint point * @throws Throwable in case of wrong JDBC URL */ @Around("execution(java.sql.Connection *.getConnection(..)) && target(javax.sql.DataSource)") public Object getConnection(final ProceedingJoinPoint pjp) throws Throwable { Connection conn = (Connection) pjp.proceed(); if (WrapperProxy.isWrapper(conn, TracingConnection.class)) { return conn; } String url = conn.getMetaData().getURL(); ConnectionInfo connectionInfo = URLParser.parse(url); return WrapperProxy.wrap(conn, new TracingConnection(conn, connectionInfo, withActiveSpanOnly, ignoredStatements, GlobalTracer.get())); }
Example #3
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); } }