Skip to content

Commit 6a38c25

Browse files
authored
Merge pull request #245 from scouter-contrib/release/2.6.2
XLOG 클래스 모드 추가 및 프로파일 에러 구현
2 parents 593af7c + 2f0a685 commit 6a38c25

File tree

12 files changed

+327
-28
lines changed

12 files changed

+327
-28
lines changed

http/xflow.http

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,6 @@ GET http://demo.scouterapm.com:6188/scouter/v1/xlog-data/20191017/-8542316848524
7272
GET http://demo.scouterapm.com:6188/scouter/v1/dictionary/20191020?dictKeys=[table:566700965]
7373

7474
###
75+
GET http://demo.scouterapm.com:6188/scouter/v1/dictionary/20191106?dictKeys=[error:305445213]
76+
77+
###

src/common/InstanceColor.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
import * as d3 from "d3";
2-
import {schemeSet3} from "d3-scale-chromatic";
2+
import {schemeSet3,interpolateViridis} from "d3-scale-chromatic";
33
import Color from "color-js";
44

55
let instanceColors = {};
66
let metricColors = {};
7+
let xlogColors = {};
78
class InstanceColor {
89
static setInstances(instances, colorType) {
910
instanceColors = {};
11+
const _xlogFamilly = instances.filter(_in=> _in.objFamily === 'javaee' || _in.objFamily === 'tracing');
12+
const _total = _xlogFamilly.length;
13+
_xlogFamilly.forEach((instance, n) => {
14+
xlogColors[instance.objHash] = interpolateViridis(n/_total);
15+
});
16+
1017
instances.forEach((instance, n) => {
1118
instanceColors[instance.objHash] = [];
1219
let instanceBaseColor;
20+
1321
if (n > 9) {
1422
let cnt = Math.floor(n / 10);
1523
instanceBaseColor = Color(d3.schemeCategory10[n % 10]).shiftHue(20 * cnt);
1624
} else {
1725
instanceBaseColor = d3.schemeCategory10[n]; // 10
1826
}
27+
28+
1929
instanceColors[instance.objHash].push(instanceBaseColor);
30+
2031
for (let i=0; i<4; i++) {
2132
let color = Color(instanceBaseColor);
2233
if (colorType === "white") {
@@ -26,11 +37,16 @@ class InstanceColor {
2637
}
2738
}
2839
});
40+
41+
2942
}
3043

3144
static getInstanceColors() {
3245
return instanceColors;
3346
}
47+
static getXlogColors() {
48+
return xlogColors;
49+
}
3450

3551
static getMetricColor(metric, colorType) {
3652
if (!metricColors[metric]) {

src/common/ScouterApi.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import jQuery from "jquery";
2+
import {getCurrentUser, getWithCredentials, setAuthHeader} from "./common";
3+
4+
export default class ScouterApi {
5+
//- Default Api
6+
// App, Control API List
7+
static isAuthentification(config) {
8+
const {addr,conf,user,serverId} = config;
9+
10+
return jQuery.ajax({
11+
method: "GET",
12+
async: true,
13+
url: `${addr}/scouter/v1/kv/a?serverId=${serverId}`,
14+
xhrFields: getWithCredentials(conf),
15+
beforeSend: (xhr)=> setAuthHeader(xhr, conf, user)
16+
});
17+
}
18+
static getObjectPreset(config) {
19+
const {addr,conf,user,serverId} = config;
20+
21+
return jQuery.ajax({
22+
method: "GET",
23+
async: true,
24+
url: `${addr}/scouter/v1/kv/__scouter_paper_preset?serverId=${serverId}`,
25+
xhrFields: getWithCredentials(conf),
26+
beforeSend: (xhr)=> setAuthHeader(xhr, conf, getCurrentUser(conf,user))
27+
});
28+
}
29+
static getAlertList(config,offset,objType){
30+
const {addr,conf,user,serverId} = config;
31+
const {ol,la} = offset;
32+
return jQuery.ajax({
33+
method: "GET",
34+
async: true,
35+
url: `${addr}/scouter/v1/alert/realTime/${ol}/${la}?objType=${objType}&serverId=${serverId}`,
36+
xhrFields: getWithCredentials(conf),
37+
beforeSend: (xhr)=> setAuthHeader(xhr, conf, getCurrentUser(conf,user))
38+
});
39+
}
40+
static getConterModel(config){
41+
const {addr,conf,user,serverId} = config;
42+
return jQuery.ajax({
43+
method: "GET",
44+
async: true,
45+
url: `${addr}/scouter/v1/info/counter-model?serverId=${serverId}`,
46+
xhrFields: getWithCredentials(conf),
47+
beforeSend: (xhr)=> setAuthHeader(xhr, conf, getCurrentUser(conf,user))
48+
});
49+
}
50+
51+
static getMonitoringObjects(config){
52+
const {addr,conf,user,serverId} = config;
53+
return jQuery.ajax({
54+
method: "GET",
55+
async: true,
56+
url: `${addr}scouter/v1/object?serverId=${serverId}`,
57+
xhrFields: getWithCredentials(conf),
58+
beforeSend: (xhr)=> setAuthHeader(xhr, conf, getCurrentUser(conf,user))
59+
});
60+
61+
}
62+
static getConnectedServer(config){
63+
const {addr,conf,user} = config;
64+
return jQuery.ajax({
65+
method: "GET",
66+
async: true,
67+
url: `${addr}scouter/v1/info/server`,
68+
xhrFields: getWithCredentials(conf),
69+
beforeSend: (xhr)=> setAuthHeader(xhr, conf, getCurrentUser(conf,user))
70+
});
71+
72+
}
73+
//- 실시간 쪽
74+
static getRealTimeCounter(config,params,objects){
75+
const {addr,conf,user,serverId} = config;
76+
return jQuery.ajax({
77+
method: "GET",
78+
async: true,
79+
url: `${addr}/scouter/v1/counter/realTime/${params}?objHashes=${JSON.stringify(objects.map(obj=>Number(obj.objHash)))}?serverId=${serverId}`,
80+
xhrFields: getWithCredentials(conf),
81+
beforeSend: (xhr)=> setAuthHeader(xhr, conf, getCurrentUser(conf,user))
82+
});
83+
}
84+
}

src/common/common.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// local storage access
22
import moment from "moment";
33
import {Dictionary, DictType} from "./dictionary";
4-
export const version = "2.6.1";
4+
export const version = "2.6.2";
55

66
export function getData(key) {
77
let ls = null;
@@ -796,3 +796,11 @@ export function updateQueryStringParameter(uri, key, value) {
796796
return uri + separator + key + "=" + value;
797797
}
798798
}
799+
export function confBuilder(addr,conf,user,serverId){
800+
return {
801+
addr : addr,
802+
conf : conf,
803+
user : user,
804+
serverId : serverId
805+
}
806+
}

src/components/Controller/Controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ class Controller extends Component {
792792
};
793793

794794
toggleFilteredObject = (objHash) => {
795+
795796
if (this.props.filterMap[objHash]) {
796797
this.props.removeFilteredObject(objHash);
797798
} else {

src/components/Menu/Menu.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ class Menu extends Component {
2222
showAlert: false
2323
};
2424
}
25-
25+
componentWillReceiveProps(nextProps) {
26+
const {pathname}= nextProps.location;
27+
if( pathname !== this.props.pathname){
28+
this.setState({
29+
menu: pathname
30+
});
31+
this.props.setMenu(pathname);
32+
}
33+
}
2634
componentDidMount() {
2735
this.setState({
2836
menu: this.props.location.pathname

src/components/Paper/LineChart/Line.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ class Line extends Component {
6868
if (nextProps.options !== this.props.options) {
6969
this.changedOption(nextProps.options, nextProps);
7070
}
71+
72+
if( nextProps.filterMap !== this.props.filterMap){
73+
this.paint(nextProps);
74+
}
7175
if ((!nextProps.range.realTime && !nextProps.timeFocus.active) ||
7276
nextProps.counters !== this.props.counters) {
7377
this.paint(nextProps);
@@ -457,7 +461,7 @@ class Line extends Component {
457461
// this.paint(this.props);
458462
// }
459463
if(repaint){
460-
this.paint(this.props);
464+
this.paint(props);
461465
}
462466
}
463467

src/components/Paper/Paper.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ class Paper extends Component {
241241
boxes[key].values[attr] = boxes[key].advancedOption[attr].value;
242242
}
243243
}
244+
if(boxes[key].option && boxes[key].option.type ==='xlog' && !boxes[key].option.config['showClassMode']){
245+
boxes[key].option.config['showClassMode'] = Options.options().xlog.config.showClassMode;
246+
}
244247
}
245248
}
246249
this.props.setBoxesLayouts(boxes, layouts);
@@ -315,7 +318,7 @@ class Paper extends Component {
315318

316319
if (JSON.stringify(nextProps.template) !== JSON.stringify(this.props.template)) {
317320
if (JSON.stringify(nextProps.template.boxes) !== JSON.stringify(this.state.boxes) || JSON.stringify(nextProps.template.layouts) !== JSON.stringify(this.state.layouts)) {
318-
// 초기화 : 만약 라인 차트 타입 설정이 없는 경우
321+
// 초기화 : 로드한 차트에 만약 라인 차트 타입 설정이 없는 경우
319322
const boxes = nextProps.template.boxes;
320323
if( boxes ){
321324
for (const key in boxes) {
@@ -325,6 +328,9 @@ class Paper extends Component {
325328
boxes[key].values[attr] = boxes[key].advancedOption[attr].value;
326329
}
327330
}
331+
if(boxes[key].option.type ==='xlog' && !boxes[key].option.config['showClassMode']){
332+
boxes[key].option.config['showClassMode'] = Options.options().xlog.config.showClassMode;
333+
}
328334
}
329335
}
330336
this.props.setBoxesLayouts(boxes, nextProps.template.layouts);

src/components/Paper/PaperControl/Options.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ export function options() {
5454
type: "selector",
5555
data: ["Y", "N"],
5656
value: "N"
57+
},
58+
showClassMode : {
59+
name :'CLASS MODE',
60+
type: "selector",
61+
data: ["Y", "N"],
62+
value: "N"
5763
}
64+
5865
}
5966
},
6067
visitor: {

src/components/Paper/XLog/Profiler/FrameProfile/FrameStepDetail/FrameStepDetail.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import {withRouter} from 'react-router-dom';
66
import * as d3 from "d3";
77
import sqlFormatter from "sql-formatter";
88
import JSONPretty from 'react-json-pretty';
9+
import jQuery from "jquery";
10+
import {getCurrentUser, getHttpProtocol, getWithCredentials, setAuthHeader} from "../../../../../../common/common";
11+
import moment from "moment/moment";
912

1013
class FrameStepDetail extends Component {
1114

@@ -102,11 +105,31 @@ class FrameStepDetail extends Component {
102105

103106
return sql;
104107
};
105-
108+
getError(error){
109+
let ret = '';
110+
const {endTime} = this.props.profile;
111+
jQuery.ajax({
112+
method: "GET",
113+
async: false,
114+
dataType: "json",
115+
url: `${getHttpProtocol(this.props.config)}/scouter/v1/dictionary/${moment(new Date(Number(endTime))).format("YYYYMMDD")}?dictKeys=[error:${error}]`,
116+
xhrFields: getWithCredentials(this.props.config),
117+
beforeSend: (xhr)=>{
118+
setAuthHeader(xhr, this.props.config, getCurrentUser(this.props.config, this.props.user));
119+
}
120+
}).done(data=>{
121+
const res = data.result[0];
122+
if(res) {
123+
ret = res.text
124+
}
125+
});
126+
return ret ? ret : 'HAS ERROR (DISPLAY ERROR MESSAGE IS NOT YET SUPPORTED)';
127+
}
106128
render() {
107129

108130
let selectedIndex = this.props.selectedIndex;
109131
let info = this.props.steps[selectedIndex];
132+
110133
let stepLength = this.props.steps.length;
111134
let startTime = this.props.profile.endTime - this.props.profile.elapsed;
112135
let timeFormatter = d3.timeFormat(this.props.config.dateFormat + " " + this.props.config.timeFormat + " %L");
@@ -166,7 +189,7 @@ class FrameStepDetail extends Component {
166189
{(info.step.error && Number(info.step.error) !== 0) &&
167190
<div className="frame-row">
168191
<div className="sub-detail-title"><span>ERROR</span></div>
169-
<div className="main-value error">{/*info.step.error*/}HAS ERROR (DISPLAY ERROR MESSAGE IS NOT YET SUPPORTED)</div>
192+
<div className="main-value error">{this.getError(info.step.error)}</div>
170193
</div>
171194
}
172195
{info.step.stepType === "12" && // DUMP라면
@@ -293,7 +316,8 @@ class FrameStepDetail extends Component {
293316

294317
let mapStateToProps = (state) => {
295318
return {
296-
config: state.config
319+
config: state.config,
320+
user: state.user
297321
};
298322
};
299323

0 commit comments

Comments
 (0)