-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(aci): Register new metric detector chartcuterie chart in frontend #101171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
malwilley
merged 1 commit into
master
from
malwilley/feat/metric-detector-chartcuterie-fe
Oct 8, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,129 @@ | ||
import type {Theme} from '@emotion/react'; | ||
import type {LineSeriesOption, YAXisComponentOption} from 'echarts'; | ||
|
||
import type {AreaChartSeries} from 'sentry/components/charts/areaChart'; | ||
import XAxis from 'sentry/components/charts/components/xAxis'; | ||
import AreaSeries from 'sentry/components/charts/series/areaSeries'; | ||
import type {SessionApiResponse} from 'sentry/types/organization'; | ||
import { | ||
getMetricDetectorChartOption, | ||
transformSessionResponseToSeries, | ||
type MetricDetectorChartData, | ||
} from 'sentry/views/detectors/components/details/metric/charts/metricDetectorChartOptions'; | ||
|
||
import {DEFAULT_FONT_FAMILY, makeSlackChartDefaults, slackChartSize} from './slack'; | ||
import type {RenderDescriptor} from './types'; | ||
import {ChartType} from './types'; | ||
|
||
function transformAreaSeries(series: AreaChartSeries[]): LineSeriesOption[] { | ||
return series.map(({seriesName, data, ...otherSeriesProps}) => { | ||
const areaSeries = AreaSeries({ | ||
name: seriesName, | ||
data: data.map(({name, value}) => [name, value]), | ||
lineStyle: { | ||
opacity: 1, | ||
width: 0.4, | ||
}, | ||
areaStyle: { | ||
opacity: 1.0, | ||
}, | ||
animation: false, | ||
animationThreshold: 1, | ||
animationDuration: 0, | ||
...otherSeriesProps, | ||
}); | ||
|
||
// Fix incident label font family, cannot use Rubik | ||
if (areaSeries.markLine?.label) { | ||
areaSeries.markLine.label.fontFamily = DEFAULT_FONT_FAMILY; | ||
} | ||
|
||
return areaSeries; | ||
}); | ||
} | ||
|
||
export function makeMetricDetectorCharts( | ||
theme: Theme | ||
): Array<RenderDescriptor<ChartType>> { | ||
const slackChartDefaults = makeSlackChartDefaults(theme); | ||
const metricDetectorCharts: Array<RenderDescriptor<ChartType>> = []; | ||
|
||
const metricDetectorXaxis = XAxis({ | ||
theme, | ||
splitNumber: 3, | ||
isGroupedByDate: true, | ||
axisLabel: {fontSize: 11, fontFamily: DEFAULT_FONT_FAMILY}, | ||
}); | ||
const metricDetectorYaxis: YAXisComponentOption = { | ||
axisLabel: {fontSize: 11, fontFamily: DEFAULT_FONT_FAMILY}, | ||
splitLine: { | ||
lineStyle: { | ||
color: theme.chartLineColor, | ||
opacity: 0.3, | ||
}, | ||
}, | ||
}; | ||
|
||
metricDetectorCharts.push({ | ||
key: ChartType.SLACK_METRIC_DETECTOR_EVENTS, | ||
getOption: (data: MetricDetectorChartData) => { | ||
const {chartOption} = getMetricDetectorChartOption(data, theme); | ||
|
||
return { | ||
...chartOption, | ||
backgroundColor: theme.background, | ||
series: transformAreaSeries(chartOption.series), | ||
xAxis: metricDetectorXaxis, | ||
yAxis: { | ||
...chartOption.yAxis, | ||
...metricDetectorYaxis, | ||
axisLabel: { | ||
...chartOption.yAxis!.axisLabel, | ||
...metricDetectorYaxis.axisLabel, | ||
}, | ||
}, | ||
grid: slackChartDefaults.grid, | ||
}; | ||
}, | ||
...slackChartSize, | ||
}); | ||
|
||
interface MetricDetectorSessionData | ||
extends Omit<MetricDetectorChartData, 'timeseriesData'> { | ||
sessionResponse: SessionApiResponse; | ||
} | ||
|
||
metricDetectorCharts.push({ | ||
key: ChartType.SLACK_METRIC_DETECTOR_SESSIONS, | ||
getOption: (data: MetricDetectorSessionData) => { | ||
const {sessionResponse, detector, ...rest} = data; | ||
const {chartOption} = getMetricDetectorChartOption( | ||
{ | ||
...rest, | ||
detector, | ||
timeseriesData: transformSessionResponseToSeries(sessionResponse, detector), | ||
}, | ||
theme | ||
); | ||
|
||
return { | ||
...chartOption, | ||
backgroundColor: theme.background, | ||
series: transformAreaSeries(chartOption.series), | ||
xAxis: metricDetectorXaxis, | ||
yAxis: { | ||
...chartOption.yAxis, | ||
...metricDetectorYaxis, | ||
axisLabel: { | ||
...chartOption.yAxis!.axisLabel, | ||
...metricDetectorYaxis.axisLabel, | ||
}, | ||
}, | ||
grid: slackChartDefaults.grid, | ||
}; | ||
}, | ||
...slackChartSize, | ||
}); | ||
|
||
return metricDetectorCharts; | ||
} |
This file contains hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Null Handling Breaks Chart Options
Removing
| null
fromSnubaQueryDataSource.queryObj
is a breaking change. If existing code or backend responses providenull
values, the new chart options code inmetricDetectorChartOptions.tsx
will encounter runtime errors when accessingdataSource.queryObj.snubaQuery
.Additional Locations (1)
static/app/views/detectors/components/details/metric/charts/metricDetectorChartOptions.tsx#L172-L173