Skip to content

ref(insights): Refactor Resource Summary + Landing charts into separate modules #89612

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 7 commits into from
Apr 22, 2025

Conversation

billyvg
Copy link
Member

@billyvg billyvg commented Apr 15, 2025

Part of #88560

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 15, 2025
@billyvg billyvg changed the title ref(insights): Refactor ResourceSummaryCharts into separate modules ref(insights): Refactor Resource Summary + Landing charts into separate modules Apr 15, 2025
@billyvg billyvg force-pushed the ref-insights-combine-widgets-browser-resources branch from 3255226 to 5da6791 Compare April 15, 2025 16:10
@billyvg
Copy link
Member Author

billyvg commented Apr 15, 2025

@codecov-ai-reviewer review

Copy link

codecov-ai bot commented Apr 15, 2025

On it! We are reviewing the PR and will provide feedback shortly.

Comment on lines +23 to +29
if (data) {
data[`avg(${HTTP_RESPONSE_TRANSFER_SIZE})`].lineStyle = {
type: 'dashed',
};
data[`avg(${HTTP_DECODED_RESPONSE_CONTENT_LENGTH})`].lineStyle = {
type: 'dashed',
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line style modifications directly mutate the data object. It's better to create a new transformed series object to maintain data immutability.

Comment on lines +16 to +21
{...props}
id="resourceLandingDurationChartWidget"
title={getDurationChartTitle('resource')}
series={[data[`avg(${SPAN_SELF_TIME})`]]}
isLoading={isPending}
error={error}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a useCallback for the series array construction to prevent unnecessary re-renders in the InsightsLineChartWidget component.

Comment on lines -64 to -65
appliedFilters={spanTimeChartsFilters}
extraQuery={extraQuery}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved these into the new widget

@@ -155,7 +155,7 @@ function ResourceSummary() {
</ModuleLayout.Full>
)}

<ResourceSummaryCharts groupId={groupId!} />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved into widget, groupId comes from URL params - currently drawer is directly tied to the chart/page where it was opened, so i think it's fine to have the widget grab this from the URL/router. if there was some world where we would render these charts separate independently, then we'd need to refactor to allow a way to specify the required properties that we'd need to add to the URL for linking and for rendering.

Comment on lines 13 to 14
const {SPAN_SELF_TIME, NORMALIZED_DESCRIPTION, SPAN_DOMAIN} = SpanMetricsField;
const {SPAN_DOMAIN: STARFISH_SPAN_DOMAIN, USER_GEO_SUBREGION} = BrowserStarfishFields;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to alias BrowserStarfishFields.SPAN_DOMAIN since we moved these down into the new hook and now there are 2 SPAN_DOMAINs in scope.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BrowserStarfishFields is in the process of being deprecated, could we just grab all of these fields from SpanMetricsFeild ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DominikB2014 Oops, should have looked into the enums... updated!

Comment on lines -62 to -69
if (spanMetricsSeriesData) {
spanMetricsSeriesData[`avg(${HTTP_RESPONSE_TRANSFER_SIZE})`].lineStyle = {
type: 'dashed',
};
spanMetricsSeriesData[`avg(${HTTP_DECODED_RESPONSE_CONTENT_LENGTH})`].lineStyle = {
type: 'dashed',
};
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 3 charts shared the data fetching code, but in the new charts only the AverageSeries chart has this code since it is the only chart that uses these series (IIUC).

@billyvg billyvg marked this pull request as ready for review April 15, 2025 20:05
@billyvg billyvg requested a review from a team as a code owner April 15, 2025 20:05
Comment on lines 13 to 14
const {SPAN_SELF_TIME, NORMALIZED_DESCRIPTION, SPAN_DOMAIN} = SpanMetricsField;
const {SPAN_DOMAIN: STARFISH_SPAN_DOMAIN, USER_GEO_SUBREGION} = BrowserStarfishFields;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BrowserStarfishFields is in the process of being deprecated, could we just grab all of these fields from SpanMetricsFeild ?

@billyvg billyvg merged commit 17d074d into master Apr 22, 2025
45 checks passed
@billyvg billyvg deleted the ref-insights-combine-widgets-browser-resources branch April 22, 2025 17:47
billyvg added a commit that referenced this pull request Apr 22, 2025
@github-actions github-actions bot locked and limited conversation to collaborators May 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants