mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add stat readStringLength
This commit is contained in:
@@ -573,6 +573,7 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
sqlStat.addFetchRowCount(fetchRowCount);
|
||||
long stmtExecuteNano = resultSet.getStatementProxy().getLastExecuteTimeNano();
|
||||
sqlStat.addResultSetHoldTimeNano(stmtExecuteNano, nanos);
|
||||
sqlStat.addStringReadLength(resultSet.getReadStringLength());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,10 +762,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
|
||||
if (obj instanceof Clob) {
|
||||
clobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (ClobProxy) obj);
|
||||
}
|
||||
|
||||
if (obj instanceof Blob) {
|
||||
} else if (obj instanceof Blob) {
|
||||
blobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (Blob) obj);
|
||||
} else if (obj instanceof String) {
|
||||
result.addReadStringLength(((String) obj).length());
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -777,10 +778,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
|
||||
if (obj instanceof Clob) {
|
||||
clobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (ClobProxy) obj);
|
||||
}
|
||||
|
||||
if (obj instanceof Blob) {
|
||||
} else if (obj instanceof Blob) {
|
||||
blobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (Blob) obj);
|
||||
} else if (obj instanceof String) {
|
||||
result.addReadStringLength(((String) obj).length());
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -792,10 +793,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
|
||||
if (obj instanceof Clob) {
|
||||
clobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (ClobProxy) obj);
|
||||
}
|
||||
|
||||
if (obj instanceof Blob) {
|
||||
} else if (obj instanceof Blob) {
|
||||
blobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (Blob) obj);
|
||||
} else if (obj instanceof String) {
|
||||
result.addReadStringLength(((String) obj).length());
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -808,10 +809,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
|
||||
if (obj instanceof Clob) {
|
||||
clobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (ClobProxy) obj);
|
||||
}
|
||||
|
||||
if (obj instanceof Blob) {
|
||||
} else if (obj instanceof Blob) {
|
||||
blobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (Blob) obj);
|
||||
} else if (obj instanceof String) {
|
||||
result.addReadStringLength(((String) obj).length());
|
||||
}
|
||||
|
||||
return obj;
|
||||
@@ -915,4 +916,26 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
|
||||
StatFilterContext.getInstance().clob_open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resultSet_getString(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
|
||||
String value = chain.resultSet_getString(result, columnIndex);
|
||||
|
||||
if (value != null) {
|
||||
result.addReadStringLength(value.length());
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resultSet_getString(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
|
||||
String value = chain.resultSet_getString(result, columnLabel);
|
||||
|
||||
if (value != null) {
|
||||
result.addReadStringLength(value.length());
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,8 @@ public interface ResultSetProxy extends ResultSet, WrapperProxy {
|
||||
void setConstructNano();
|
||||
|
||||
int getCloseCount();
|
||||
|
||||
void addReadStringLength(int length);
|
||||
|
||||
long getReadStringLength();
|
||||
}
|
||||
|
||||
@@ -51,11 +51,13 @@ public class ResultSetProxyImpl extends WrapperProxyImpl implements ResultSetPro
|
||||
private final StatementProxy statement;
|
||||
private final String sql;
|
||||
|
||||
protected int cursorIndex = 0;
|
||||
protected int fetchRowCount = 0;
|
||||
protected int cursorIndex = 0;
|
||||
protected int fetchRowCount = 0;
|
||||
protected long constructNano;
|
||||
protected final JdbcSqlStat sqlStat;
|
||||
private int closeCount = 0;
|
||||
private int closeCount = 0;
|
||||
|
||||
private long readStringLength = 0;
|
||||
|
||||
public ResultSetProxyImpl(StatementProxy statement, ResultSet resultSet, long id, String sql){
|
||||
super(resultSet, id);
|
||||
@@ -1078,4 +1080,14 @@ public class ResultSetProxyImpl extends WrapperProxyImpl implements ResultSetPro
|
||||
return closeCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addReadStringLength(int length) {
|
||||
this.readStringLength += length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getReadStringLength() {
|
||||
return readStringLength;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
|
||||
private final AtomicLong clobOpenCount = new AtomicLong();
|
||||
private final AtomicLong blobOpenCount = new AtomicLong();
|
||||
private final AtomicLong stringReadLength = new AtomicLong();
|
||||
|
||||
private final Histogram histogram = new Histogram(new long[] { //
|
||||
//
|
||||
@@ -226,6 +227,7 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
|
||||
blobOpenCount.set(0);
|
||||
clobOpenCount.set(0);
|
||||
stringReadLength.set(0);
|
||||
}
|
||||
|
||||
public long getConcurrentMax() {
|
||||
@@ -274,14 +276,22 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
public void incrementClobOpenCount() {
|
||||
clobOpenCount.incrementAndGet();
|
||||
}
|
||||
|
||||
|
||||
public long getBlobOpenCount() {
|
||||
return blobOpenCount.get();
|
||||
}
|
||||
|
||||
|
||||
public void incrementBlobOpenCount() {
|
||||
blobOpenCount.incrementAndGet();
|
||||
}
|
||||
|
||||
public long getStringReadLength() {
|
||||
return stringReadLength.get();
|
||||
}
|
||||
|
||||
public void addStringReadLength(long length) {
|
||||
this.stringReadLength.addAndGet(length);
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
@@ -505,9 +515,10 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
SimpleType.LONG, //
|
||||
SimpleType.LONG, //
|
||||
SimpleType.LONG, //
|
||||
|
||||
|
||||
// 35 -
|
||||
SimpleType.LONG, //
|
||||
SimpleType.LONG, //
|
||||
|
||||
};
|
||||
|
||||
@@ -560,9 +571,10 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
"EffectedRowCountMax", //
|
||||
"FetchRowCountMax", //
|
||||
"ClobOpenCount",
|
||||
|
||||
|
||||
// 35 -
|
||||
"BlobOpenCount",
|
||||
"StringReadLength",
|
||||
|
||||
//
|
||||
};
|
||||
@@ -634,8 +646,9 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
map.put("EffectedRowCountMax", getUpdateCountMax()); // 32
|
||||
map.put("FetchRowCountMax", getFetchRowCountMax()); // 33
|
||||
map.put("ClobOpenCount", getClobOpenCount()); // 34
|
||||
|
||||
|
||||
map.put("BlobOpenCount", getBlobOpenCount()); // 35
|
||||
map.put("StringReadLength", getStringReadLength()); // 36
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user