@Test void shouldTraceStatement() throws SQLException { final DataSource dataSource = unit.trace(original); try (final Connection connection = dataSource.getConnection(); final Statement statement = connection.createStatement()) { statement.execute("SELECT 1"); } final List<MockSpan> spans = tracer.finishedSpans(); final MockSpan span = getOnlyElement(spans); assertThat(span.operationName(), is("execute")); assertThat(span.tags(), hasEntry("component", "JDBC")); assertThat(span.tags(), hasEntry("db.instance", "USERS")); assertThat(span.tags(), hasEntry("db.statement", "SELECT 1")); assertThat(span.tags(), hasEntry("db.type", "sql")); assertThat(span.tags(), hasEntry("db.user", "")); assertThat(span.tags(), hasEntry("peer.address", "h2:mem:users")); assertThat(span.tags(), hasEntry("peer.hostname", "users")); assertThat(span.tags(), not(hasKey("peer.port"))); assertThat(span.tags(), hasEntry("span.kind", "client")); assertThat(span.tags(), hasEntry("flow_id", "REcCvlqMSReeo7adheiYFA")); assertThat(span.tags(), not(hasKey("error"))); }
@CheckReturnValue public DataSource trace(final DataSource dataSource) { return ProxyDataSourceBuilder.create(dataSource) .listener(new TracingQueryExecutionListener( tracer, operationName, lifecycle, activation, decorator)) .build(); }
DataSourceTracer { @CheckReturnValue public DataSource trace(final DataSource dataSource) { return ProxyDataSourceBuilder.create(dataSource) .listener(new TracingQueryExecutionListener( tracer, operationName, lifecycle, activation, decorator)) .build(); } }
DataSourceTracer { @CheckReturnValue public DataSource trace(final DataSource dataSource) { return ProxyDataSourceBuilder.create(dataSource) .listener(new TracingQueryExecutionListener( tracer, operationName, lifecycle, activation, decorator)) .build(); } DataSourceTracer(final Tracer tracer); }
DataSourceTracer { @CheckReturnValue public DataSource trace(final DataSource dataSource) { return ProxyDataSourceBuilder.create(dataSource) .listener(new TracingQueryExecutionListener( tracer, operationName, lifecycle, activation, decorator)) .build(); } DataSourceTracer(final Tracer tracer); @CheckReturnValue DataSourceTracer withOperationName(
            final OperationName operationName); @CheckReturnValue DataSourceTracer withLifecycle(final Lifecycle lifecycle); @CheckReturnValue DataSourceTracer withActivation(final Activation activation); @CheckReturnValue DataSourceTracer withAdditionalSpanDecorators(
            final SpanDecorator first, final SpanDecorator... decorators); @CheckReturnValue DataSourceTracer withSpanDecorators(
            final SpanDecorator decorator, final SpanDecorator... decorators); @CheckReturnValue DataSource trace(final DataSource dataSource); }
DataSourceTracer { @CheckReturnValue public DataSource trace(final DataSource dataSource) { return ProxyDataSourceBuilder.create(dataSource) .listener(new TracingQueryExecutionListener( tracer, operationName, lifecycle, activation, decorator)) .build(); } DataSourceTracer(final Tracer tracer); @CheckReturnValue DataSourceTracer withOperationName(
            final OperationName operationName); @CheckReturnValue DataSourceTracer withLifecycle(final Lifecycle lifecycle); @CheckReturnValue DataSourceTracer withActivation(final Activation activation); @CheckReturnValue DataSourceTracer withAdditionalSpanDecorators(
            final SpanDecorator first, final SpanDecorator... decorators); @CheckReturnValue DataSourceTracer withSpanDecorators(
            final SpanDecorator decorator, final SpanDecorator... decorators); @CheckReturnValue DataSource trace(final DataSource dataSource);  }