forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-13550][ui] Add job vertex FlameGraph UI
- Loading branch information
Showing
20 changed files
with
453 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
91 changes: 91 additions & 0 deletions
91
flink-runtime-web/web-dashboard/src/@types/d3-flame-graph/index.d.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,91 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
declare module 'd3-flame-graph' { | ||
type ColorMapper = (node: any, originalColor: string) => string; | ||
|
||
export function flamegraph(): FlameGraph; | ||
export const offCpuColorMapper: ColorMapper; | ||
export function defaultFlamegraphTooltip(): any; | ||
|
||
export interface StackFrame { | ||
name: string; | ||
value: number; | ||
children: StackFrame[]; | ||
} | ||
|
||
type LabelHandler = (node: any) => string; | ||
type ClickHandler = (node: any) => void; | ||
type DetailsHandler = (node: any) => void; | ||
type SearchHandler = (results: any, sum: any, totalValue: any) => void; | ||
type SearchMatch = (node: any, term: string) => boolean; | ||
|
||
interface FlameGraph { | ||
(selection: any): any; | ||
|
||
selfValue(val: boolean): FlameGraph; | ||
selfValue(): boolean; | ||
width(val: number): FlameGraph; | ||
width(): number; | ||
height(val: number): FlameGraph; | ||
height(): number; | ||
cellHeight(val: number): FlameGraph; | ||
cellHeight(): number; | ||
minFrameSize(val: number): FlameGraph; | ||
minFrameSize(): number; | ||
title(val: string): FlameGraph; | ||
title(): string; | ||
tooltip(val: boolean): FlameGraph; | ||
tooltip(): boolean; | ||
tooltip(any: tip): boolean; | ||
transitionDuration(val: number): FlameGraph; | ||
transitionDuration(): number; | ||
transitionEase(val: string): FlameGraph; | ||
transitionEase(): string; | ||
label(val: LabelHandler): FlameGraph; | ||
label(): LabelHandler; | ||
sort(val: boolean): FlameGraph; | ||
sort(): boolean; | ||
inverted(val: boolean): FlameGraph; | ||
inverted(): boolean; | ||
computeDelta(val: boolean): FlameGraph; | ||
computeDelta(): boolean; | ||
|
||
resetZoom(): void; | ||
onClick(val: ClickHandler): FlameGraph; | ||
onClick(): ClickHandler; | ||
setDetailsElement(val: HTMLElement | null): FlameGraph; | ||
setDetailsElement(): HTMLElement | null; | ||
setDetailsHandler(val: DetailsHandler): FlameGraph; | ||
setDetailsHandler(): FlameGraph; | ||
setSearchHandler(val: SearchHandler): FlameGraph; | ||
setSearchHandler(): FlameGraph; | ||
setColorMapper(val: ColorMapper): FlameGraph; | ||
setColorMapper(): FlameGraph; | ||
setColorHue(val: string): FlameGraph; | ||
setColorHue(): FlameGraph; | ||
setSearchMatch(val: SearchMatch): FlameGraph; | ||
setSearchMatch(): FlameGraph; | ||
|
||
search(term: string): void; | ||
clear(): void; | ||
merge(node: StackFrame): void; | ||
update(node: StackFrame): void; | ||
destroy(): void; | ||
} | ||
} |
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 @@ | ||
declare module 'd3-tip'; |
29 changes: 29 additions & 0 deletions
29
flink-runtime-web/web-dashboard/src/app/interfaces/job-flamegraph.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,29 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
export interface JobFlameGraphInterface { | ||
endTimestamp: number; | ||
data: JobFlameGraphNodeInterface; | ||
graphType: string; | ||
} | ||
|
||
export interface JobFlameGraphNodeInterface { | ||
name: string; | ||
value: number; | ||
children: JobFlameGraphNodeInterface[]; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
|
||
@import "theme"; | ||
|
||
:host { | ||
|
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
46 changes: 46 additions & 0 deletions
46
...board/src/app/pages/job/overview/flamegraph/job-overview-drawer-flamegraph.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,46 @@ | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one | ||
~ or more contributor license agreements. See the NOTICE file | ||
~ distributed with this work for additional information | ||
~ regarding copyright ownership. The ASF licenses this file | ||
~ to you under the Apache License, Version 2.0 (the | ||
~ "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ | ||
~ http:https://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
|
||
<span *ngIf="selectedVertex?.detail?.status !== 'RUNNING'"> | ||
Operator is not running. Cannot sample back pressure. | ||
</span> | ||
|
||
Type: | ||
<nz-radio-group [(ngModel)]="graphType" nzButtonStyle="solid"> | ||
<label nz-radio-button nzValue="on_cpu" (click)="selectFrameGraphType()" title="Includes Thread.State.[RUNNABLE, NEW]">On-CPU</label> | ||
<label nz-radio-button nzValue="off_cpu" (click)="selectFrameGraphType()" title="Includes Thread.State.[WAITING, TIMED_WAITING, BLOCKED]">Off-CPU</label> | ||
<label nz-radio-button nzValue="full" (click)="selectFrameGraphType()" title="Includes stack traces of threads in all states">Mixed</label> | ||
</nz-radio-group> | ||
|
||
Measurement: | ||
<span *ngIf="flameGraph.endTimestamp"> | ||
{{ (now - flameGraph.endTimestamp) | humanizeDuration }} ago | ||
</span> | ||
|
||
<div class="flame-graph-area"> | ||
<flink-flame-graph [data]="flameGraph['data']" [graphType]="graphType"></flink-flame-graph> | ||
</div> | ||
|
||
<div style="padding-top: 100px"> | ||
<nz-spin *ngIf="isLoading"></nz-spin> | ||
</div> | ||
|
||
|
||
|
||
|
31 changes: 31 additions & 0 deletions
31
...board/src/app/pages/job/overview/flamegraph/job-overview-drawer-flamegraph.component.less
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,31 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
|
||
nz-select { | ||
width: 300px; | ||
} | ||
|
||
.metric-selector { | ||
text-align: center; | ||
} | ||
|
||
:host { | ||
padding: 16px; | ||
display: block; | ||
} |
82 changes: 82 additions & 0 deletions
82
...shboard/src/app/pages/job/overview/flamegraph/job-overview-drawer-flamegraph.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,82 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Component, OnInit, ChangeDetectionStrategy, OnDestroy, ChangeDetectorRef } from '@angular/core'; | ||
import { Subject } from 'rxjs'; | ||
import { flatMap, takeUntil, tap } from 'rxjs/operators'; | ||
import { JobFlameGraphInterface, NodesItemCorrectInterface } from 'interfaces'; | ||
import { JobService } from 'services'; | ||
|
||
@Component({ | ||
selector: 'flink-job-overview-drawer-flamegraph', | ||
templateUrl: './job-overview-drawer-flamegraph.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
styleUrls: ['./job-overview-drawer-flamegraph.component.less'] | ||
}) | ||
export class JobOverviewDrawerFlameGraphComponent implements OnInit, OnDestroy { | ||
destroy$ = new Subject(); | ||
isLoading = true; | ||
now = Date.now(); | ||
selectedVertex: NodesItemCorrectInterface | null; | ||
flameGraph = {} as JobFlameGraphInterface; | ||
|
||
graphType = 'on_cpu'; | ||
|
||
constructor(private jobService: JobService, private cdr: ChangeDetectorRef) {} | ||
|
||
ngOnInit() { | ||
this.requestFlameGraph(); | ||
} | ||
|
||
private requestFlameGraph() { | ||
this.jobService.jobWithVertex$ | ||
.pipe( | ||
takeUntil(this.destroy$), | ||
tap(data => (this.selectedVertex = data.vertex)), | ||
flatMap(data => this.jobService.loadOperatorFlameGraph(data.job.jid, data.vertex!.id, this.graphType)) | ||
) | ||
.subscribe( | ||
data => { | ||
this.now = Date.now(); | ||
if (this.flameGraph.endTimestamp !== data['endTimestamp']) { | ||
this.isLoading = false; | ||
this.flameGraph = data; | ||
this.flameGraph.graphType = this.graphType; | ||
} | ||
this.cdr.markForCheck(); | ||
}, | ||
() => { | ||
this.isLoading = false; | ||
this.cdr.markForCheck(); | ||
} | ||
); | ||
} | ||
|
||
selectFrameGraphType() { | ||
this.destroy$.next(); | ||
this.destroy$.complete(); | ||
this.destroy$ = new Subject(); | ||
this.flameGraph = {} as JobFlameGraphInterface; | ||
this.requestFlameGraph(); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.destroy$.next(); | ||
this.destroy$.complete(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,4 @@ flink-job-overview-drawer { | |
display: block; | ||
position: relative; | ||
} | ||
|
Oops, something went wrong.