12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import type {LineChartProps} from 'sentry/components/charts/lineChart';
- import {transformToLineSeries} from 'sentry/components/charts/lineChart';
- import getBreakpointChartOptionsFromData, {
- type EventBreakpointChartData,
- } from 'sentry/components/events/eventStatisticalDetector/breakpointChartOptions';
- import type {EventsStatsSeries} from 'sentry/types';
- import {transformStatsResponse} from 'sentry/utils/profiling/hooks/utils';
- import {lightTheme as theme} from 'sentry/utils/theme';
- import type {NormalizedTrendsTransaction} from 'sentry/views/performance/trends/types';
- import {slackChartDefaults, slackChartSize} from './slack';
- import type {RenderDescriptor} from './types';
- import {ChartType} from './types';
- export const performanceCharts: RenderDescriptor<ChartType>[] = [];
- export type FunctionRegressionPercentileData = {
- data: EventsStatsSeries<'p95()'>;
- };
- function modifyOptionsForSlack(options: Omit<LineChartProps, 'series'>) {
- options.legend = options.legend || {};
- options.legend.icon = 'none';
- options.legend.left = '25';
- options.legend.top = '20';
- return {
- ...options,
- grid: slackChartDefaults.grid,
- visualMap: options.options?.visualMap,
- };
- }
- type FunctionRegressionChartData = {
- evidenceData: NormalizedTrendsTransaction;
- rawResponse: any;
- };
- performanceCharts.push({
- key: ChartType.SLACK_PERFORMANCE_ENDPOINT_REGRESSION,
- getOption: (data: EventBreakpointChartData) => {
- const {chartOptions, series} = getBreakpointChartOptionsFromData(
- data,
- ChartType.SLACK_PERFORMANCE_ENDPOINT_REGRESSION,
- theme
- );
- const transformedSeries = transformToLineSeries({series});
- const modifiedOptions = modifyOptionsForSlack(chartOptions);
- return {
- ...modifiedOptions,
- backgroundColor: theme.background,
- series: transformedSeries,
- grid: slackChartDefaults.grid,
- visualMap: modifiedOptions.options?.visualMap,
- };
- },
- ...slackChartSize,
- });
- performanceCharts.push({
- key: ChartType.SLACK_PERFORMANCE_FUNCTION_REGRESSION,
- getOption: (data: FunctionRegressionChartData) => {
- const transformed = transformStatsResponse(
- 'profileFunctions',
- ['p95()'],
- data.rawResponse
- );
- const percentileData = {
- data: transformed,
- };
- const param = {
- percentileData: percentileData as FunctionRegressionPercentileData,
- evidenceData: data.evidenceData,
- };
- const {chartOptions, series} = getBreakpointChartOptionsFromData(
- param,
- ChartType.SLACK_PERFORMANCE_FUNCTION_REGRESSION,
- theme
- );
- const transformedSeries = transformToLineSeries({series});
- const modifiedOptions = modifyOptionsForSlack(chartOptions);
- return {
- ...modifiedOptions,
- backgroundColor: theme.background,
- series: transformedSeries,
- grid: slackChartDefaults.grid,
- visualMap: modifiedOptions.options?.visualMap,
- };
- },
- ...slackChartSize,
- });
|