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: connection count usage #9294

Merged
merged 3 commits into from
Feb 11, 2025
Merged

feat: connection count usage #9294

merged 3 commits into from
Feb 11, 2025

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented Feb 11, 2025

About the changes

Network data usage may show connections instead of raw request count behind a flag.
Screenshot 2025-02-11 at 15 37 06

This PR adjusts chart data to visualize connections count (1 connection = 7200 requests per day) in a day or in a month

Important files

Discussion points

Copy link

vercel bot commented Feb 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 11, 2025 3:11pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Feb 11, 2025 3:11pm

Copy link
Contributor

github-actions bot commented Feb 11, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

@@ -40,6 +42,46 @@ export const toChartData = (
return { datasets, labels };
};

export const toConnectionChartData = (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a copy of existing method with minor modifications

const date = parseISO(dataPoint.period);
const requestCount = dataPoint.trafficTypes[0].count;

if (dataPoint.period.length === 7) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if YYYY-MM then divide requests by 1 day connection (7200 req) and number of days in a month

Copy link
Contributor

@thomasheartman thomasheartman Feb 11, 2025

Choose a reason for hiding this comment

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

whew. yeah, this'll work, but it feels iffy. A regex match ([0-9]{4}-[0-9]{2}) or a date checker would put me more at ease, but it'll also be more computationally expensive.

But even better: may I suggest that you do if (traffic.grouping === 'monthly)`? That should also give you what you need, and is also less work .

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (dataPoint.period.length === 7) {
if (traffic.grouping === 'monthly') {

requestCount / (daysInMonth * 7200);
} else {
// 1 connection = 7200 requests per day
record[dataPoint.period] = requestCount / 7200;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

daily request quota for one connection is 7200

Copy link
Contributor Author

Choose a reason for hiding this comment

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

next PR may change the 7200 to a variant to make it configurable

Copy link
Contributor

@thomasheartman thomasheartman left a comment

Choose a reason for hiding this comment

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

I don't have the context, but by and large this looks sane to me. Added a suggestion and a comment to have a look at, but otherwise fine.

Comment on lines 304 to 305
// console.log(chartData, chartDataSelection.grouping, chartDataSelection);

Copy link
Contributor

Choose a reason for hiding this comment

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

probably don't need this 😉

const date = parseISO(dataPoint.period);
const requestCount = dataPoint.trafficTypes[0].count;

if (dataPoint.period.length === 7) {
Copy link
Contributor

@thomasheartman thomasheartman Feb 11, 2025

Choose a reason for hiding this comment

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

whew. yeah, this'll work, but it feels iffy. A regex match ([0-9]{4}-[0-9]{2}) or a date checker would put me more at ease, but it'll also be more computationally expensive.

But even better: may I suggest that you do if (traffic.grouping === 'monthly)`? That should also give you what you need, and is also less work .

const date = parseISO(dataPoint.period);
const requestCount = dataPoint.trafficTypes[0].count;

if (dataPoint.period.length === 7) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (dataPoint.period.length === 7) {
if (traffic.grouping === 'monthly') {

@thomasheartman
Copy link
Contributor

Also, so this only affects visualisations, right? It's not supposed to touch the aggregation metrics in the boxes etc? Because if so, you probably want to do it earlier on.

@kwasniew
Copy link
Contributor Author

@thomasheartman yeah, i deliberately left out the aggregation box since this change is to get a preview in the chart itself with minimal effort. We can iterate on this later and introduce another tab.

@kwasniew kwasniew merged commit 54766fd into main Feb 11, 2025
8 of 12 checks passed
@kwasniew kwasniew deleted the connection-count-usage branch February 11, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants