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

Infrastructure to meter updates by script for ra-s nontimeseries #108910

Merged
merged 24 commits into from
Jul 11, 2024

Conversation

pgomulka
Copy link
Contributor

@pgomulka pgomulka commented May 22, 2024

this commit refactors the metering for billing api so that we can hide the implementation details of DocumentSizeObserver creation and adds additional field originatesFromScript on IndexRequest
There will no longer need to have a code checking if the request was already parsed in ingest service or updatehelper. This logic will be hidden in the implementation.

@pgomulka pgomulka changed the title DRAFT Meter updates by script for ra-s nontimeseries Infrastructure to meter updates by script for ra-s nontimeseries Jun 28, 2024
@pgomulka pgomulka marked this pull request as ready for review June 28, 2024 08:15
@pgomulka pgomulka requested a review from a team as a code owner June 28, 2024 08:15
@pgomulka pgomulka self-assigned this Jun 28, 2024
@pgomulka pgomulka added :Core/Infra/Metrics Metrics and metering infrastructure >refactoring labels Jun 28, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Jun 28, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Contributor

@ldematte ldematte left a comment

Choose a reason for hiding this comment

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

LGTM, even if it is hard to see if this will work well in serverless. Well, we'll see and iterate, I suppose :)
Will this break the submodule update? Do you have a corresponding change ready?

@@ -109,8 +109,7 @@ public IndexResult index(Index index) throws IOException {
DocumentSizeAccumulator.EMPTY_INSTANCE
);
ParsedDocument parsedDocument = index.parsedDoc();
DocumentSizeObserver documentSizeObserver = parsedDocument.getDocumentSizeObserver();
documentParsingReporter.onIndexingCompleted(documentSizeObserver);
documentParsingReporter.onIndexingCompleted(parsedDocument);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is much cleaner, names makes more sense. I like it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can find a better name for DocumentSizeObserver, (DocumentSizeAccumulator or similar?), but that's really a nitpick, and should be the last thing we do, when everything is in place.

.setRefreshPolicy(request.getRefreshPolicy())
.setNormalisedBytesParsed(documentSizeObserver.normalisedBytesParsed());
.setRefreshPolicy(request.getRefreshPolicy());
documentSizeObserver.setNormalisedBytesParsedOn(finalIndexRequest);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: to be honest, I liked the old style more. But I'm not enough into the code (especially not in how this is used in serverless) to have a strong opinion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, wondering if this is still necessary looking at the impls of setNormalisedBytesParsedOn.
Would below work (or are there cases where we don't want to set bytes parsed even if > 0)?

if(documentSizeObserver.normalisedBytesParsed() > 0) {
  finalIndexRequest.setNormalisedBytesParsed(documentSizeObserver.normalisedBytesParsed());
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see, this is because we want someone to know not to set the normalized bytes, e.g. have an implementation that says public void setNormalisedBytesParsedOn(IndexRequest indexRequest) { /* do nothing */ }
Not loving the inversion, but I understand why now (as I said, not enough into code to understand how/if this could be better)

Copy link
Contributor

@mosche mosche left a comment

Choose a reason for hiding this comment

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

Lgtm if tests pass 🎉

Just wondering if the indirection on setNormalisedBytesParsed is required, or if this could be removed to make it easier to follow the code.

@pgomulka pgomulka merged commit cf03c66 into elastic:main Jul 11, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Metrics Metrics and metering infrastructure >refactoring Team:Core/Infra Meta label for core/infra team v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants