Skip to content

ref(platform-insights): Make duration chart loadable #92094

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
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions static/app/components/charts/chartWidgetLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ const CHART_MAP = {
import(
'sentry/views/insights/common/components/widgets/httpDomainSummaryDurationChartWidget'
),
overviewApiLatencyChartWidget: () =>
import(
'sentry/views/insights/common/components/widgets/overviewApiLatencyChartWidget'
),
} satisfies Record<string, () => Promise<{default: React.FC<LoadableChartWidgetProps>}>>;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {TimeSeriesWidgetVisualization} from 'sentry/views/dashboards/widgets/tim
import {Widget} from 'sentry/views/dashboards/widgets/widget/widget';
import {Mode} from 'sentry/views/explore/contexts/pageParamsContext/mode';
import {ChartType} from 'sentry/views/insights/common/components/chart';
import type {LoadableChartWidgetProps} from 'sentry/views/insights/common/components/widgets/types';
import {useEAPSeries} from 'sentry/views/insights/common/queries/useDiscoverSeries';
import {convertSeriesToTimeseries} from 'sentry/views/insights/common/utils/convertSeriesToTimeseries';
import {Referrer} from 'sentry/views/insights/pages/platform/laravel/referrers';
Expand All @@ -18,11 +19,13 @@ import {ModalChartContainer} from 'sentry/views/insights/pages/platform/shared/s
import {Toolbar} from 'sentry/views/insights/pages/platform/shared/toolbar';
import {useTransactionNameQuery} from 'sentry/views/insights/pages/platform/shared/useTransactionNameQuery';

export function DurationWidget() {
export default function OverviewApiLatencyChartWidget(props: LoadableChartWidgetProps) {
const organization = useOrganization();
const {query} = useTransactionNameQuery();
const pageFilterChartParams = usePageFilterChartParams();
const releaseBubbleProps = useReleaseBubbleProps();
const pageFilterChartParams = usePageFilterChartParams({
pageFilters: props.pageFilters,
});
const releaseBubbleProps = useReleaseBubbleProps(props);

const fullQuery = `span.op:http.server ${query}`.trim();

Expand All @@ -33,7 +36,8 @@ export function DurationWidget() {
yAxis: ['avg(span.duration)', 'p95(span.duration)'],
referrer: Referrer.DURATION_CHART,
},
Referrer.DURATION_CHART
Referrer.DURATION_CHART,
props.pageFilters
);

const plottables = useMemo(() => {
Expand All @@ -52,6 +56,7 @@ export function DurationWidget() {
isEmpty={isEmpty}
VisualizationType={TimeSeriesWidgetVisualization}
visualizationProps={{
id: 'overviewApiLatencyChartWidget',
plottables,
...releaseBubbleProps,
}}
Expand Down
10 changes: 8 additions & 2 deletions static/app/views/insights/common/queries/useDiscoverSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ export const useEAPSeries = <
| string[],
>(
options: UseMetricsSeriesOptions<Fields> = {},
referrer: string
referrer: string,
pageFilters?: PageFilters
) => {
return useDiscoverSeries<Fields>(options, DiscoverDatasets.SPANS_EAP_RPC, referrer);
return useDiscoverSeries<Fields>(
options,
DiscoverDatasets.SPANS_EAP_RPC,
referrer,
pageFilters
);
};

export const useMetricsSeries = <Fields extends MetricsProperty[]>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {limitMaxPickableDays} from 'sentry/views/explore/utils';
import * as ModuleLayout from 'sentry/views/insights/common/components/moduleLayout';
import {ToolRibbon} from 'sentry/views/insights/common/components/ribbon';
import {STARRED_SEGMENT_TABLE_QUERY_KEY} from 'sentry/views/insights/common/components/tableCells/starredSegmentCell';
import OverviewApiLatencyChartWidget from 'sentry/views/insights/common/components/widgets/overviewApiLatencyChartWidget';
import {useEAPSpans} from 'sentry/views/insights/common/queries/useDiscover';
import {useOnboardingProject} from 'sentry/views/insights/common/queries/useOnboardingProject';
import {useInsightsEap} from 'sentry/views/insights/common/utils/useEap';
Expand Down Expand Up @@ -56,7 +57,6 @@ import {
useIsNextJsInsightsEnabled,
} from 'sentry/views/insights/pages/platform/nextjs/features';
import {NewNextJsExperienceButton} from 'sentry/views/insights/pages/platform/nextjs/newNextjsExperienceToggle';
import {DurationWidget} from 'sentry/views/insights/pages/platform/shared/durationWidget';
import {IssuesWidget} from 'sentry/views/insights/pages/platform/shared/issuesWidget';
import {TrafficWidget} from 'sentry/views/insights/pages/platform/shared/trafficWidget';
import {TransactionNameSearchBar} from 'sentry/views/insights/pages/transactionNameSearchBar';
Expand Down Expand Up @@ -243,7 +243,7 @@ function EAPBackendOverviewPage() {
trafficSeriesName={t('Requests')}
baseQuery={'span.op:http.server'}
/>
<DurationWidget />
<OverviewApiLatencyChartWidget />
</StackedWidgetWrapper>
</ModuleLayout.Third>
<ModuleLayout.TwoThirds>
Expand Down
4 changes: 2 additions & 2 deletions static/app/views/insights/pages/platform/laravel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {useEffect} from 'react';
import {t} from 'sentry/locale';
import {trackAnalytics} from 'sentry/utils/analytics';
import useOrganization from 'sentry/utils/useOrganization';
import OverviewApiLatencyChartWidget from 'sentry/views/insights/common/components/widgets/overviewApiLatencyChartWidget';
import {CachesWidget} from 'sentry/views/insights/pages/platform/laravel/cachesWidget';
import {JobsWidget} from 'sentry/views/insights/pages/platform/laravel/jobsWidget';
import {QueriesWidget} from 'sentry/views/insights/pages/platform/laravel/queriesWidget';
import {DurationWidget} from 'sentry/views/insights/pages/platform/shared/durationWidget';
import {IssuesWidget} from 'sentry/views/insights/pages/platform/shared/issuesWidget';
import {PlatformLandingPageLayout} from 'sentry/views/insights/pages/platform/shared/layout';
import {PathsTable} from 'sentry/views/insights/pages/platform/shared/pathsTable';
Expand Down Expand Up @@ -34,7 +34,7 @@ export function LaravelOverviewPage() {
/>
</WidgetGrid.Position1>
<WidgetGrid.Position2>
<DurationWidget />
<OverviewApiLatencyChartWidget />
</WidgetGrid.Position2>
<WidgetGrid.Position3>
<IssuesWidget />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ import {useMemo} from 'react';

import {type Fidelity, getInterval} from 'sentry/components/charts/utils';
import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse';
import type {PageFilters} from 'sentry/types/core';
import usePageFilters from 'sentry/utils/usePageFilters';

export function usePageFilterChartParams({
granularity = 'spans',
pageFilters,
}: {
granularity?: Fidelity;
pageFilters?: PageFilters;
} = {}) {
const {selection} = usePageFilters();
const pageFilterContext = usePageFilters();
const selection = pageFilters || pageFilterContext.selection;

const normalizedDateTime = useMemo(
() => normalizeDateTimeParams(selection.datetime),
Expand Down
4 changes: 2 additions & 2 deletions static/app/views/insights/pages/platform/nextjs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {trackAnalytics} from 'sentry/utils/analytics';
import {useLocation} from 'sentry/utils/useLocation';
import {useNavigate} from 'sentry/utils/useNavigate';
import useOrganization from 'sentry/utils/useOrganization';
import OverviewApiLatencyChartWidget from 'sentry/views/insights/common/components/widgets/overviewApiLatencyChartWidget';
import {DeadRageClicksWidget} from 'sentry/views/insights/pages/platform/nextjs/deadRageClickWidget';
import SSRTreeWidget from 'sentry/views/insights/pages/platform/nextjs/ssrTreeWidget';
import {WebVitalsWidget} from 'sentry/views/insights/pages/platform/nextjs/webVitalsWidget';
import {DurationWidget} from 'sentry/views/insights/pages/platform/shared/durationWidget';
import {IssuesWidget} from 'sentry/views/insights/pages/platform/shared/issuesWidget';
import {PlatformLandingPageLayout} from 'sentry/views/insights/pages/platform/shared/layout';
import {PagesTable} from 'sentry/views/insights/pages/platform/shared/pagesTable';
Expand Down Expand Up @@ -97,7 +97,7 @@ export function NextJsOverviewPage({
/>
</WidgetGrid.Position1>
<WidgetGrid.Position2>
<DurationWidget />
<OverviewApiLatencyChartWidget />
</WidgetGrid.Position2>
<WidgetGrid.Position3>
<IssuesWidget />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import useOrganization from 'sentry/utils/useOrganization';
import usePageFilters from 'sentry/utils/usePageFilters';
import {useReleaseStats} from 'sentry/utils/useReleaseStats';
import type {LoadableChartWidgetProps} from 'sentry/views/insights/common/components/widgets/types';

export function useReleaseBubbleProps() {
type Params = Pick<LoadableChartWidgetProps, 'showReleaseAs'>;

export function useReleaseBubbleProps(params?: Params) {
const organization = useOrganization();
const pageFilters = usePageFilters();

Expand All @@ -14,6 +17,6 @@ export function useReleaseBubbleProps() {
})) ?? [];

return organization.features.includes('release-bubbles-ui')
? ({releases, showReleaseAs: 'bubble'} as const)
? ({releases, showReleaseAs: params?.showReleaseAs ?? 'bubble'} as const)
: {};
}
Loading