Skip to content
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

feat(insights): implement geo region selector in web vitals and assets #76185

Merged
merged 5 commits into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ const {
HTTP_RESPONSE_CONTENT_LENGTH,
PROJECT_ID,
FILE_EXTENSION,
USER_GEO_SUBREGION,
} = SpanMetricsField;

const {TIME_SPENT_PERCENTAGE} = SpanFunction;
@@ -49,6 +50,9 @@ export const getResourcesEventViewQuery = (
...(resourceFilters.transaction
? [`transaction:"${resourceFilters.transaction}"`]
: []),
...(resourceFilters[USER_GEO_SUBREGION]
? [`user.geo.subregion:[${resourceFilters[USER_GEO_SUBREGION]}]`]
: []),
...getDomainFilter(resourceFilters[SPAN_DOMAIN]),
...(resourceFilters[RESOURCE_RENDER_BLOCKING_STATUS]
? [
Original file line number Diff line number Diff line change
@@ -45,6 +45,11 @@ function ResourceSummaryCharts(props: {groupId: string}) {
filters[RESOURCE_RENDER_BLOCKING_STATUS],
}
: {}),
...(filters[SpanMetricsField.USER_GEO_SUBREGION]
? {
[SpanMetricsField.USER_GEO_SUBREGION]: `[${filters[SpanMetricsField.USER_GEO_SUBREGION].join(',')}]`,
}
: {}),
}),
yAxis: [
`spm()`,
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ const {
SPAN_DOMAIN,
TRANSACTION,
RESOURCE_RENDER_BLOCKING_STATUS,
USER_GEO_SUBREGION,
} = BrowserStarfishFields;

type Option = {
@@ -52,7 +53,12 @@ function ResourceView() {
...(filters[SPAN_DOMAIN] ? {[SPAN_DOMAIN]: filters[SPAN_DOMAIN]} : {}),
};

const extraQuery = getResourceTypeFilter(undefined, DEFAULT_RESOURCE_TYPES);
const extraQuery = [
...getResourceTypeFilter(undefined, DEFAULT_RESOURCE_TYPES),
...(filters[USER_GEO_SUBREGION]
? [`user.geo.subregion:[${filters[USER_GEO_SUBREGION].join(',')}]`]
: []),
];

return (
<Fragment>
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ const {
SPAN_SELF_TIME,
HTTP_RESPONSE_CONTENT_LENGTH,
TRANSACTION,
USER_GEO_SUBREGION,
} = SpanMetricsField;

type Row = {
@@ -55,6 +56,7 @@ function ResourceSummaryTable() {
const {data, isLoading, pageLinks} = useResourcePagesQuery(groupId, {
sort,
cursor,
subregions: filters[USER_GEO_SUBREGION],
renderBlockingStatus: filters[RESOURCE_RENDER_BLOCKING_STATUS],
});

Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ import {
RESOURCE_THROUGHPUT_UNIT,
} from 'sentry/views/insights/browser/resources/settings';
import {ResourceSpanOps} from 'sentry/views/insights/browser/resources/types';
import {useResourceModuleFilters} from 'sentry/views/insights/browser/resources/utils/useResourceFilters';
import type {ValidSort} from 'sentry/views/insights/browser/resources/utils/useResourceSort';
import {DurationCell} from 'sentry/views/insights/common/components/tableCells/durationCell';
import {renderHeadCell} from 'sentry/views/insights/common/components/tableCells/renderHeadCell';
@@ -79,6 +80,7 @@ function ResourceTable({sort, defaultResourceTypes}: Props) {
const location = useLocation();
const organization = useOrganization();
const cursor = decodeScalar(location.query?.[QueryParameterNames.SPANS_CURSOR]);
const filters = useResourceModuleFilters();
const {setPageInfo, pageAlert} = usePageAlert();

const {data, isLoading, pageLinks} = useResourcesQuery({
@@ -130,7 +132,11 @@ function ResourceTable({sort, defaultResourceTypes}: Props) {

if (key === SPAN_DESCRIPTION) {
const fileExtension = row[SPAN_DESCRIPTION].split('.').pop() || '';

const extraLinkQueryParams = {};
if (filters[SpanMetricsField.USER_GEO_SUBREGION]) {
extraLinkQueryParams[SpanMetricsField.USER_GEO_SUBREGION] =
filters[SpanMetricsField.USER_GEO_SUBREGION];
}
return (
<DescriptionWrapper>
<ResourceIcon fileExtension={fileExtension} spanOp={row[SPAN_OP]} />
@@ -140,6 +146,7 @@ function ResourceTable({sort, defaultResourceTypes}: Props) {
spanOp={row[SPAN_OP]}
description={row[SPAN_DESCRIPTION]}
group={row[SPAN_GROUP]}
extraLinkQueryParams={extraLinkQueryParams}
/>
</DescriptionWrapper>
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {Sort} from 'sentry/utils/discover/fields';
import {useSpanTransactionMetrics} from 'sentry/views/insights/common/queries/useSpanTransactionMetrics';
import {SpanMetricsField} from 'sentry/views/insights/types';
import {SpanMetricsField, type SubregionCode} from 'sentry/views/insights/types';

const {HTTP_RESPONSE_CONTENT_LENGTH, RESOURCE_RENDER_BLOCKING_STATUS} = SpanMetricsField;

@@ -9,15 +9,24 @@ export const useResourcePagesQuery = (
{
sort,
cursor,
subregions,
renderBlockingStatus,
}: {sort: Sort; cursor?: string; renderBlockingStatus?: string}
}: {
sort: Sort;
cursor?: string;
renderBlockingStatus?: string;
subregions?: SubregionCode[];
}
) => {
return useSpanTransactionMetrics(
{
'span.group': groupId,
...(renderBlockingStatus
? {[RESOURCE_RENDER_BLOCKING_STATUS]: renderBlockingStatus}
: {}),
...(subregions
? {[SpanMetricsField.USER_GEO_SUBREGION]: `[${subregions.join(',')}]`}
: {}),
},
[sort],
cursor,
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import pick from 'lodash/pick';

import {decodeList} from 'sentry/utils/queryString';
import {useLocation} from 'sentry/utils/useLocation';
import type {ResourceSpanOps} from 'sentry/views/insights/browser/resources/types';
import type {SubregionCode} from 'sentry/views/insights/types';

// TODO - we should probably just use SpanMetricsField here
export enum BrowserStarfishFields {
SPAN_OP = 'span.op',
TRANSACTION = 'transaction',
SPAN_DOMAIN = 'span.domain',
GROUP_ID = 'groupId',
DESCRIPTION = 'description',
RESOURCE_RENDER_BLOCKING_STATUS = 'resource.render_blocking_status',
USER_GEO_SUBREGION = 'user.geo.subregion',
}

export type ModuleFilters = {
@@ -22,17 +26,27 @@ export type ModuleFilters = {
[BrowserStarfishFields.SPAN_OP]?: ResourceSpanOps;
[BrowserStarfishFields.TRANSACTION]?: string;
[BrowserStarfishFields.SPAN_DOMAIN]?: string;
[BrowserStarfishFields.USER_GEO_SUBREGION]?: SubregionCode[];
};

export const useResourceModuleFilters = () => {
const location = useLocation<ModuleFilters>();

return pick(location.query, [
const filters = pick(location.query, [
BrowserStarfishFields.SPAN_DOMAIN,
BrowserStarfishFields.SPAN_OP,
BrowserStarfishFields.TRANSACTION,
BrowserStarfishFields.GROUP_ID,
BrowserStarfishFields.DESCRIPTION,
BrowserStarfishFields.RESOURCE_RENDER_BLOCKING_STATUS,
]);

const subregions = decodeList(
location.query[BrowserStarfishFields.USER_GEO_SUBREGION]
) as SubregionCode[];
if (subregions.length) {
filters[BrowserStarfishFields.USER_GEO_SUBREGION] = subregions;
}

return filters;
};
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ import {ToolRibbon} from 'sentry/views/insights/common/components/ribbon';
import {useSpanMetrics} from 'sentry/views/insights/common/queries/useDiscover';
import {useModuleBreadcrumbs} from 'sentry/views/insights/common/utils/useModuleBreadcrumbs';
import {useModuleURL} from 'sentry/views/insights/common/utils/useModuleURL';
import SubregionSelector from 'sentry/views/insights/common/views/spans/selectors/subregionSelector';
import {SampleList} from 'sentry/views/insights/common/views/spanSummaryPage/sampleList';
import {ModuleName, SpanMetricsField} from 'sentry/views/insights/types';
import {TraceViewSources} from 'sentry/views/performance/newTraceDetails/traceMetadataHeader';
@@ -55,6 +56,11 @@ function ResourceSummary() {
{
search: MutableSearch.fromQueryObject({
'span.group': groupId,
...(filters[SpanMetricsField.USER_GEO_SUBREGION]
? {
[SpanMetricsField.USER_GEO_SUBREGION]: `[${filters[SpanMetricsField.USER_GEO_SUBREGION].join(',')}]`,
}
: {}),
}),
fields: [
`avg(${SPAN_SELF_TIME})`,
@@ -123,6 +129,7 @@ function ResourceSummary() {
<RenderBlockingSelector
value={filters[RESOURCE_RENDER_BLOCKING_STATUS] || ''}
/>
<SubregionSelector />
</ToolRibbon>
<ResourceInfo
isLoading={isLoading}
@@ -154,6 +161,7 @@ function ResourceSummary() {
<ModuleLayout.Full>
<SampleList
transactionRoute={webVitalsModuleURL}
subregions={filters[SpanMetricsField.USER_GEO_SUBREGION]}
groupId={groupId}
moduleName={ModuleName.RESOURCE}
transactionName={transaction as string}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {Fragment} from 'react';
import styled from '@emotion/styled';

import {Breadcrumbs} from 'sentry/components/breadcrumbs';
@@ -27,6 +27,7 @@ import {ModulesOnboarding} from 'sentry/views/insights/common/components/modules
import {ToolRibbon} from 'sentry/views/insights/common/components/ribbon';
import {useModuleBreadcrumbs} from 'sentry/views/insights/common/utils/useModuleBreadcrumbs';
import {DomainSelector} from 'sentry/views/insights/common/views/spans/selectors/domainSelector';
import SubregionSelector from 'sentry/views/insights/common/views/spans/selectors/subregionSelector';
import {ModuleName} from 'sentry/views/insights/types';

const {SPAN_OP, SPAN_DOMAIN} = BrowserStarfishFields;
@@ -64,15 +65,18 @@ function ResourcesLandingPage() {
<ModulePageFilterBar
moduleName={ModuleName.RESOURCE}
extraFilters={
<DomainSelector
moduleName={ModuleName.RESOURCE}
emptyOptionLocation="top"
value={filters[SPAN_DOMAIN] || ''}
additionalQuery={[
...DEFAULT_RESOURCE_FILTERS,
`${SPAN_OP}:[${DEFAULT_RESOURCE_TYPES.join(',')}]`,
]}
/>
<Fragment>
<DomainSelector
moduleName={ModuleName.RESOURCE}
emptyOptionLocation="top"
value={filters[SPAN_DOMAIN] || ''}
additionalQuery={[
...DEFAULT_RESOURCE_FILTERS,
`${SPAN_OP}:[${DEFAULT_RESOURCE_TYPES.join(',')}]`,
]}
/>
<SubregionSelector />
</Fragment>
}
/>
</ToolRibbon>
Original file line number Diff line number Diff line change
@@ -15,9 +15,11 @@ import {applyStaticWeightsToTimeseries} from 'sentry/views/insights/browser/webV
import type {BrowserType} from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
import {PERFORMANCE_SCORE_WEIGHTS} from 'sentry/views/insights/browser/webVitals/utils/scoreThresholds';
import Chart, {ChartType} from 'sentry/views/insights/common/components/chart';
import type {SubregionCode} from 'sentry/views/insights/types';

type Props = {
browserTypes?: BrowserType[];
subregions?: SubregionCode[];
transaction?: string;
};

@@ -43,14 +45,18 @@ export const formatTimeSeriesResultsToChartData = (
});
};

export function PerformanceScoreBreakdownChart({transaction, browserTypes}: Props) {
export function PerformanceScoreBreakdownChart({
transaction,
browserTypes,
subregions,
}: Props) {
const theme = useTheme();
const segmentColors = [...theme.charts.getColorPalette(3).slice(0, 5)];

const pageFilters = usePageFilters();

const {data: timeseriesData, isLoading: isTimeseriesLoading} =
useProjectWebVitalsScoresTimeseriesQuery({transaction, browserTypes});
useProjectWebVitalsScoresTimeseriesQuery({transaction, browserTypes, subregions});

const period = pageFilters.selection.datetime.period;
const performanceScoreSubtext = (period && DEFAULT_RELATIVE_PERIODS[period]) ?? '';
Original file line number Diff line number Diff line change
@@ -17,11 +17,13 @@ import type {
WebVitals,
} from 'sentry/views/insights/browser/webVitals/types';
import type {BrowserType} from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
import type {SubregionCode} from 'sentry/views/insights/types';

type Props = {
browserTypes?: BrowserType[];
isProjectScoreLoading?: boolean;
projectScore?: ProjectScore;
subregions?: SubregionCode[];
transaction?: string;
webVital?: WebVitals | null;
};
@@ -34,6 +36,7 @@ export function PerformanceScoreChart({
transaction,
isProjectScoreLoading,
browserTypes,
subregions,
}: Props) {
const theme = useTheme();
const pageFilters = usePageFilters();
@@ -100,6 +103,7 @@ export function PerformanceScoreChart({
<PerformanceScoreBreakdownChart
transaction={transaction}
browserTypes={browserTypes}
subregions={subregions}
/>
</Flex>
);
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ import {useProjectRawWebVitalsValuesTimeseriesQuery} from 'sentry/views/insights
import {MODULE_DOC_LINK} from 'sentry/views/insights/browser/webVitals/settings';
import type {ProjectScore} from 'sentry/views/insights/browser/webVitals/types';
import type {BrowserType} from 'sentry/views/insights/browser/webVitals/utils/queryParameterDecoders/browserType';
import type {SubregionCode} from 'sentry/views/insights/types';
import {SidebarSpacer} from 'sentry/views/performance/transactionSummary/utils';

const CHART_HEIGHTS = 100;
@@ -32,13 +33,15 @@ type Props = {
projectScore?: ProjectScore;
projectScoreIsLoading?: boolean;
search?: string;
subregions?: SubregionCode[];
};

export function PageOverviewSidebar({
projectScore,
transaction,
projectScoreIsLoading,
browserTypes,
subregions,
}: Props) {
const theme = useTheme();
const router = useRouter();
@@ -62,6 +65,7 @@ export function PageOverviewSidebar({
transaction,
datetime: doubledDatetime,
browserTypes,
subregions,
});

const {countDiff, currentSeries, currentCount, initialCount} = processSeriesData(
Loading