|
@@ -6,17 +6,19 @@ import {Panel} from 'sentry/components/panels';
|
|
|
import Placeholder from 'sentry/components/placeholder';
|
|
|
import {space} from 'sentry/styles/space';
|
|
|
import {PageFilters} from 'sentry/types';
|
|
|
-import {Series} from 'sentry/types/echarts';
|
|
|
+import {Series, SeriesDataUnit} from 'sentry/types/echarts';
|
|
|
+import {defined} from 'sentry/utils';
|
|
|
import {useDiscoverQuery} from 'sentry/utils/discover/discoverQuery';
|
|
|
import EventView from 'sentry/utils/discover/eventView';
|
|
|
import {DiscoverDatasets} from 'sentry/utils/discover/types';
|
|
|
import {useLocation} from 'sentry/utils/useLocation';
|
|
|
import useOrganization from 'sentry/utils/useOrganization';
|
|
|
import usePageFilters from 'sentry/utils/usePageFilters';
|
|
|
-import {useWrappedDiscoverTimeseriesQuery} from 'sentry/views/starfish/utils/useSpansQuery';
|
|
|
+import {useEventsStatsQuery} from 'sentry/views/starfish/utils/useEventsStatsQuery';
|
|
|
import {SpanGroupBreakdown} from 'sentry/views/starfish/views/webServiceView/spanGroupBreakdown';
|
|
|
|
|
|
export const OTHER_SPAN_GROUP_MODULE = 'Other';
|
|
|
+export const NULL_SPAN_CATEGORY = '<null>';
|
|
|
|
|
|
type Props = {
|
|
|
transaction?: string;
|
|
@@ -45,21 +47,21 @@ export function SpanGroupBreakdownContainer({transaction, transactionMethod}: Pr
|
|
|
const theme = useTheme();
|
|
|
|
|
|
const {data: segments, isLoading: isSegmentsLoading} = useDiscoverQuery({
|
|
|
- eventView: getEventView(
|
|
|
+ eventView: getCumulativeTimeEventView(
|
|
|
selection,
|
|
|
- // TODO: Fix has:span.category in the backend
|
|
|
- `transaction.op:http.server has:span.category ${
|
|
|
- transaction ? `transaction:${transaction}` : ''
|
|
|
- } ${transactionMethod ? `http.method:${transactionMethod}` : ''}`,
|
|
|
+ `transaction.op:http.server ${transaction ? `transaction:${transaction}` : ''} ${
|
|
|
+ transactionMethod ? `http.method:${transactionMethod}` : ''
|
|
|
+ }`,
|
|
|
['span.category']
|
|
|
),
|
|
|
orgSlug: organization.slug,
|
|
|
+ referrer: 'starfish-web-service.span-category-breakdown',
|
|
|
location,
|
|
|
limit: 4,
|
|
|
});
|
|
|
|
|
|
- const {data: cumulativeTime} = useDiscoverQuery({
|
|
|
- eventView: getEventView(
|
|
|
+ const {data: cumulativeTime, isLoading: isCumulativeDataLoading} = useDiscoverQuery({
|
|
|
+ eventView: getCumulativeTimeEventView(
|
|
|
selection,
|
|
|
`transaction.op:http.server ${transaction ? `transaction:${transaction}` : ''} ${
|
|
|
transactionMethod ? `http.method:${transactionMethod}` : ''
|
|
@@ -67,22 +69,32 @@ export function SpanGroupBreakdownContainer({transaction, transactionMethod}: Pr
|
|
|
[]
|
|
|
),
|
|
|
orgSlug: organization.slug,
|
|
|
+ referrer: 'starfish-web-service.total-time',
|
|
|
location,
|
|
|
});
|
|
|
|
|
|
- const {isLoading: isTopDataLoading, data: topData} = useWrappedDiscoverTimeseriesQuery({
|
|
|
+ const {isLoading: isTopDataLoading, data: topData} = useEventsStatsQuery({
|
|
|
eventView: getEventView(
|
|
|
selection,
|
|
|
- `transaction.op:http.server has:span.category ${
|
|
|
- transaction ? `transaction:${transaction}` : ''
|
|
|
- } ${transactionMethod ? `http.method:${transactionMethod}` : ''}`,
|
|
|
+ `transaction.op:http.server ${transaction ? `transaction:${transaction}` : ''} ${
|
|
|
+ transactionMethod ? `http.method:${transactionMethod}` : ''
|
|
|
+ }`,
|
|
|
['span.category'],
|
|
|
true
|
|
|
),
|
|
|
+ enabled: true,
|
|
|
+ referrer: 'starfish-web-service.span-category-breakdown-timeseries',
|
|
|
initialData: [],
|
|
|
});
|
|
|
|
|
|
- if (!segments?.data || !cumulativeTime?.data || topData.length === 0) {
|
|
|
+ if (
|
|
|
+ isSegmentsLoading ||
|
|
|
+ isCumulativeDataLoading ||
|
|
|
+ isTopDataLoading ||
|
|
|
+ !defined(segments) ||
|
|
|
+ !defined(cumulativeTime) ||
|
|
|
+ !defined(topData)
|
|
|
+ ) {
|
|
|
return <Placeholder height="285px" />;
|
|
|
}
|
|
|
|
|
@@ -101,10 +113,11 @@ export function SpanGroupBreakdownContainer({transaction, transactionMethod}: Pr
|
|
|
|
|
|
for (let index = 0; index < segments.data.length; index++) {
|
|
|
const element = segments.data[index];
|
|
|
+ const category = element['span.category'] as string;
|
|
|
transformedData.push({
|
|
|
cumulativeTime: parseInt(element['sum(span.duration)'] as string, 10),
|
|
|
group: {
|
|
|
- 'span.category': element['span.category'] as string,
|
|
|
+ 'span.category': category === '' ? NULL_SPAN_CATEGORY : category,
|
|
|
},
|
|
|
});
|
|
|
}
|
|
@@ -121,21 +134,24 @@ export function SpanGroupBreakdownContainer({transaction, transactionMethod}: Pr
|
|
|
const seriesByDomain: {[category: string]: Series} = {};
|
|
|
const colorPalette = theme.charts.getColorPalette(transformedData.length - 2);
|
|
|
|
|
|
- if (!isTopDataLoading && topData.length > 0 && transformedData.length > 0) {
|
|
|
+ if (!isTopDataLoading && transformedData.length > 0) {
|
|
|
transformedData.forEach((segment, index) => {
|
|
|
- const label = segment.group['span.category'];
|
|
|
+ const category = segment.group['span.category'] as string;
|
|
|
+ const label = category === '' ? NULL_SPAN_CATEGORY : category;
|
|
|
seriesByDomain[label] = {
|
|
|
- seriesName: `${label}`,
|
|
|
+ seriesName: label,
|
|
|
data: [],
|
|
|
color: colorPalette[index],
|
|
|
};
|
|
|
});
|
|
|
|
|
|
- topData.forEach(value => {
|
|
|
- seriesByDomain[value.group].data.push({
|
|
|
- value: value['p95(span.duration)'],
|
|
|
- name: value.interval,
|
|
|
- });
|
|
|
+ Object.keys(topData).forEach(key => {
|
|
|
+ const seriesData = topData?.[key];
|
|
|
+ const label = key === '' ? NULL_SPAN_CATEGORY : key;
|
|
|
+ seriesByDomain[label].data =
|
|
|
+ seriesData?.data.map(datum => {
|
|
|
+ return {name: datum[0], value: datum[1][0].count} as SeriesDataUnit;
|
|
|
+ }) ?? [];
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -174,7 +190,7 @@ const getEventView = (
|
|
|
return EventView.fromSavedQuery({
|
|
|
name: '',
|
|
|
fields: ['sum(span.duration)', 'p95(span.duration)', ...groups],
|
|
|
- yAxis: getTimeseries ? ['sum(span.duration)', 'p95(span.duration)'] : [],
|
|
|
+ yAxis: getTimeseries ? ['p95(span.duration)'] : [],
|
|
|
query,
|
|
|
dataset: DiscoverDatasets.SPANS_METRICS,
|
|
|
start: pageFilters.datetime.start ?? undefined,
|
|
@@ -187,3 +203,23 @@ const getEventView = (
|
|
|
interval: getTimeseries ? getInterval(pageFilters.datetime, 'low') : undefined,
|
|
|
});
|
|
|
};
|
|
|
+
|
|
|
+const getCumulativeTimeEventView = (
|
|
|
+ pageFilters: PageFilters,
|
|
|
+ query: string,
|
|
|
+ groups: string[]
|
|
|
+) => {
|
|
|
+ return EventView.fromSavedQuery({
|
|
|
+ name: '',
|
|
|
+ fields: ['sum(span.duration)', ...groups],
|
|
|
+ query,
|
|
|
+ dataset: DiscoverDatasets.SPANS_METRICS,
|
|
|
+ start: pageFilters.datetime.start ?? undefined,
|
|
|
+ end: pageFilters.datetime.end ?? undefined,
|
|
|
+ range: pageFilters.datetime.period ?? undefined,
|
|
|
+ orderby: '-sum_span_duration',
|
|
|
+ projects: [1],
|
|
|
+ version: 2,
|
|
|
+ topEvents: groups.length > 0 ? '4' : undefined,
|
|
|
+ });
|
|
|
+};
|