mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add readBytes Count
This commit is contained in:
@@ -709,26 +709,26 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Blob resultSet_getBlob(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
|
||||
Blob blob = chain.resultSet_getBlob(result, columnIndex);
|
||||
|
||||
|
||||
if (blob != null) {
|
||||
blobOpenAfter(chain.getDataSource().getDataSourceStat(), result, blob);
|
||||
}
|
||||
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Blob resultSet_getBlob(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
|
||||
Blob blob = chain.resultSet_getBlob(result, columnLabel);
|
||||
|
||||
|
||||
if (blob != null) {
|
||||
blobOpenAfter(chain.getDataSource().getDataSourceStat(), result, blob);
|
||||
}
|
||||
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
@@ -826,7 +826,7 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
if (obj instanceof Clob) {
|
||||
clobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (ClobProxy) obj);
|
||||
}
|
||||
|
||||
|
||||
if (obj instanceof Blob) {
|
||||
blobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (Blob) obj);
|
||||
}
|
||||
@@ -882,7 +882,7 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
private void blobOpenAfter(JdbcDataSourceStat dataSourceStat, ResultSetProxy rs, Blob blob) {
|
||||
blobOpenAfter(dataSourceStat, rs.getStatementProxy(), blob);
|
||||
}
|
||||
@@ -893,7 +893,7 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
|
||||
private void blobOpenAfter(JdbcDataSourceStat dataSourceStat, StatementProxy stmt, Blob blob) {
|
||||
dataSourceStat.incrementBlobOpenCount();
|
||||
|
||||
|
||||
if (stmt != null) {
|
||||
JdbcSqlStat sqlStat = stmt.getSqlStat();
|
||||
if (sqlStat != null) {
|
||||
@@ -916,26 +916,48 @@ 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] resultSet_getBytes(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException {
|
||||
byte[] value = chain.resultSet_getBytes(result, columnIndex);
|
||||
|
||||
if (value != null) {
|
||||
result.addReadBytesLength(value.length);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] resultSet_getBytes(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException {
|
||||
byte[] value = chain.resultSet_getBytes(result, columnLabel);
|
||||
|
||||
if (value != null) {
|
||||
result.addReadBytesLength(value.length);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,8 @@ public interface ResultSetProxy extends ResultSet, WrapperProxy {
|
||||
void addReadStringLength(int length);
|
||||
|
||||
long getReadStringLength();
|
||||
|
||||
void addReadBytesLength(int length);
|
||||
|
||||
long getReadBytesLength();
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public class ResultSetProxyImpl extends WrapperProxyImpl implements ResultSetPro
|
||||
private int closeCount = 0;
|
||||
|
||||
private long readStringLength = 0;
|
||||
private long readBytesLength = 0;
|
||||
|
||||
public ResultSetProxyImpl(StatementProxy statement, ResultSet resultSet, long id, String sql){
|
||||
super(resultSet, id);
|
||||
@@ -1089,5 +1090,15 @@ public class ResultSetProxyImpl extends WrapperProxyImpl implements ResultSetPro
|
||||
public long getReadStringLength() {
|
||||
return readStringLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addReadBytesLength(int length) {
|
||||
this.readBytesLength += length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getReadBytesLength() {
|
||||
return readBytesLength;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,7 +77,8 @@ 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 AtomicLong readStringLength = new AtomicLong();
|
||||
private final AtomicLong readBytesLength = new AtomicLong();
|
||||
|
||||
private final Histogram histogram = new Histogram(new long[] { //
|
||||
//
|
||||
@@ -227,7 +228,8 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
|
||||
blobOpenCount.set(0);
|
||||
clobOpenCount.set(0);
|
||||
stringReadLength.set(0);
|
||||
readStringLength.set(0);
|
||||
readBytesLength.set(0);
|
||||
}
|
||||
|
||||
public long getConcurrentMax() {
|
||||
@@ -284,13 +286,21 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
public void incrementBlobOpenCount() {
|
||||
blobOpenCount.incrementAndGet();
|
||||
}
|
||||
|
||||
public long getStringReadLength() {
|
||||
return stringReadLength.get();
|
||||
|
||||
public long getReadStringLength() {
|
||||
return readStringLength.get();
|
||||
}
|
||||
|
||||
|
||||
public void addStringReadLength(long length) {
|
||||
this.stringReadLength.addAndGet(length);
|
||||
this.readStringLength.addAndGet(length);
|
||||
}
|
||||
|
||||
public long getReadBytesLength() {
|
||||
return readBytesLength.get();
|
||||
}
|
||||
|
||||
public void addReadBytesLength(int length) {
|
||||
this.readBytesLength.addAndGet(length);
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
@@ -519,6 +529,7 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
// 35 -
|
||||
SimpleType.LONG, //
|
||||
SimpleType.LONG, //
|
||||
SimpleType.LONG, //
|
||||
|
||||
};
|
||||
|
||||
@@ -573,8 +584,9 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
"ClobOpenCount",
|
||||
|
||||
// 35 -
|
||||
"BlobOpenCount",
|
||||
"StringReadLength",
|
||||
"BlobOpenCount", //
|
||||
"ReadStringLength", //
|
||||
"ReadBytesLength",
|
||||
|
||||
//
|
||||
};
|
||||
@@ -648,7 +660,8 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
map.put("ClobOpenCount", getClobOpenCount()); // 34
|
||||
|
||||
map.put("BlobOpenCount", getBlobOpenCount()); // 35
|
||||
map.put("StringReadLength", getStringReadLength()); // 36
|
||||
map.put("ReadStringLength", getReadStringLength()); // 36
|
||||
map.put("ReadBytesLength", getReadBytesLength()); // 37
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -104,8 +104,12 @@
|
||||
<td id="ClobOpenCount"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='td_lable'>StringReadLength</td>
|
||||
<td id="StringReadLength"></td>
|
||||
<td class='td_lable'>ReadStringLength</td>
|
||||
<td id="ReadStringLength"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='td_lable'>ReadBytesLength</td>
|
||||
<td id="ReadBytesLength"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="container">
|
||||
@@ -155,7 +159,8 @@
|
||||
$("#BatchSizeTotal").text(sqlInfo.BatchSizeTotal)
|
||||
$("#BlobOpenCount").text(sqlInfo.BlobOpenCount)
|
||||
$("#ClobOpenCount").text(sqlInfo.ClobOpenCount)
|
||||
$("#StringReadLength").text(sqlInfo.StringReadLength)
|
||||
$("#ReadStringLength").text(sqlInfo.ReadStringLength)
|
||||
$("#ReadBytesLength").text(sqlInfo.ReadBytesLength)
|
||||
},
|
||||
dataType: "json"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user