Skip to content

Commit

Permalink
Use meter for autocommit metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
patsonluk committed Sep 9, 2024
1 parent e78fc97 commit 3aab5b3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ public void run() {
command.openSearcher = openSearcher;
command.waitSearcher = WAIT_SEARCHER;
command.softCommit = softCommit;
command.autoCommit = true;
if (core.getCoreDescriptor().getCloudDescriptor() != null
&& core.getCoreDescriptor().getCloudDescriptor().isLeader()
&& !softCommit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class CommitUpdateCommand extends UpdateCommand {
public boolean expungeDeletes = false;
public boolean softCommit = false;
public boolean prepareCommit = false;
boolean autoCommit = false;

/**
* User provided commit data. Can be let to null if there is none. It is possible to commit this
* user data, even if there is no uncommitted change in the index writer, provided this user data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public class DirectUpdateHandler2 extends UpdateHandler
Meter splitCommands;
Meter optimizeCommands;
Meter rollbackCommands;
Meter hardAutoCommitCounts;
Meter softAutoCommitCounts;
LongAdder numDocsPending = new LongAdder();
LongAdder numErrors = new LongAdder();
Meter numErrorsCumulative;
Expand Down Expand Up @@ -210,14 +212,9 @@ public void initializeMetrics(SolrMetricsContext parentContext, String scope) {
this.solrMetricsContext = parentContext.getChildContext(this);
}
commitCommands = solrMetricsContext.meter("commits", getCategory().toString(), scope);
solrMetricsContext.gauge(
() -> commitTracker.getCommitCount(), true, "autoCommits", getCategory().toString(), scope);
solrMetricsContext.gauge(
() -> softCommitTracker.getCommitCount(),
true,
"softAutoCommits",
getCategory().toString(),
scope);
hardAutoCommitCounts = solrMetricsContext.meter("autoCommits", getCategory().toString(), scope);
softAutoCommitCounts = solrMetricsContext.meter("softAutoCommits", getCategory().toString(), scope);

if (commitTracker.getDocsUpperBound() > 0) {
solrMetricsContext.gauge(
() -> commitTracker.getDocsUpperBound(),
Expand Down Expand Up @@ -705,6 +702,14 @@ public void commit(CommitUpdateCommand cmd) throws IOException {
if (cmd.expungeDeletes) expungeDeleteCommands.mark();
}

if (cmd.autoCommit) {
if (cmd.softCommit) {
softAutoCommitCounts.mark();
} else {
hardAutoCommitCounts.mark();
}
}

@SuppressWarnings("unchecked")
Future<Void>[] waitSearcher =
cmd.waitSearcher ? (Future<Void>[]) Array.newInstance(Future.class, 1) : null;
Expand Down

0 comments on commit 3aab5b3

Please sign in to comment.