-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
Conversation
Pinging @elastic/es-core-infra (Team:Core/Infra) |
There was a problem hiding this 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?
server/src/main/java/org/elasticsearch/plugins/internal/DocumentSizeObserver.java
Outdated
Show resolved
Hide resolved
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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());
}
There was a problem hiding this comment.
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)
There was a problem hiding this 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.
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 IndexRequestThere 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.