ActiveSpanLifecycle implements Lifecycle { @Override public Optional<Span> start( final Tracer tracer, String operationName) { return Optional.ofNullable(tracer.activeSpan()) .map(NonFinishingSpan::new); }  @Override Optional<Span> start(
            final Tracer tracer, String operationName);  }
@Test void shouldUseActiveSpan() throws SQLException { final DataSource dataSource = unit.trace(original); try (final Connection connection = dataSource.getConnection(); final Statement statement = connection.createStatement()) { final MockSpan parent = tracer.buildSpan("parent").start(); try (final Scope ignored = tracer.activateSpan(parent)) { statement.execute("SELECT 1"); } finally { parent.finish(); } } final List<MockSpan> spans = tracer.finishedSpans(); final MockSpan span = Iterables.getOnlyElement(spans); assertThat(span.operationName(), is("parent")); 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.hostname", "users")); assertThat(span.tags(), not(hasKey("peer.port"))); assertThat(span.tags(), not(hasKey("span.kind"))); }