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

fix: calculate push page size based on monitor size per batch #993

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

shahzad31
Copy link
Contributor

@shahzad31 shahzad31 commented Jan 16, 2025

decide the no of monitors based on size of monitor size while pushing !!

Copy link
Member

@vigneshshanmugam vigneshshanmugam left a comment

Choose a reason for hiding this comment

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

@shahzad31 Thanks for the PR, Can we change the PR based on what we discussed

decide the no of monitors based on size of monitor size while pushing

await this.cleanup(output);
return data;
return { content, sizeKb };
Copy link
Contributor

Choose a reason for hiding this comment

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

@shahzad31 Please review, this change of the return type is breaking unit tests

@emilioalvap emilioalvap self-assigned this Feb 7, 2025
@emilioalvap
Copy link
Contributor

@shahzad31 can we adjust the PR description to match the actual intention? This doesn't seem to involve any retries as it is

@shahzad31
Copy link
Contributor Author

@shahzad31 can we adjust the PR description to match the actual intention? This doesn't seem to involve any retries as it is

yeah i will come back to this PR next week

@shahzad31 shahzad31 changed the title fix: retry on payload too large error fix: calculate push page size based on monitor size per batch Feb 14, 2025
@@ -58,6 +58,7 @@ export async function sendReqAndHandleError<T>(
options: APIRequestOptions
): Promise<T> {
const { statusCode, body } = await sendRequest(options);

return (
await handleError(statusCode, options.url, body)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add the chunk size and payload size information on this error? It will be helpful to know how big the payload was and how many monitors per chunk were sent

Copy link
Member

@vigneshshanmugam vigneshshanmugam left a comment

Choose a reason for hiding this comment

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

The approach looks good, just needs changes on the wording. Also, can you share how it looks on the CLI? Thanks

statusCode,
options.url,
body,
`${options.body?.length} number of monitors were sent, with a total size of ${options.body?.length} bytes`
Copy link
Member

Choose a reason for hiding this comment

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

Feels weird, Why not Kibana API return proper error message when we go over the limits?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

kibana doesn't return the payload size

Copy link
Member

Choose a reason for hiding this comment

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

In this case, we need to do this only for the 413 status code, Otherwise we are showing this error message for all the error codes which feels incorrect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@shahzad31
Copy link
Contributor Author

this is how error looks like now

image

Copy link
Member

@vigneshshanmugam vigneshshanmugam left a comment

Choose a reason for hiding this comment

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

Looks good except for the conversion logic.

let currentSize = 0;

for (const item of arr) {
const sizeKiB = item.id ? sizes.get(item.id) / 1024 : 1;
Copy link
Member

Choose a reason for hiding this comment

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

The size is stored in bytes, we need to convert them to kibibytes and round it off - #993 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants