@Test void shouldTraceBatch() throws SQLException { try (final Connection connection = original.getConnection(); final Statement statement = connection.createStatement()) { statement.execute("CREATE TABLE users(id BIGINT, name TEXT)"); } final DataSource dataSource = unit.trace(original); try (final Connection connection = dataSource.getConnection(); final Statement statement = connection.createStatement()) { statement.addBatch("INSERT INTO users(id, name) VALUES (1, 'Alice')"); statement.addBatch("INSERT INTO users(id, name) VALUES (2, 'Bob')"); statement.executeBatch(); } final List<MockSpan> spans = tracer.finishedSpans(); final MockSpan span = getOnlyElement(spans); assertThat(span.operationName(), is("executeBatch")); assertThat(span.tags(), hasEntry("db.statement", "INSERT INTO users(id, name) VALUES (1, 'Alice')\nINSERT INTO users(id, name) VALUES (2, 'Bob')")); }
@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);  }