Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[#9641] Replace agent-stat api #9682

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export class AgentStatisticChartContainerComponent implements OnInit {
ngOnInit() {
this.emptyText$ = this.translateService.get('COMMON.NO_DATA');
this.chartData$ = this.storeHelperService.getAgentList(this.unsubscribe).pipe(
filter((data: IAgentList) => !!data),
map((data: IAgentList) => this.makeChartData(data))
filter((data: IServerAndAgentDataV2[]) => !!data),
map((data: IServerAndAgentDataV2[]) => this.makeChartData(data))
);
}

private makeChartData(data: IAgentList): {[key: string]: PrimitiveArray[]} {
private makeChartData(data: IServerAndAgentDataV2[]): {[key: string]: PrimitiveArray[]} {
if (isEmpty(data)) {
return {
jvm: [],
Expand All @@ -55,11 +55,11 @@ export class AgentStatisticChartContainerComponent implements OnInit {
* }
*/
let count = 0;
const dataObj = Object.keys(data).reduce((acc1: {[key: string]: any}, appKey: string) => {
const app = data[appKey];

return app.reduce((acc2: {[key: string]: any}, {agentVersion, jvmInfo}: IAgent) => {
const dataObj = data.reduce((acc1: {[key: string]: any}, {instancesList}: IServerAndAgentDataV2) => {
return instancesList.reduce((acc2: {[key: string]: any}, {agentVersion, jvmInfo}: IAgentDataV2) => {
count++;

if (agentVersion) {
acc2['agent'][agentVersion] = (acc2['agent'][agentVersion] || 0) + 1;
}
Expand All @@ -71,7 +71,7 @@ export class AgentStatisticChartContainerComponent implements OnInit {

return acc2;
}, acc1);
}, {jvm: {}, agent: {}}) as {[key: string]: {[key: string]: number}};
}, {jvm: {}, agent: {}})

const sortedDataObj = Object.entries(dataObj).reduce((acc1: {[key: string]: Map<string, number>}, [key, valueObj]: [string, {[key: string]: number}]) => {
const sortedChildMap = new Map<string, number>(Object.entries(valueObj).sort(([k1], [k2]) => k1 < k2 ? -1 : 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class AgentStatisticListContainerComponent implements OnInit, OnDestroy {

ngOnInit() {
this.agentListData$ = this.storeHelperService.getAgentList(this.unsubscribe).pipe(
map((data: IAgentList) => this.makeGridData(data))
map((data: IServerAndAgentDataV2[]) => this.makeGridData(data))
);
}

Expand All @@ -34,33 +34,27 @@ export class AgentStatisticListContainerComponent implements OnInit, OnDestroy {
this.unsubscribe.complete();
}

private makeGridData(agentList: IAgentList): IGridData[] {
private makeGridData(data: IServerAndAgentDataV2[]): IGridData[] {
let index = 1;
const resultData: IGridData[] = [];
Object.keys(agentList).forEach((key: string, innerIndex: number) => {
const list: IAgent[] = agentList[key];
data.forEach(({instancesList}: IServerAndAgentDataV2) => {
let row: IGridData;

if (list.length === 0) {
row = this.makeRow(list[0], index, false, false);
instancesList.forEach((agent: IAgentDataV2, agentIndex: number) => {
if (agentIndex === 0) {
row = this.makeRow(agent, index, true, false);
} else {
row.children.push(this.makeRow(agent, index, false, true));
}
index++;
} else {
list.forEach((agent: IAgent, agentIndex: number) => {
if (agentIndex === 0) {
row = this.makeRow(agent, index, true, false);
} else {
row.children.push(this.makeRow(agent, index, false, true));
}
index++;
});
}
});
resultData.push(row);
});

return resultData;
}

private makeRow(agent: IAgent, index: number, hasChild: boolean, isChild: boolean): any {
private makeRow(agent: IAgentDataV2, index: number, hasChild: boolean, isChild: boolean): any {
const oRow: IGridData = {
index: index,
application: agent.applicationName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { tap } from 'rxjs/operators';

@Injectable()
export class AgentStatisticDataService {
private url = 'getAgentList.pinpoint';
private url = 'agents/statistics.pinpoint';
private lastRequestTime: number;

constructor(
private http: HttpClient
) {}

getData(): Observable<IAgentList> {
return this.http.get<IAgentList>(this.url).pipe(
getData(): Observable<IServerAndAgentDataV2[]> {
return this.http.get<IServerAndAgentDataV2[]>(this.url).pipe(
tap(() => {
this.lastRequestTime = new Date().getTime();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ConfigurationAgentStatisticContainerComponent implements OnInit, On
tap(() => {
this.lastRequestTime = moment(this.agentStatisticDataService.getLastRequestTime()).tz(this.timezone).format(this.dateFormat);
}),
map((data: IAgentList) => !!data)
map((data: IServerAndAgentDataV2[]) => !!data)
);
}

Expand Down Expand Up @@ -80,7 +80,7 @@ export class ConfigurationAgentStatisticContainerComponent implements OnInit, On
this.showProcessing();
this.agentStatisticDataService.getData().pipe(
takeUntil(this.unsubscribe)
).subscribe((agentList: IAgentList) => {
).subscribe((agentList: IServerAndAgentDataV2[]) => {
this.storeHelperService.dispatch(new Actions.UpdateAdminAgentList(agentList));
this.hideProcessing();
}, (error: IServerError) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class StoreHelperService {
})
);
}
getAgentList(unsubscribe: Subject<void>): Observable<IAgentList> {
getAgentList(unsubscribe: Subject<void>): Observable<IServerAndAgentDataV2[]> {
return this.getObservable(STORE_KEY.ADMIN_AGENT_LIST, unsubscribe);
}
getAgentSelection(unsubscribe: Subject<void>): Observable<string> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Action } from '@ngrx/store';
const UPDATE_ADMIN_AGENT_LIST = 'UPDATE_ADMIN_AGENT_LIST';
export class UpdateAdminAgentList implements Action {
readonly type = UPDATE_ADMIN_AGENT_LIST;
constructor(public payload: IAgentList) {}
constructor(public payload: IServerAndAgentDataV2[]) {}
}

export function Reducer(state: IAgentList, action: UpdateAdminAgentList): IAgentList {
export function Reducer(state: IServerAndAgentDataV2[], action: UpdateAdminAgentList): IServerAndAgentDataV2[] {
switch (action.type) {
case UPDATE_ADMIN_AGENT_LIST:
return action.payload;
Expand Down
21 changes: 13 additions & 8 deletions web/src/main/angular/src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,28 +336,33 @@ interface IServerAndAgentDataV2 {
}

interface IAgentDataV2 {
applicationName: string;
agentId: string;
agentName: string;
agentVersion: string;
applicationName: string;
container: boolean;
startTimestamp: number;
hostName: string;
ip: string;
linkList: any[];
pid: number;
ports: string;
serviceType: string;
pid: number;
vmVersion: string;
agentVersion: string;
container: boolean;
serviceTypeCode: number;
startTimestamp: number;
status: {
jvmInfo?: {
version: number;
jvmVersion: string;
gcTypeName: string;
};
status?: {
agentId: string;
eventTimestamp: number;
state: {
code: number;
desc: string;
}
};
vmVersion: string;
linkList?: any[];
}

// @store
Expand Down
3 changes: 2 additions & 1 deletion web/src/main/angular/src/proxy.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ const PROXY_CONFIG = [
"/uriStat/top50.pinpoint",
"/uriStat/chart.pinpoint",
"/agents/search-all",
"/agents/search-application"
"/agents/search-application",
"/agents/statistics"
],
target: 'http://localhost:8080',
secure: false
Expand Down