jdbc-commons:reduce unnecessary call ThreadLocal with ContextManager#stopSpan(span) (#3244)
This commit is contained in:
parent
8611124b33
commit
a328a3bafc
|
|
@ -36,8 +36,8 @@ public class CallableStatementTracing {
|
|||
public static <R> R execute(java.sql.CallableStatement realStatement,
|
||||
ConnectionInfo connectInfo, String method, String sql, Executable<R> exec)
|
||||
throws SQLException {
|
||||
AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBI/CallableStatement/" + method, connectInfo.getDatabasePeer());
|
||||
try {
|
||||
AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBI/CallableStatement/" + method, connectInfo.getDatabasePeer());
|
||||
Tags.DB_TYPE.set(span, "sql");
|
||||
SpanLayer.asDB(span);
|
||||
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
|
||||
|
|
@ -45,12 +45,11 @@ public class CallableStatementTracing {
|
|||
span.setComponent(connectInfo.getComponent());
|
||||
return exec.exe(realStatement, sql);
|
||||
} catch (SQLException e) {
|
||||
AbstractSpan span = ContextManager.activeSpan();
|
||||
span.errorOccurred();
|
||||
span.log(e);
|
||||
throw e;
|
||||
} finally {
|
||||
ContextManager.stopSpan();
|
||||
ContextManager.stopSpan(span);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ public class PreparedStatementTracing {
|
|||
public static <R> R execute(java.sql.PreparedStatement realStatement,
|
||||
ConnectionInfo connectInfo, String method, String sql, Executable<R> exec)
|
||||
throws SQLException {
|
||||
final AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBI/PreparedStatement/" + method, connectInfo.getDatabasePeer());
|
||||
try {
|
||||
AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBI/PreparedStatement/" + method, connectInfo.getDatabasePeer());
|
||||
Tags.DB_TYPE.set(span, "sql");
|
||||
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
|
||||
Tags.DB_STATEMENT.set(span, sql);
|
||||
|
|
@ -46,12 +46,11 @@ public class PreparedStatementTracing {
|
|||
SpanLayer.asDB(span);
|
||||
return exec.exe(realStatement, sql);
|
||||
} catch (SQLException e) {
|
||||
AbstractSpan span = ContextManager.activeSpan();
|
||||
span.errorOccurred();
|
||||
span.log(e);
|
||||
throw e;
|
||||
} finally {
|
||||
ContextManager.stopSpan();
|
||||
ContextManager.stopSpan(span);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ public class ConnectionTracing {
|
|||
public static <R> R execute(java.sql.Connection realConnection,
|
||||
ConnectionInfo connectInfo, String method, String sql, Executable<R> exec)
|
||||
throws SQLException {
|
||||
AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBI/Connection/" + method, connectInfo.getDatabasePeer());
|
||||
try {
|
||||
AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBI/Connection/" + method, connectInfo.getDatabasePeer());
|
||||
Tags.DB_TYPE.set(span, "sql");
|
||||
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
|
||||
Tags.DB_STATEMENT.set(span, sql);
|
||||
|
|
@ -40,12 +40,11 @@ public class ConnectionTracing {
|
|||
SpanLayer.asDB(span);
|
||||
return exec.exe(realConnection, sql);
|
||||
} catch (SQLException e) {
|
||||
AbstractSpan span = ContextManager.activeSpan();
|
||||
span.errorOccurred();
|
||||
span.log(e);
|
||||
throw e;
|
||||
} finally {
|
||||
ContextManager.stopSpan();
|
||||
ContextManager.stopSpan(span);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue