forked from kiali/kiali-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use heatmap in trace details (kiali#2016)
* Use heatmap in trace details Fixes kiali/kiali#3279 - Reduxify stats metrics for comparison with traces Same data will be use in several places, so redux is a convenient solution here - Refactor heatmap to use css grid layout instead of flex (flex doesn't work so well for two-axis grids). Heatmap style & structure is well simplified - Rename SpanItemData -> RichSpanData and make it computed directly in transformTraceData (sooner as before) - Create one heatmap from Metrics Stats as an aggregation of all span-based stats... - ...and another heatmap to replace the textual information we had, comparing trace stats with other traces displayed on screen * Create a heatmap of similar traces - Replace old list of similar with a heatmap. Merge the small 2x2 within that new one - Add a tooltip giving some explanations about the similarity algo * Add a couple of tests on trace stats Also move some code so that TraceStats (from utils) doesn't depend on StatsComparison (from components) * Responsive design for heatmaps Width is now capped with previously used width, but cells are auto-shrinked for smaller width
- Loading branch information
Showing
24 changed files
with
745 additions
and
470 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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ActionType, createAction } from 'typesafe-actions'; | ||
import { ActionKeys } from './ActionKeys'; | ||
import { MetricsStats } from 'types/Metrics'; | ||
|
||
export const MetricsStatsActions = { | ||
setStats: createAction(ActionKeys.METRICS_STATS_SET, resolve => (stats: Map<string, MetricsStats>) => | ||
resolve({ metricsStats: stats }) | ||
) | ||
}; | ||
|
||
export type MetricsStatsAction = ActionType<typeof MetricsStatsActions>; |
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,39 @@ | ||
import { ThunkDispatch } from 'redux-thunk'; | ||
import { KialiAppState } from '../store/Store'; | ||
import { KialiAppAction } from './KialiAppAction'; | ||
import * as API from '../services/Api'; | ||
import { MetricsStatsActions } from './MetricsStatsActions'; | ||
import { MetricsStatsQuery, statsQueryToKey } from 'types/MetricsOptions'; | ||
import { addError, addInfo } from 'utils/AlertUtils'; | ||
import { MetricsStats } from 'types/Metrics'; | ||
|
||
type ExpiringStats = MetricsStats & { timestamp: number }; | ||
|
||
const expiry = 2 * 60 * 1000; | ||
const MetricsStatsThunkActions = { | ||
load: (queries: MetricsStatsQuery[]) => { | ||
return (dispatch: ThunkDispatch<KialiAppState, void, KialiAppAction>, getState: () => KialiAppState) => { | ||
const oldStats = getState().metricsStats.data as Map<string, ExpiringStats>; | ||
const now = Date.now(); | ||
// Keep only queries for stats we don't already have | ||
const newStats = new Map(Array.from(oldStats).filter(([_, v]) => now - v.timestamp < expiry)); | ||
const filtered = queries.filter(q => !newStats.has(statsQueryToKey(q))); | ||
if (filtered.length > 0) { | ||
API.getMetricsStats(filtered) | ||
.then(res => { | ||
// Merge result | ||
Object.entries(res.data.stats).forEach(e => newStats.set(e[0], { ...e[1], timestamp: now })); | ||
dispatch(MetricsStatsActions.setStats(newStats)); | ||
if (res.data.warnings && res.data.warnings.length > 0) { | ||
addInfo(res.data.warnings.join('; '), false); | ||
} | ||
}) | ||
.catch(err => { | ||
addError('Could not fetch metrics stats.', err); | ||
}); | ||
} | ||
}; | ||
} | ||
}; | ||
|
||
export default MetricsStatsThunkActions; |
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.