import {t} from 'sentry/locale'; import {formatBytesBase2} from 'sentry/utils'; import {formatRate} from 'sentry/utils/formatters'; import getDynamicText from 'sentry/utils/getDynamicText'; import {MutableSearch} from 'sentry/utils/tokenizeSearch'; import {RESOURCE_THROUGHPUT_UNIT} from 'sentry/views/performance/browser/resources'; import {Referrer} from 'sentry/views/performance/browser/resources/referrer'; import {useResourceModuleFilters} from 'sentry/views/performance/browser/resources/utils/useResourceFilters'; import {AVG_COLOR, THROUGHPUT_COLOR} from 'sentry/views/starfish/colors'; import Chart, {ChartType} from 'sentry/views/starfish/components/chart'; import ChartPanel from 'sentry/views/starfish/components/chartPanel'; import {useSpanMetricsSeries} from 'sentry/views/starfish/queries/useDiscoverSeries'; import {SpanMetricsField} from 'sentry/views/starfish/types'; import { DataTitles, getDurationChartTitle, getThroughputChartTitle, } from 'sentry/views/starfish/views/spans/types'; import {Block, BlockContainer} from 'sentry/views/starfish/views/spanSummaryPage/block'; const { SPAN_SELF_TIME, HTTP_RESPONSE_CONTENT_LENGTH, HTTP_DECODED_RESPONSE_CONTENT_LENGTH, HTTP_RESPONSE_TRANSFER_SIZE, RESOURCE_RENDER_BLOCKING_STATUS, } = SpanMetricsField; function ResourceSummaryCharts(props: {groupId: string}) { const filters = useResourceModuleFilters(); const {data: spanMetricsSeriesData, isLoading: areSpanMetricsSeriesLoading} = useSpanMetricsSeries( { search: MutableSearch.fromQueryObject({ 'span.group': props.groupId, ...(filters[RESOURCE_RENDER_BLOCKING_STATUS] ? { [RESOURCE_RENDER_BLOCKING_STATUS]: filters[RESOURCE_RENDER_BLOCKING_STATUS], } : {}), }), yAxis: [ `spm()`, `avg(${SPAN_SELF_TIME})`, `avg(${HTTP_RESPONSE_CONTENT_LENGTH})`, `avg(${HTTP_DECODED_RESPONSE_CONTENT_LENGTH})`, `avg(${HTTP_RESPONSE_TRANSFER_SIZE})`, ], enabled: Boolean(props.groupId), }, Referrer.RESOURCE_SUMMARY_CHARTS ); if (spanMetricsSeriesData) { spanMetricsSeriesData[`avg(${HTTP_RESPONSE_TRANSFER_SIZE})`].lineStyle = { type: 'dashed', }; spanMetricsSeriesData[`avg(${HTTP_DECODED_RESPONSE_CONTENT_LENGTH})`].lineStyle = { type: 'dashed', }; } return ( formatRate(value, RESOURCE_THROUGHPUT_UNIT), nameFormatter: () => t('Requests'), }} /> getDynamicText({ value: formatBytesBase2(bytes), fixed: 'xx KiB', }), nameFormatter: name => DataTitles[name], }} /> ); } export default ResourceSummaryCharts;