-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#8843] Implement apdex score chart in inspector
- Loading branch information
1 parent
5066c43
commit 43e0593
Showing
51 changed files
with
505 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
3 changes: 3 additions & 0 deletions
3
...src/main/angular/src/app/core/components/apdex-score/apdex-score-container.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<pp-apdex-score | ||
[score]="apdexScore"> | ||
</pp-apdex-score> |
65 changes: 65 additions & 0 deletions
65
web/src/main/angular/src/app/core/components/apdex-score/apdex-score-container.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; | ||
import { Subject, merge } from 'rxjs'; | ||
import { filter, switchMap, tap, map, takeUntil } from 'rxjs/operators'; | ||
|
||
import { MessageQueueService, MESSAGE_TO, NewUrlStateNotificationService } from 'app/shared/services'; | ||
import { ApdexScoreDataService } from './apdex-score-data.service'; | ||
import { ServerMapData } from 'app/core/components/server-map/class/server-map-data.class'; | ||
|
||
@Component({ | ||
selector: 'pp-apdex-score-container', | ||
templateUrl: './apdex-score-container.component.html', | ||
styleUrls: ['./apdex-score-container.component.css'] | ||
}) | ||
export class ApdexScoreContainerComponent implements OnInit, OnDestroy { | ||
private unsubscribe = new Subject<void>(); | ||
|
||
private selectedTarget: ISelectedTarget; | ||
private serverMapData: ServerMapData; | ||
private previousRange: number[]; | ||
|
||
apdexScore: number; | ||
|
||
constructor( | ||
private apdexScoreDataService: ApdexScoreDataService, | ||
private messageQueueService: MessageQueueService, | ||
private newUrlStateNotificationService: NewUrlStateNotificationService, | ||
private cd: ChangeDetectorRef, | ||
) { } | ||
|
||
ngOnInit() { | ||
this.newUrlStateNotificationService.onUrlStateChange$.pipe( | ||
takeUntil((this.unsubscribe)), | ||
).subscribe(() => { | ||
this.serverMapData = null; | ||
this.selectedTarget = null; | ||
}); | ||
|
||
merge( | ||
this.messageQueueService.receiveMessage(this.unsubscribe, MESSAGE_TO.SERVER_MAP_DATA_UPDATE).pipe( | ||
tap(({serverMapData, range}: {serverMapData: ServerMapData, range: number[]}) => { | ||
this.serverMapData = serverMapData; | ||
this.previousRange = range; | ||
}), | ||
filter(() => !!this.selectedTarget), | ||
), | ||
this.messageQueueService.receiveMessage(this.unsubscribe, MESSAGE_TO.SERVER_MAP_TARGET_SELECT).pipe( | ||
filter(({isWAS, isMerged}: ISelectedTarget) => isWAS && !isMerged), | ||
tap((target: ISelectedTarget) => this.selectedTarget = target), | ||
) | ||
).pipe( | ||
map(() => this.serverMapData.getNodeData(this.selectedTarget.node[0])), | ||
switchMap(({applicationName, serviceTypeCode}: INodeInfo) => { | ||
return this.apdexScoreDataService.getApdexScore({applicationName, serviceTypeCode, from: this.previousRange[0], to: this.previousRange[1]}); | ||
}) | ||
).subscribe(({apdexScore}: {apdexScore: number}) => { | ||
this.apdexScore = apdexScore; | ||
this.cd.detectChanges(); | ||
}); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.unsubscribe.next(); | ||
this.unsubscribe.complete(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
web/src/main/angular/src/app/core/components/apdex-score/apdex-score-data.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
|
||
@Injectable({providedIn: 'root'}) | ||
export class ApdexScoreDataService { | ||
private url = 'getApdexScore.pinpoint'; | ||
|
||
constructor( | ||
private http: HttpClient, | ||
) { } | ||
|
||
getApdexScore(params: {[key: string]: any}): Observable<{apdexScore: number}> { | ||
return this.http.get<{apdexScore: number}>(this.url, {params}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...main/angular/src/app/core/components/inspector-chart/agent-apdex-score-chart.container.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { PrimitiveArray, Data, spline } from 'billboard.js'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import { IInspectorChartContainer } from './inspector-chart-container-factory'; | ||
import { makeYData, makeXData, getMaxTickValue } from 'app/core/utils/chart-util'; | ||
import { IInspectorChartData, InspectorChartDataService } from './inspector-chart-data.service'; | ||
import { InspectorChartThemeService } from './inspector-chart-theme.service'; | ||
import { NewUrlStateNotificationService } from 'app/shared/services'; | ||
import { UrlPathId } from 'app/shared/models'; | ||
|
||
export class AgentApdexScoreChartContainer implements IInspectorChartContainer { | ||
private apiUrl = 'getAgentStat/apdexScore/chart.pinpoint'; | ||
|
||
defaultYMax = 1; | ||
title = 'Apdex Score'; | ||
|
||
constructor( | ||
private inspectorChartDataService: InspectorChartDataService, | ||
private inspectorChartThemeService: InspectorChartThemeService, | ||
private newUrlStateNotificationService: NewUrlStateNotificationService, | ||
) {} | ||
|
||
getData(range: number[]): Observable<IInspectorChartData> { | ||
const applicationId = this.newUrlStateNotificationService.getPathValue(UrlPathId.APPLICATION).getApplicationName(); | ||
const serviceTypeName = this.newUrlStateNotificationService.getPathValue(UrlPathId.APPLICATION).getServiceType(); | ||
|
||
return this.inspectorChartDataService.getData(this.apiUrl, range, {serviceTypeName, applicationId}); | ||
} | ||
|
||
makeChartData({charts}: IInspectorChartData): PrimitiveArray[] { | ||
return [ | ||
['x', ...makeXData(charts.x)], | ||
['apdexScore', ...makeYData(charts.y['APDEX_SCORE'], 2)], | ||
]; | ||
} | ||
|
||
makeDataOption(): Data { | ||
const alpha = this.inspectorChartThemeService.getAlpha(0.4); | ||
|
||
return { | ||
type: spline(), | ||
names: { | ||
apdexScore: 'Apdex Score', | ||
}, | ||
colors: { | ||
apdexScore: `rgba(65, 196, 100, ${alpha})`, | ||
} | ||
}; | ||
} | ||
|
||
makeElseOption(): {[key: string]: any} { | ||
return {}; | ||
} | ||
|
||
makeYAxisOptions(data: PrimitiveArray[]): {[key: string]: any} { | ||
return { | ||
y: { | ||
label: { | ||
text: 'Apdex Score', | ||
position: 'outer-middle' | ||
}, | ||
tick: { | ||
count: 5, | ||
format: (v: number): string => this.convertWithUnit(v) | ||
}, | ||
padding: { | ||
top: 0, | ||
bottom: 0 | ||
}, | ||
min: 0, | ||
max: this.defaultYMax, | ||
default: [0, this.defaultYMax] | ||
} | ||
}; | ||
} | ||
|
||
makeTooltipOptions(): {[key: string]: any} { | ||
return { | ||
linked: false | ||
}; | ||
} | ||
|
||
convertWithUnit(value: number): string { | ||
return (Math.floor(value * 100) / 100).toFixed(2); | ||
} | ||
|
||
getTooltipFormat(v: number, columnId: string, i: number): string { | ||
return this.convertWithUnit(v); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.