Skip to content

Commit 2f0e349

Browse files
committed
Merge pull request scouter-project#135 from scouter-project/master
Merge for release
2 parents e0b7f60 + 6a1fd45 commit 2f0e349

85 files changed

Lines changed: 1046 additions & 517 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ Scouter has three modules:
7272
- [Scouter APM : Facebook Scouter user group](https://www.facebook.com/groups/scouterapm/)
7373

7474
## How to contribute
75-
- TBD
75+
- **Notice** : Pull request to **dev branch** only allowed.
76+
- Please check the development guide below
77+
- [Scouter developer guide](./scouter.document/tech/Developer-Guide.md)
78+
7679

7780

7881
## Q&A

‎README_kr.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ APM은 Application performance montoring 또는 application performance manageme
6767
- [Scouter APM 사용자 모임 - Facebook 그룹](https://www.facebook.com/groups/scouterapm/)
6868

6969
## Scouter에 기여하기
70-
- TBD
70+
- **Pull request**는 반드시 **dev branch**로 요청하여야 합니다.
71+
- 상세한 내용은 개발자 가이드를 참조하시기 바랍니다.
72+
- [Scouter 개발자 가이드](./scouter.document/tech/Developer-Guide_kr.md)
7173

7274
## Q&A
7375
- [Google Groups](https://groups.google.com/forum/#!forum/scouter-project)

‎scouter.agent.host/src/scouter/agent/counter/task/HostPerf.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ void domain(CounterBasket pw) throws SigarException {
103103

104104
p = pw.getPack(conf.getObjName(), TimeTypeEnum.FIVE_MIN);
105105
p.put(CounterConstants.HOST_CPU, new FloatValue(cpu));
106+
p.put(CounterConstants.HOST_SYSCPU, new FloatValue(sysCpu));
107+
p.put(CounterConstants.HOST_USERCPU, new FloatValue(userCpu));
106108
p.put(CounterConstants.HOST_MEM, new FloatValue(memrate));
107109
p.put(CounterConstants.HOST_MEM_TOTAL, new DecimalValue(tmem / 1024 / 1024));
108110
p.put(CounterConstants.HOST_MEM_USED, new DecimalValue(umem / 1024 / 1024));

‎scouter.agent.java/src/scouter/agent/asm/JDBCPreparedStatementASM.java‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737
public class JDBCPreparedStatementASM implements IASM, Opcodes {
3838
public final HashSet<String> target = HookingSet.getHookingClassSet(Configure.getInstance().hook_jdbc_pstmt_classes);
3939
public final HashSet<String> noField = new HashSet<String>();
40+
4041
public JDBCPreparedStatementASM() {
41-
target.add("org.mariadb.jdbc.MariaDbClientPreparedStatement");
42-
target.add("org.mariadb.jdbc.MariaDbServerPreparedStatement");
42+
target.add("org/mariadb/jdbc/AbstractMariaDbPrepareStatement");
43+
target.add("org/mariadb/jdbc/MariaDbClientPreparedStatement");
44+
target.add("org/mariadb/jdbc/MariaDbServerPreparedStatement");
4345
target.add("org/mariadb/jdbc/MySQLPreparedStatement");
4446
target.add("oracle/jdbc/driver/OraclePreparedStatement");
4547
target.add("org/postgresql/jdbc2/AbstractJdbc2Statement");
@@ -55,9 +57,10 @@ public JDBCPreparedStatementASM() {
5557
target.add("cubrid/jdbc/driver/CUBRIDPreparedStatement");
5658

5759
// @skyworker - MySQL ServerPreparedStatement는 특별히 필드를 추가하지 않음
58-
noField.add("org.mariadb.jdbc.MariaDbServerPreparedStatement");
59-
noField.add("com/mysql/jdbc/ServerPreparedStatement");
60+
noField.add("com/mysql/jdbc/ServerPreparedStatement");
6061
noField.add("jdbc/FakePreparedStatement2");
62+
noField.add("org/mariadb/jdbc/MariaDbClientPreparedStatement");
63+
noField.add("org/mariadb/jdbc/MariaDbServerPreparedStatement");
6164
}
6265

6366
public ClassVisitor transform(ClassVisitor cv, String className, ClassDesc classDesc) {

‎scouter.agent.java/src/scouter/agent/counter/meter/MeterAPI.java‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public synchronized void add(int elapsed, boolean err) {
5656
}
5757
}
5858

59-
public float getCountPerSec(int period) {
59+
public float getTps(int period) {
6060
final INT sum = new INT();
6161
period = meter.search(period, new Handler<MeterAPI.Bucket>() {
6262
public void process(Bucket b) {
@@ -79,7 +79,7 @@ public void process(Bucket b) {
7979
return (int) ((cnt.value == 0) ? 0 : sum.value / cnt.value);
8080
}
8181

82-
public long getTimeSum(int period) {
82+
public long getSumTime(int period) {
8383
final LONG sum = new LONG();
8484
period = meter.search(period, new Handler<MeterAPI.Bucket>() {
8585
public void process(Bucket b) {
@@ -89,37 +89,36 @@ public void process(Bucket b) {
8989
return ((period == 0) ? 0 : sum.value / period);
9090
}
9191

92-
public float getErrorPerSec(int period) {
92+
public int getCount(int period) {
9393

94-
final INT cnt = new INT();
95-
final INT err = new INT();
94+
final INT sum = new INT();
9695
meter.search(period, new Handler<MeterAPI.Bucket>() {
9796
public void process(Bucket b) {
98-
cnt.value += b.count;
99-
err.value += b.error;
97+
sum.value += b.count;
10098
}
10199
});
102-
return (float) ((cnt.value == 0) ? 0 : (((double) err.value / cnt.value) * 100.0));
100+
return sum.value;
103101
}
104102

105-
public int getCount(int period) {
106-
103+
public int getErrorCount(int period) {
107104
final INT sum = new INT();
108105
meter.search(period, new Handler<MeterAPI.Bucket>() {
109106
public void process(Bucket b) {
110-
sum.value += b.count;
107+
sum.value += b.error;
111108
}
112109
});
113110
return sum.value;
114111
}
115112

116-
public int getError(int period) {
117-
final INT sum = new INT();
113+
public float getErrorRate(int period) {
114+
final INT cnt = new INT();
115+
final INT err = new INT();
118116
meter.search(period, new Handler<MeterAPI.Bucket>() {
119117
public void process(Bucket b) {
120-
sum.value += b.error;
118+
cnt.value += b.count;
119+
err.value += b.error;
121120
}
122121
});
123-
return sum.value;
122+
return (float) ((cnt.value == 0) ? 0 : (((double) err.value / cnt.value) * 100.0));
124123
}
125124
}

‎scouter.agent.java/src/scouter/agent/counter/meter/MeterSQL.java‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public synchronized void add(int elapsed, boolean err) {
5656
}
5757
}
5858

59-
public float getCountPerSec(int period) {
59+
public float getTps(int period) {
6060
final INT sum = new INT();
6161
period = meter.search(period, new Handler<MeterSQL.Bucket>() {
6262
public void process(Bucket b) {
@@ -79,7 +79,7 @@ public void process(Bucket b) {
7979
return (int) ((cnt.value == 0) ? 0 : sum.value / cnt.value);
8080
}
8181

82-
public long getTimeSum(int period) {
82+
public long getSumTime(int period) {
8383
final LONG sum = new LONG();
8484
period = meter.search(period, new Handler<MeterSQL.Bucket>() {
8585
public void process(Bucket b) {
@@ -90,37 +90,37 @@ public void process(Bucket b) {
9090
}
9191

9292

93-
public float getErrorPerSec(int period) {
93+
public int getCount(int period) {
9494

95-
final INT cnt = new INT();
96-
final INT err = new INT();
95+
final INT sum = new INT();
9796
meter.search(period, new Handler<MeterSQL.Bucket>() {
9897
public void process(Bucket b) {
99-
cnt.value += b.count;
100-
err.value += b.error;
98+
sum.value += b.count;
10199
}
102100
});
103-
return (float) ((cnt.value == 0) ? 0 : (((double) err.value / cnt.value) * 100.0));
101+
return sum.value;
104102
}
105103

106-
public int getCount(int period) {
107-
104+
public int getErrorCount(int period) {
108105
final INT sum = new INT();
109106
meter.search(period, new Handler<MeterSQL.Bucket>() {
110107
public void process(Bucket b) {
111-
sum.value += b.count;
108+
sum.value += b.error;
112109
}
113110
});
114111
return sum.value;
115112
}
116113

117-
public int getError(int period) {
118-
final INT sum = new INT();
114+
public float getErrorRate(int period) {
115+
final INT cnt = new INT();
116+
final INT err = new INT();
119117
meter.search(period, new Handler<MeterSQL.Bucket>() {
120118
public void process(Bucket b) {
121-
sum.value += b.error;
119+
cnt.value += b.count;
120+
err.value += b.error;
122121
}
123122
});
124-
return sum.value;
123+
return (float) ((cnt.value == 0) ? 0 : (((double) err.value / cnt.value) * 100.0));
125124
}
125+
126126
}

‎scouter.agent.java/src/scouter/agent/counter/meter/MeterService.java‎

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public static MeterService getInstance() {
3636
final static class Bucket {
3737
final short[] pct90 = new short[PCT_BUCKET];
3838
int count;
39-
long time;
39+
long elapsedTime;
40+
long sqlTimeByService;
41+
long apiTmeByService;
4042

4143
int error;
4244
}
@@ -49,19 +51,25 @@ protected Bucket create() {
4951
protected void clear(Bucket o) {
5052
o.count = 0;
5153
o.error = 0;
52-
o.time = 0L;
54+
o.elapsedTime = 0L;
55+
o.sqlTimeByService = 0L;
56+
o.apiTmeByService = 0L;
5357
for (int i = 0; i < PCT_BUCKET; i++) {
5458
o.pct90[i] = 0;
5559
}
5660
}
5761
};
5862

59-
public synchronized void add(int elapsed, boolean err) {
60-
if(elapsed <0)
61-
elapsed=0;
63+
public synchronized void add(long elapsed, int sqlTime, int apiTime, boolean err) {
64+
if(elapsed < 0)
65+
elapsed = 0;
66+
6267
Bucket b = meter.getCurrentBucket();
6368
b.count++;
64-
b.time += elapsed;
69+
b.elapsedTime += elapsed;
70+
b.sqlTimeByService += sqlTime;
71+
b.apiTmeByService += apiTime;
72+
6573
if (err) {
6674
b.error++;
6775
}
@@ -87,7 +95,7 @@ public int getElapsedTime(int period) {
8795
final INT cnt = new INT();
8896
meter.search(period, new Handler<MeterService.Bucket>() {
8997
public void process(Bucket b) {
90-
sum.value += b.time;
98+
sum.value += b.elapsedTime;
9199
cnt.value += b.count;
92100

93101
}
@@ -120,7 +128,35 @@ public void process(Bucket b) {
120128
return (int) ((cnt.value == 0) ? 0 : sum.value / cnt.value);
121129
}
122130

123-
public float getError(int period) {
131+
public int getSqlTime(int period) {
132+
final LONG sum = new LONG();
133+
final INT cnt = new INT();
134+
135+
meter.search(period, new Handler<MeterService.Bucket>() {
136+
public void process(Bucket b) {
137+
sum.value += b.sqlTimeByService;
138+
cnt.value += b.count;
139+
140+
}
141+
});
142+
return (int) ((cnt.value == 0) ? 0 : sum.value / cnt.value);
143+
}
144+
145+
public int getApiTime(int period) {
146+
final LONG sum = new LONG();
147+
final INT cnt = new INT();
148+
149+
meter.search(period, new Handler<MeterService.Bucket>() {
150+
public void process(Bucket b) {
151+
sum.value += b.apiTmeByService;
152+
cnt.value += b.count;
153+
154+
}
155+
});
156+
return (int) ((cnt.value == 0) ? 0 : sum.value / cnt.value);
157+
}
158+
159+
public float getErrorRate(int period) {
124160

125161
final INT cnt = new INT();
126162
final INT err = new INT();

‎scouter.agent.java/src/scouter/agent/counter/task/ServicePerf.java‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ public void getServicePerf(CounterBasket pw) {
4747
MeterService service = MeterService.getInstance();
4848
int elapsed = service.getElapsedTime(30);
4949
float tps = service.getTPS(30);
50-
float err = service.getError(30);
50+
float errorRate = service.getErrorRate(30);
5151
int count = service.getServiceCount(60);
5252
int resp90pct = service.getElapsed90Pct(30);
53+
int sqlTimeByService = service.getSqlTime(30);
54+
int apiTimeByService = service.getApiTime(30);
5355

5456
int[] act = TraceContextManager.getActiveCount();
5557
int active = act[0] + act[1] + act[2];
@@ -65,9 +67,11 @@ public void getServicePerf(CounterBasket pw) {
6567
p.put(CounterConstants.WAS_ELAPSED_TIME, new DecimalValue(elapsed));
6668
p.put(CounterConstants.WAS_SERVICE_COUNT, new DecimalValue(count));
6769
p.put(CounterConstants.WAS_TPS, new FloatValue(tps));
68-
p.put(CounterConstants.WAS_ERROR_RATE, new FloatValue(err));
70+
p.put(CounterConstants.WAS_ERROR_RATE, new FloatValue(errorRate));
6971
p.put(CounterConstants.WAS_ACTIVE_SERVICE, new DecimalValue(active));
7072
p.put(CounterConstants.WAS_ELAPSED_90PCT, new DecimalValue(resp90pct));
73+
p.put(CounterConstants.WAS_APICALL_ELAPSED_TIME_BY_SERVICE, new DecimalValue(apiTimeByService));
74+
p.put(CounterConstants.WAS_SQL_ELAPSED_TIME_BY_SERVICE, new DecimalValue(sqlTimeByService));
7175

7276
ListValue activeSpeed = new ListValue();
7377
activeSpeed.add(act[0]);
@@ -81,17 +85,21 @@ public void getServicePerf(CounterBasket pw) {
8185
count = service.getServiceCount(300);
8286
tps = service.getTPS(300);
8387
elapsed = service.getElapsedTime(300);
84-
err = service.getError(300);
85-
int activeSErvice = (int) activeCounter.getAvg(300);
88+
errorRate = service.getErrorRate(300);
89+
int activeService = (int) activeCounter.getAvg(300);
8690
resp90pct = service.getElapsed90Pct(300);
91+
sqlTimeByService = service.getSqlTime(300);
92+
apiTimeByService = service.getApiTime(300);
8793

8894
p = pw.getPack(TimeTypeEnum.FIVE_MIN);
8995
p.put(CounterConstants.WAS_ELAPSED_TIME, new DecimalValue(elapsed));
9096
p.put(CounterConstants.WAS_SERVICE_COUNT, new DecimalValue(count));
9197
p.put(CounterConstants.WAS_TPS, new FloatValue(tps));
92-
p.put(CounterConstants.WAS_ERROR_RATE, new FloatValue(err));
93-
p.put(CounterConstants.WAS_ACTIVE_SERVICE, new DecimalValue(activeSErvice));
98+
p.put(CounterConstants.WAS_ERROR_RATE, new FloatValue(errorRate));
99+
p.put(CounterConstants.WAS_ACTIVE_SERVICE, new DecimalValue(activeService));
94100
p.put(CounterConstants.WAS_ELAPSED_90PCT, new DecimalValue(resp90pct));
101+
p.put(CounterConstants.WAS_APICALL_ELAPSED_TIME_BY_SERVICE, new DecimalValue(apiTimeByService));
102+
p.put(CounterConstants.WAS_SQL_ELAPSED_TIME_BY_SERVICE, new DecimalValue(sqlTimeByService));
95103
}
96104

97105
private long last_sent = DateUtil.getMinUnit(System.currentTimeMillis()) / 5;

0 commit comments

Comments
 (0)