Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Bundle Analysis: fix trends when no data in query range#1267

Merged
JerrySentry merged 5 commits intomainfrom
ba_trends
Apr 3, 2025
Merged

Bundle Analysis: fix trends when no data in query range#1267
JerrySentry merged 5 commits intomainfrom
ba_trends

Conversation

@JerrySentry
Copy link
Copy Markdown
Contributor

@JerrySentry JerrySentry commented Apr 2, 2025

When there are no measurement datapoints for the specified query range then instead of return nothing we will look back in time past the start of the range to look for the first datapoint and let that be the first data point in the query range. This basically carryovers the nearest measurement so that the trend graph renders with a starting point

closes: codecov/engineering-team#2886
closes: codecov/engineering-team#3358

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@seer-by-sentry
Copy link
Copy Markdown
Contributor

seer-by-sentry bot commented Apr 2, 2025

✅ Sentry found no issues in your recent changes ✅

@JerrySentry JerrySentry marked this pull request as ready for review April 2, 2025 20:04
@JerrySentry JerrySentry requested a review from a team as a code owner April 2, 2025 20:04
@codecov-notifications
Copy link
Copy Markdown

codecov-notifications bot commented Apr 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.32%. Comparing base (f717a2b) to head (6a9370b).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1267      +/-   ##
==========================================
+ Coverage   96.31%   96.32%   +0.01%     
==========================================
  Files         487      487              
  Lines       16891    16891              
==========================================
+ Hits        16269    16271       +2     
+ Misses        622      620       -2     
Flag Coverage Δ
unit 96.32% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1178,9 +1178,12 @@ def test_no_dataset(self, trigger_backfill):
repository_id__in=[self.repo1.pk, self.repo2.pk],
)
)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not sure why this test breaks when I introduce the new tests from above.. namely the ordering of the input is flipped.. going to check that either ordering direction works, in trigger_backfill it doesn't matter for the ordering anyways.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could also confirm the items in the set as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated

before: datetime,
after: Optional[datetime] = None,
branch: Optional[str] = None,
) -> Dict[int, List[Dict[str, Any]]]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

was this change on purpose? Should we also change the type on 41 as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah because when this function was made the measurable_id was only ints representing the flag IDs for flag measurements, but it can be also str for component names or BA reports.

Yes updating line 41.

carryover = dict(measurements[0])
carryover["timestamp_bin"] = self.after
carryover = dict(measurements[0]) if measurements else {}
carryover["timestamp_bin"] = self.after.replace(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this to "zero out" the timestamp?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, in the downstream when building the list of measurements to return it needs to have 00:00:00.000 as the time, that is expected because normally we pull the data from the aggregate tables, naturally it always agg by n days and so the time is always 0s. But in this case when we carry over the last datapoint we don't query from the aggregate tables, instead it comes from the un-agg'd table so the time is when it got inserted. So this part would zero out the times to comply with the logic later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ahhhh okay makes sense

Copy link
Copy Markdown
Contributor

@ajay-sentry ajay-sentry left a comment

Choose a reason for hiding this comment

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

send it

@JerrySentry JerrySentry added this pull request to the merge queue Apr 3, 2025
Merged via the queue into main with commit 8ded4cb Apr 3, 2025
23 of 24 checks passed
@JerrySentry JerrySentry deleted the ba_trends branch April 3, 2025 19:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

2 participants