Better span names for jdbc
MODIFY
instrumentation/hibernate/hibernate-3.3/src/test/groovy/CriteriaTest.groovy
instrumentation/hibernate/hibernate-3.3/src/test/groovy/CriteriaTest.groovy
@@ -61,11 +61,11 @@ class CriteriaTest extends AbstractHibernateTest {
}
}
span(2) {
+ operationName ~/^select /
spanKind CLIENT
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^select /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"

MODIFY
instrumentation/hibernate/hibernate-3.3/src/test/groovy/QueryTest.groovy
instrumentation/hibernate/hibernate-3.3/src/test/groovy/QueryTest.groovy
@@ -72,7 +72,6 @@ class QueryTest extends AbstractHibernateTest {
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" String
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -119,11 +118,11 @@ class QueryTest extends AbstractHibernateTest {
}
}
span(2) {
+ operationName ~/^select /
spanKind CLIENT
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^select /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -199,11 +198,11 @@ class QueryTest extends AbstractHibernateTest {
}
}
span(2) {
+ operationName ~/^select /
spanKind CLIENT
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^select /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"

MODIFY
instrumentation/hibernate/hibernate-3.3/src/test/groovy/SessionTest.groovy
instrumentation/hibernate/hibernate-3.3/src/test/groovy/SessionTest.groovy
@@ -83,7 +83,6 @@ class SessionTest extends AbstractHibernateTest {
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" String
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -175,7 +174,6 @@ class SessionTest extends AbstractHibernateTest {
childOf span(2)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" String
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -247,11 +245,11 @@ class SessionTest extends AbstractHibernateTest {
}
}
span(2) {
+ operationName ~/^select /
spanKind CLIENT
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^select /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -276,7 +274,6 @@ class SessionTest extends AbstractHibernateTest {
childOf span(3)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" String
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -415,7 +412,6 @@ class SessionTest extends AbstractHibernateTest {
childOf span(2)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" String
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -499,7 +495,6 @@ class SessionTest extends AbstractHibernateTest {
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" String
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -602,11 +597,11 @@ class SessionTest extends AbstractHibernateTest {
}
}
span(5) {
+ operationName ~/^insert /
spanKind CLIENT
childOf span(4)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^insert /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -617,11 +612,11 @@ class SessionTest extends AbstractHibernateTest {
}
}
span(6) {
+ operationName ~/^delete /
spanKind CLIENT
childOf span(4)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^delete /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"

MODIFY
instrumentation/hibernate/hibernate-4.0/src/test/groovy/CriteriaTest.groovy
instrumentation/hibernate/hibernate-4.0/src/test/groovy/CriteriaTest.groovy
@@ -61,11 +61,11 @@ class CriteriaTest extends AbstractHibernateTest {
}
}
span(2) {
+ operationName ~/^select /
spanKind CLIENT
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^select /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"

MODIFY
instrumentation/hibernate/hibernate-4.0/src/test/groovy/QueryTest.groovy
instrumentation/hibernate/hibernate-4.0/src/test/groovy/QueryTest.groovy
@@ -72,7 +72,6 @@ class QueryTest extends AbstractHibernateTest {
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" String
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -119,11 +118,11 @@ class QueryTest extends AbstractHibernateTest {
}
}
span(2) {
+ operationName ~/^select /
spanKind CLIENT
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^select /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -199,11 +198,11 @@ class QueryTest extends AbstractHibernateTest {
}
}
span(2) {
+ operationName ~/^select /
spanKind CLIENT
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^select /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"

MODIFY
instrumentation/hibernate/hibernate-4.0/src/test/groovy/SessionTest.groovy
instrumentation/hibernate/hibernate-4.0/src/test/groovy/SessionTest.groovy
@@ -83,7 +83,6 @@ class SessionTest extends AbstractHibernateTest {
spanKind CLIENT
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" String
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -175,11 +174,11 @@ class SessionTest extends AbstractHibernateTest {
}
}
span(2) {
+ operationName ~/^select /
spanKind CLIENT
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^select /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -204,7 +203,6 @@ class SessionTest extends AbstractHibernateTest {
childOf span(3)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" String
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -343,7 +341,6 @@ class SessionTest extends AbstractHibernateTest {
childOf span(2)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" String
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -427,7 +424,6 @@ class SessionTest extends AbstractHibernateTest {
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" String
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -530,11 +526,11 @@ class SessionTest extends AbstractHibernateTest {
}
}
span(5) {
+ operationName ~/^insert /
spanKind CLIENT
childOf span(4)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^insert /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -545,11 +541,11 @@ class SessionTest extends AbstractHibernateTest {
}
}
span(6) {
+ operationName ~/^delete /
spanKind CLIENT
childOf span(4)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^delete /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"
@@ -581,11 +577,11 @@ class SessionTest extends AbstractHibernateTest {
}
}
span(9) {
+ operationName ~/^insert /
spanKind CLIENT
childOf span(8)
tags {
"$MoreTags.SERVICE_NAME" "h2"
- "$MoreTags.RESOURCE_NAME" ~/^insert /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "h2"

MODIFY
instrumentation/hibernate/hibernate-4.3/src/test/groovy/ProcedureCallTest.groovy
instrumentation/hibernate/hibernate-4.3/src/test/groovy/ProcedureCallTest.groovy
@@ -105,11 +105,11 @@ class ProcedureCallTest extends AgentTestRunner {
}
}
span(2) {
+ operationName "{call TEST_PROC()}"
spanKind CLIENT
childOf span(1)
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" "{call TEST_PROC()}"
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"

MODIFY
instrumentation/hibernate/hibernate-4.3/src/test/groovy/SpringJpaTest.groovy
instrumentation/hibernate/hibernate-4.3/src/test/groovy/SpringJpaTest.groovy
@@ -46,10 +46,10 @@ class SpringJpaTest extends AgentTestRunner {
assertTraces(1) {
trace(0, 1) {
span(0) {
+ operationName "select customer0_.id as id1_0_, customer0_.firstName as firstNam2_0_, customer0_.lastName as lastName3_0_ from Customer customer0_"
spanKind CLIENT
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" "select customer0_.id as id1_0_, customer0_.firstName as firstNam2_0_, customer0_.lastName as lastName3_0_ from Customer customer0_"
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -75,10 +75,10 @@ class SpringJpaTest extends AgentTestRunner {
if (extraTrace) {
trace(0, 1) {
span(0) {
+ operationName "call next value for hibernate_sequence"
spanKind CLIENT
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" "call next value for hibernate_sequence"
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -92,10 +92,10 @@ class SpringJpaTest extends AgentTestRunner {
}
trace(extraTrace ? 1 : 0, 1) {
span(0) {
+ operationName ~/insert into Customer \(.*\) values \(.*, \?, \?\)/
spanKind CLIENT
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" ~/insert into Customer \(.*\) values \(.*, \?, \?\)/
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -118,10 +118,10 @@ class SpringJpaTest extends AgentTestRunner {
assertTraces(2) {
trace(0, 1) {
span(0) {
+ operationName "select customer0_.id as id1_0_0_, customer0_.firstName as firstNam2_0_0_, customer0_.lastName as lastName3_0_0_ from Customer customer0_ where customer0_.id=?"
spanKind CLIENT
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" "select customer0_.id as id1_0_0_, customer0_.firstName as firstNam2_0_0_, customer0_.lastName as lastName3_0_0_ from Customer customer0_ where customer0_.id=?"
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -134,10 +134,10 @@ class SpringJpaTest extends AgentTestRunner {
}
trace(1, 1) {
span(0) {
+ operationName "update Customer set firstName=?, lastName=? where id=?"
spanKind CLIENT
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" "update Customer set firstName=?, lastName=? where id=?"
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -160,10 +160,10 @@ class SpringJpaTest extends AgentTestRunner {
assertTraces(1) {
trace(0, 1) {
span(0) {
+ operationName "select customer0_.id as id1_0_, customer0_.firstName as firstNam2_0_, customer0_.lastName as lastName3_0_ from Customer customer0_ where customer0_.lastName=?"
spanKind CLIENT
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" "select customer0_.id as id1_0_, customer0_.firstName as firstNam2_0_, customer0_.lastName as lastName3_0_ from Customer customer0_ where customer0_.lastName=?"
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -184,10 +184,10 @@ class SpringJpaTest extends AgentTestRunner {
assertTraces(2) {
trace(0, 1) {
span(0) {
+ operationName "select customer0_.id as id1_0_0_, customer0_.firstName as firstNam2_0_0_, customer0_.lastName as lastName3_0_0_ from Customer customer0_ where customer0_.id=?"
spanKind CLIENT
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" "select customer0_.id as id1_0_0_, customer0_.firstName as firstNam2_0_0_, customer0_.lastName as lastName3_0_0_ from Customer customer0_ where customer0_.id=?"
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -200,10 +200,10 @@ class SpringJpaTest extends AgentTestRunner {
}
trace(1, 1) {
span(0) {
+ operationName "delete from Customer where id=?"
spanKind CLIENT
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" "delete from Customer where id=?"
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"

MODIFY
instrumentation/java-concurrent/src/slickTest/groovy/SlickTest.groovy
instrumentation/java-concurrent/src/slickTest/groovy/SlickTest.groovy
@@ -43,13 +43,12 @@ class SlickTest extends AgentTestRunner {
}
}
span(1) {
- operationName "database.query"
+ operationName SlickUtils.TestQuery()
spanKind CLIENT
childOf span(0)
errored false
tags {
"$MoreTags.SERVICE_NAME" SlickUtils.Driver()
- "$MoreTags.RESOURCE_NAME" SlickUtils.TestQuery()
"$MoreTags.SPAN_TYPE" SpanTypes.SQL
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" SlickUtils.Driver()

MODIFY
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/DataSourceInstrumentation.java
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/DataSourceInstrumentation.java
@@ -23,7 +23,6 @@ import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.named;
import com.google.auto.service.AutoService;
-import io.opentelemetry.auto.instrumentation.api.MoreTags;
import io.opentelemetry.auto.instrumentation.api.SpanWithScope;
import io.opentelemetry.auto.tooling.Instrumenter;
import io.opentelemetry.trace.Span;
@@ -71,11 +70,13 @@ public final class DataSourceInstrumentation extends Instrumenter.Default {
return null;
}
- final Span span = TRACER.spanBuilder("database.connection").setSpanKind(CLIENT).startSpan();
+ final Span span =
+ TRACER
+ .spanBuilder(ds.getClass().getSimpleName() + ".getConnection")
+ .setSpanKind(CLIENT)
+ .startSpan();
DECORATE.afterStart(span);
- span.setAttribute(MoreTags.RESOURCE_NAME, ds.getClass().getSimpleName() + ".getConnection");
-
return new SpanWithScope(span, TRACER.withSpan(span));
}

MODIFY
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/JDBCDecorator.java
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/JDBCDecorator.java
@@ -109,18 +109,23 @@ public class JDBCDecorator extends DatabaseClientDecorator<DBInfo> {
return super.onConnection(span, dbInfo);
}
+ public String spanNameOnStatement(final String statement) {
+ return statement == null ? DB_QUERY : statement;
+ }
+
+ public String spanNameOnPreparedStatement(final PreparedStatement statement) {
+ final String sql = JDBCMaps.preparedStatements.get(statement);
+ return sql == null ? DB_QUERY : sql;
+ }
+
@Override
public Span onStatement(final Span span, final String statement) {
- final String resourceName = statement == null ? DB_QUERY : statement;
- span.setAttribute(MoreTags.RESOURCE_NAME, resourceName);
span.setAttribute(Tags.COMPONENT, "java-jdbc-statement");
return super.onStatement(span, statement);
}
public Span onPreparedStatement(final Span span, final PreparedStatement statement) {
final String sql = JDBCMaps.preparedStatements.get(statement);
- final String resourceName = sql == null ? DB_QUERY : sql;
- span.setAttribute(MoreTags.RESOURCE_NAME, resourceName);
span.setAttribute(Tags.COMPONENT, "java-jdbc-prepared_statement");
return super.onStatement(span, sql);
}

MODIFY
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/PreparedStatementInstrumentation.java
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/PreparedStatementInstrumentation.java
@@ -79,7 +79,11 @@ public final class PreparedStatementInstrumentation extends Instrumenter.Default
return null;
}
- final Span span = TRACER.spanBuilder("database.query").setSpanKind(CLIENT).startSpan();
+ final Span span =
+ TRACER
+ .spanBuilder(DECORATE.spanNameOnPreparedStatement(statement))
+ .setSpanKind(CLIENT)
+ .startSpan();
DECORATE.afterStart(span);
DECORATE.onConnection(span, connection);
DECORATE.onPreparedStatement(span, statement);

MODIFY
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/StatementInstrumentation.java
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/StatementInstrumentation.java
@@ -80,7 +80,8 @@ public final class StatementInstrumentation extends Instrumenter.Default {
return null;
}
- final Span span = TRACER.spanBuilder("database.query").setSpanKind(CLIENT).startSpan();
+ final Span span =
+ TRACER.spanBuilder(DECORATE.spanNameOnStatement(sql)).setSpanKind(CLIENT).startSpan();
DECORATE.afterStart(span);
DECORATE.onConnection(span, connection);
DECORATE.onStatement(span, sql);

MODIFY
instrumentation/jdbc/src/test/groovy/JDBCInstrumentationTest.groovy
instrumentation/jdbc/src/test/groovy/JDBCInstrumentationTest.groovy
@@ -193,13 +193,12 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
- operationName "database.query"
+ operationName query
spanKind CLIENT
childOf span(0)
errored false
tags {
"$MoreTags.SERVICE_NAME" renameService ? dbName.toLowerCase() : driver
- "$MoreTags.RESOURCE_NAME" query
"$MoreTags.SPAN_TYPE" SpanTypes.SQL
"$Tags.COMPONENT" "java-jdbc-statement"
"$Tags.DB_TYPE" driver
@@ -253,13 +252,12 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
- operationName "database.query"
+ operationName query
spanKind CLIENT
childOf span(0)
errored false
tags {
"$MoreTags.SERVICE_NAME" driver
- "$MoreTags.RESOURCE_NAME" query
"$MoreTags.SPAN_TYPE" SpanTypes.SQL
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" driver
@@ -305,13 +303,12 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
- operationName "database.query"
+ operationName query
spanKind CLIENT
childOf span(0)
errored false
tags {
"$MoreTags.SERVICE_NAME" driver
- "$MoreTags.RESOURCE_NAME" query
"$MoreTags.SPAN_TYPE" SpanTypes.SQL
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" driver
@@ -357,13 +354,12 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
- operationName "database.query"
+ operationName query
spanKind CLIENT
childOf span(0)
errored false
tags {
"$MoreTags.SERVICE_NAME" driver
- "$MoreTags.RESOURCE_NAME" query
"$MoreTags.SPAN_TYPE" SpanTypes.SQL
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" driver
@@ -409,13 +405,12 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
- operationName "database.query"
+ operationName query
spanKind CLIENT
childOf span(0)
errored false
tags {
"$MoreTags.SERVICE_NAME" driver
- "$MoreTags.RESOURCE_NAME" query
"$MoreTags.SPAN_TYPE" SpanTypes.SQL
"$Tags.COMPONENT" "java-jdbc-statement"
"$Tags.DB_TYPE" driver
@@ -464,13 +459,12 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
- operationName "database.query"
+ operationName query
spanKind CLIENT
childOf span(0)
errored false
tags {
"$MoreTags.SERVICE_NAME" driver
- "$MoreTags.RESOURCE_NAME" query
"$MoreTags.SPAN_TYPE" SpanTypes.SQL
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" driver
@@ -531,13 +525,12 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
- operationName "database.query"
+ operationName query
spanKind CLIENT
childOf span(0)
errored false
tags {
"$MoreTags.SERVICE_NAME" driver
- "$MoreTags.RESOURCE_NAME" query
"$MoreTags.SPAN_TYPE" SpanTypes.SQL
if (prepareStatement) {
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
@@ -595,19 +588,17 @@ class JDBCInstrumentationTest extends AgentTestRunner {
basicSpan(it, 0, "parent")
span(1) {
- operationName "database.connection"
+ operationName "${datasource.class.simpleName}.getConnection"
childOf span(0)
tags {
- "$MoreTags.RESOURCE_NAME" "${datasource.class.simpleName}.getConnection"
"$Tags.COMPONENT" "java-jdbc-connection"
}
}
if (recursive) {
span(2) {
- operationName "database.connection"
+ operationName "${datasource.class.simpleName}.getConnection"
childOf span(1)
tags {
- "$MoreTags.RESOURCE_NAME" "${datasource.class.simpleName}.getConnection"
"$Tags.COMPONENT" "java-jdbc-connection"
}
}
@@ -646,13 +637,12 @@ class JDBCInstrumentationTest extends AgentTestRunner {
trace(0, 2) {
basicSpan(it, 0, "parent")
span(1) {
- operationName "database.query"
+ operationName query
spanKind CLIENT
childOf span(0)
errored false
tags {
"$MoreTags.SERVICE_NAME" database
- "$MoreTags.RESOURCE_NAME" query
"$MoreTags.SPAN_TYPE" SpanTypes.SQL
"$Tags.COMPONENT" "java-jdbc-statement"
"$Tags.DB_TYPE" database
@@ -711,12 +701,11 @@ class JDBCInstrumentationTest extends AgentTestRunner {
assertTraces(5) {
trace(0, 1) {
span(0) {
- operationName "database.query"
+ operationName query
spanKind CLIENT
errored false
tags {
"$MoreTags.SERVICE_NAME" dbType
- "$MoreTags.RESOURCE_NAME" query
"$MoreTags.SPAN_TYPE" SpanTypes.SQL
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" dbType
@@ -730,12 +719,11 @@ class JDBCInstrumentationTest extends AgentTestRunner {
for (int i = 1; i < numQueries; ++i) {
trace(i, 1) {
span(0) {
- operationName "database.query"
+ operationName query
spanKind CLIENT
errored false
tags {
"$MoreTags.SERVICE_NAME" dbType
- "$MoreTags.RESOURCE_NAME" query
"$MoreTags.SPAN_TYPE" SpanTypes.SQL
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" dbType

MODIFY
instrumentation/spring-data-1.8/src/test/groovy/SpringJpaTest.groovy
instrumentation/spring-data-1.8/src/test/groovy/SpringJpaTest.groovy
@@ -79,11 +79,11 @@ class SpringJpaTest extends AgentTestRunner {
}
}
span(1) { // select
+ operationName ~/^select /
spanKind CLIENT
childOf span(0)
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" ~/^select /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -115,11 +115,11 @@ class SpringJpaTest extends AgentTestRunner {
}
}
span(1) { // insert
+ operationName ~/^insert /
spanKind CLIENT
childOf span(0)
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" ~/^insert /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -151,11 +151,11 @@ class SpringJpaTest extends AgentTestRunner {
}
}
span(1) { // select
+ operationName ~/^select /
spanKind CLIENT
childOf span(0)
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" ~/^select /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -166,11 +166,11 @@ class SpringJpaTest extends AgentTestRunner {
}
}
span(2) { // update
+ operationName ~/^update /
spanKind CLIENT
childOf span(0)
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" ~/^update /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -200,11 +200,11 @@ class SpringJpaTest extends AgentTestRunner {
}
}
span(1) { // select
+ operationName ~/^select /
spanKind CLIENT
childOf span(0)
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" ~/^select /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -234,11 +234,11 @@ class SpringJpaTest extends AgentTestRunner {
}
}
span(1) { // select
+ operationName ~/^select /
spanKind CLIENT
childOf span(0)
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" ~/^select /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"
@@ -249,11 +249,11 @@ class SpringJpaTest extends AgentTestRunner {
}
}
span(2) { // delete
+ operationName ~/^delete /
spanKind CLIENT
childOf span(0)
tags {
"$MoreTags.SERVICE_NAME" "hsqldb"
- "$MoreTags.RESOURCE_NAME" ~/^delete /
"$MoreTags.SPAN_TYPE" "sql"
"$Tags.COMPONENT" "java-jdbc-prepared_statement"
"$Tags.DB_TYPE" "hsqldb"

MODIFY
testing/src/main/groovy/io/opentelemetry/auto/test/asserts/SpanAssert.groovy
testing/src/main/groovy/io/opentelemetry/auto/test/asserts/SpanAssert.groovy
@@ -21,6 +21,8 @@ import io.opentelemetry.sdk.trace.SpanData
import io.opentelemetry.trace.Span
import io.opentelemetry.trace.Status
+import java.util.regex.Pattern
+
import static TagsAssert.assertTags
import static io.opentelemetry.auto.test.asserts.EventAssert.assertEvent
@@ -71,6 +73,11 @@ class SpanAssert {
checked.name = true
}
+ def operationName(Pattern pattern) {
+ assert span.name =~ pattern
+ checked.name = true
+ }
+
def operationName(Closure spec) {
assert ((Closure) spec).call(span.name)
checked.name = true

Better span names for jdbc (#238)