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

DW-2096: Introduce evaluated & rejected events metrics #20

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,10 @@ public int getFieldNumber(String name) {
@XmlElement
protected long seekCount = 0;
@XmlElement
protected long evaluatedCount = 0;
@XmlElement
protected long rejectedCount = 0;
@XmlElement
protected long yieldCount = 0L;
@XmlElement
@XmlJavaTypeAdapter(StringMapAdapter.class)
Expand Down Expand Up @@ -897,6 +901,22 @@ public void setSeekCount(long seekCount) {
this.seekCount = seekCount;
}

public long getEvaluatedCount() {
return evaluatedCount;
}

public void setEvaluatedCount(long evaluatedCount) {
this.evaluatedCount = evaluatedCount;
}

public long getRejectedCount() {
return rejectedCount;
}

public void setRejectedCount(long rejectedCount) {
this.rejectedCount = rejectedCount;
}

public long getYieldCount() {
return this.yieldCount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public QueryMetric(QueryMetric other) {
this.sourceCount = other.sourceCount;
this.nextCount = other.nextCount;
this.seekCount = other.seekCount;
this.evaluatedCount = other.evaluatedCount;
this.rejectedCount = other.rejectedCount;
this.yieldCount = other.yieldCount;
this.versionMap = other.versionMap;
this.docSize = other.docSize;
Expand Down Expand Up @@ -143,7 +145,7 @@ public int hashCode() {
.append(this.getParameters()).append(this.getSourceCount()).append(this.getNextCount()).append(this.getSeekCount())
.append(this.getYieldCount()).append(this.getDocSize()).append(this.getDocRanges()).append(this.getFiRanges()).append(this.getPlan())
.append(this.getLoginTime()).append(this.getPredictions()).append(this.getMarkings()).append(this.getNumUpdates())
.append(this.getVersionMap()).toHashCode();
.append(this.getVersionMap()).append(this.getEvaluatedCount()).append(this.getRejectedCount()).toHashCode();
}

@Override
Expand All @@ -169,6 +171,7 @@ public boolean equals(Object o) {
.append(this.getErrorCode(), other.getErrorCode()).append(this.getSourceCount(), other.getSourceCount())
.append(this.getNextCount(), other.getNextCount()).append(this.getSeekCount(), other.getSeekCount())
.append(this.getYieldCount(), other.getYieldCount()).append(this.getDocSize(), other.getDocSize())
.append(this.getEvaluatedCount(), other.getEvaluatedCount()).append(this.getRejectedCount(), other.getRejectedCount())
.append(this.getDocRanges(), other.getDocRanges()).append(this.getFiRanges(), other.getFiRanges())
.append(this.getPlan(), other.getPlan()).append(this.getLoginTime(), other.getLoginTime())
.append(this.getPredictions(), other.getPredictions()).append(this.getMarkings(), other.getMarkings())
Expand Down Expand Up @@ -209,6 +212,8 @@ public String toString() {
buf.append(" Source Count: ").append(this.getSourceCount());
buf.append(" NextCount: ").append(this.getNextCount());
buf.append(" Seek Count: ").append(this.getSeekCount());
buf.append(" Evaluated Count: ").append(this.getEvaluatedCount());
buf.append(" Rejected Count: ").append(this.getRejectedCount());
buf.append(" Yield Count: ").append(this.getYieldCount());
buf.append(" Doc Size: ").append(this.getDocSize());
buf.append(" Doc Ranges: ").append(this.getDocRanges());
Expand Down Expand Up @@ -406,8 +411,10 @@ public void writeTo(Output output, QueryMetric message) throws IOException {
output.writeString(38, StringUtils.join(Arrays.asList(entry.getKey(), entry.getValue()), "\0"), true);
}
}

output.writeInt64(39, message.docSize, false);
output.writeInt64(40, message.evaluatedCount, false);
output.writeInt64(41, message.rejectedCount, false);
}

public void mergeFrom(Input input, QueryMetric message) throws IOException {
Expand Down Expand Up @@ -559,6 +566,12 @@ public void mergeFrom(Input input, QueryMetric message) throws IOException {
case 39:
message.docSize = input.readInt64();
break;
case 40:
message.evaluatedCount = input.readInt64();
break;
case 41:
message.rejectedCount = input.readInt64();
break;
default:
input.handleUnknownField(number, this);
break;
Expand Down Expand Up @@ -647,6 +660,10 @@ public String getFieldName(int number) {
return "versionMap";
case 39:
return "docSize";
case 40:
return "evaluatedCount";
case 41:
return "rejectedCount";
default:
return null;
}
Expand Down Expand Up @@ -699,6 +716,8 @@ public int getFieldNumber(String name) {
fieldMap.put("version", 37);
fieldMap.put("versionMap", 38);
fieldMap.put("docSize", 39);
fieldMap.put("evaluatedCount", 40);
fieldMap.put("rejectedCount", 41);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ public String getSeekCountStr() {
return nf.format(seekCount);
}

public String getEvaluatedCountStr() {
return nf.format(evaluatedCount);
}

public String getRejectedCountStr() {
return nf.format(rejectedCount);
}

public String getYieldCountStr() {
return nf.format(yieldCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public interface QueryMetricModelFormat {

String getSeekCountStr();

String getEvaluatedCountStr();

String getRejectedCountStr();

String getYieldCountStr();

String getVersionStr();
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/resources/templates/querymetric-horizontal.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ <h1>Query Metrics</h1>
<th>Sources</th>
<th>Next Calls</th>
<th>Seek Calls</th>
<th>Evaluated Events</th>
<th>Rejected Events</th>
<th>Yield Count</th>
<th>Versions</th>
<th>Total Page Time (ms)</th>
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/resources/templates/querymetric.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ <h1>Query Metrics</h1>
<tr><td>Sources</td><td th:text="${metric.sourceCountStr}"></td></tr>
<tr class="highlight"><td>Next Calls</td><td th:text="${metric.nextCountStr}"></td>
<tr><td>Seek Calls</td><td th:text="${metric.seekCountStr}"></td></tr>
<tr class="highlight"><td>Events Evaluated</td><td th:text="${metric.evaluatedCountStr}"></td></tr>
<tr><td>Events Rejected</td><td th:text="${metric.rejectedCountStr}"></td></tr>
<tr class="highlight"><td>Yield Count</td><td th:text="${metric.yieldCountStr}"></td></tr>
<tr><td>Total Page Time (ms)</td><td th:text="${metric.totalPageTimeStr}"></td></tr>
<tr class="highlight"><td>Total Page Call Time (ms)</td><td th:text="${metric.totalPageCallTimeStr}"></td></tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public Long process(Map.Entry<String,QueryMetricUpdateHolder> entry) {
storedHolder.addValue("sourceCount", updatedMetric.getSourceCount());
storedHolder.addValue("nextCount", updatedMetric.getNextCount());
storedHolder.addValue("seekCount", updatedMetric.getSeekCount());
storedHolder.addValue("evaluatedCount", updatedMetric.getEvaluatedCount());
storedHolder.addValue("rejectedCount", updatedMetric.getRejectedCount());
storedHolder.addValue("yieldCount", updatedMetric.getYieldCount());
storedHolder.addValue("docSize", updatedMetric.getDocSize());
storedHolder.addValue("docRanges", updatedMetric.getDocRanges());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class QueryMetricHandlerProperties {
"END_DATE",
"ERROR_CODE",
"ERROR_MESSAGE",
"EVALUATED_COUNT",
"FI_RANGES",
"HOST",
"LIFECYCLE",
Expand All @@ -113,6 +114,7 @@ public class QueryMetricHandlerProperties {
"QUERY_LOGIC",
"QUERY_NAME",
"QUERY_TYPE",
"REJECTED_COUNT",
"SEEK_COUNT",
"SETUP_TIME",
"SOURCE_COUNT",
Expand Down Expand Up @@ -144,9 +146,11 @@ public class QueryMetricHandlerProperties {
"DOC_RANGES",
"DOC_SIZE",
"ELAPSED_TIME",
"EVALUATED_COUNT",
"FI_RANGES",
"LOGIN_TIME",
"NEXT_COUNT",
"REJECTED_COUNT",
"SEEK_COUNT",
"SETUP_TIME",
"SOURCE_COUNT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ public Multimap<String,String> getEventFieldsToWrite(T updated, T stored) {
if (isChanged(updated.getErrorMessage(), stored == null ? null : stored.getErrorMessage())) {
fields.put("ERROR_MESSAGE", updated.getErrorMessage());
}
if (isChanged(updated.getEvaluatedCount(), stored == null ? -1 : stored.getEvaluatedCount())) {
fields.put("EVALUATED_COUNT", Long.toString(updated.getEvaluatedCount()));
}
if (isChanged(updated.getFiRanges(), stored == null ? -1 : stored.getFiRanges())) {
fields.put("FI_RANGES", Long.toString(updated.getFiRanges()));
}
Expand Down Expand Up @@ -323,6 +326,9 @@ public Multimap<String,String> getEventFieldsToWrite(T updated, T stored) {
fields.put("QUERY_TYPE", updated.getQueryType());
}
}
if (isChanged(updated.getRejectedCount(), stored == null ? -1 : stored.getRejectedCount())) {
fields.put("REJECTED_COUNT", Long.toString(updated.getRejectedCount()));
}
if (isFirstWrite(updated.getSetupTime(), stored == null ? -1 : stored.getSetupTime(), -1)) {
fields.put("SETUP_TIME", Long.toString(updated.getSetupTime()));
}
Expand Down Expand Up @@ -392,6 +398,9 @@ public Multimap<String,String> getEventFieldsToDelete(T updated, T stored) {
if (isChanged(updated.getElapsedTime(), stored.getElapsedTime())) {
fields.put("ELAPSED_TIME", Long.toString(stored.getElapsedTime()));
}
if (isChanged(updated.getEvaluatedCount(), stored.getEvaluatedCount())) {
fields.put("EVALUATED_COUNT", Long.toString(stored.getEvaluatedCount()));
}
if (isChanged(updated.getFiRanges(), stored.getFiRanges())) {
fields.put("FI_RANGES", Long.toString(stored.getFiRanges()));
}
Expand Down Expand Up @@ -450,6 +459,9 @@ public Multimap<String,String> getEventFieldsToDelete(T updated, T stored) {
fields.put("PLAN", stored.getPlan());
}
}
if (isChanged(updated.getRejectedCount(), stored.getRejectedCount())) {
fields.put("REJECTED_COUNT", Long.toString(stored.getRejectedCount()));
}
if (isChanged(updated.getSeekCount(), stored.getSeekCount())) {
fields.put("SEEK_COUNT", Long.toString(stored.getSeekCount()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ public T combineMetrics(T updatedQueryMetric, T cachedQueryMetric, QueryMetricTy
combinedMetric.setSourceCount(combinedMetric.getSourceCount() + updatedQueryMetric.getSourceCount());
combinedMetric.setNextCount(combinedMetric.getNextCount() + updatedQueryMetric.getNextCount());
combinedMetric.setSeekCount(combinedMetric.getSeekCount() + updatedQueryMetric.getSeekCount());
combinedMetric.setEvaluatedCount(combinedMetric.getEvaluatedCount() + updatedQueryMetric.getEvaluatedCount());
combinedMetric.setRejectedCount(combinedMetric.getRejectedCount() + updatedQueryMetric.getRejectedCount());
combinedMetric.setYieldCount(combinedMetric.getYieldCount() + updatedQueryMetric.getYieldCount());
combinedMetric.setDocSize(combinedMetric.getDocSize() + updatedQueryMetric.getDocSize());
combinedMetric.setDocRanges(combinedMetric.getDocRanges() + updatedQueryMetric.getDocRanges());
Expand All @@ -191,6 +193,8 @@ public T combineMetrics(T updatedQueryMetric, T cachedQueryMetric, QueryMetricTy
combinedMetric.setSourceCount(updatedQueryMetric.getSourceCount());
combinedMetric.setNextCount(updatedQueryMetric.getNextCount());
combinedMetric.setSeekCount(updatedQueryMetric.getSeekCount());
combinedMetric.setEvaluatedCount(updatedQueryMetric.getEvaluatedCount());
combinedMetric.setRejectedCount(updatedQueryMetric.getRejectedCount());
combinedMetric.setYieldCount(updatedQueryMetric.getYieldCount());
combinedMetric.setDocSize(updatedQueryMetric.getDocSize());
combinedMetric.setDocRanges(updatedQueryMetric.getDocRanges());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,15 @@ public T toMetric(EventBase event) {
m.setErrorCode(fieldValue);
} else if (fieldName.equals("ERROR_MESSAGE")) {
m.setErrorMessage(fieldValue);
} else if (fieldName.equals("EVALUATED_COUNT")) {
try {
long l = Long.parseLong(fieldValue);
if (l > m.getEvaluatedCount()) {
m.setEvaluatedCount(l);
}
} catch (Exception e) {
log.error(fieldName + ":" + fieldValue + ":" + e.getMessage());
}
} else if (fieldName.equals("FI_RANGES")) {
try {
long l = Long.parseLong(fieldValue);
Expand Down Expand Up @@ -701,6 +710,15 @@ public T toMetric(EventBase event) {
m.setQueryName(fieldValue);
} else if (fieldName.equals("QUERY_TYPE")) {
m.setQueryType(fieldValue);
} else if (fieldName.equals("REJECTED_COUNT")) {
try {
long l = Long.parseLong(fieldValue);
if (l > m.getRejectedCount()) {
m.setRejectedCount(l);
}
} catch (Exception e) {
log.error(fieldName + ":" + fieldValue + ":" + e.getMessage());
}
} else if (fieldName.equals("SEEK_COUNT")) {
try {
long l = Long.parseLong(fieldValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ public void store(QueryMetricUpdateHolder<T> queryMetricUpdate) throws Exception
updatedMetric.setSourceCount(queryMetricUpdate.getValue("sourceCount"));
updatedMetric.setNextCount(queryMetricUpdate.getValue("nextCount"));
updatedMetric.setSeekCount(queryMetricUpdate.getValue("seekCount"));
updatedMetric.setEvaluatedCount(queryMetricUpdate.getValue("evaluatedCount"));
updatedMetric.setRejectedCount(queryMetricUpdate.getValue("rejectedCount"));
updatedMetric.setYieldCount(queryMetricUpdate.getValue("yieldCount"));
updatedMetric.setDocSize(queryMetricUpdate.getValue("docSize"));
updatedMetric.setDocRanges(queryMetricUpdate.getValue("docRanges"));
Expand Down Expand Up @@ -205,6 +207,8 @@ public void store(QueryMetricUpdateHolder<T> queryMetricUpdate) throws Exception
queryMetricUpdate.getMetric().setSourceCount(updatedMetric.getSourceCount());
queryMetricUpdate.getMetric().setNextCount(updatedMetric.getNextCount());
queryMetricUpdate.getMetric().setSeekCount(updatedMetric.getSeekCount());
queryMetricUpdate.getMetric().setEvaluatedCount(updatedMetric.getEvaluatedCount());
queryMetricUpdate.getMetric().setRejectedCount(updatedMetric.getRejectedCount());
queryMetricUpdate.getMetric().setYieldCount(updatedMetric.getYieldCount());
queryMetricUpdate.getMetric().setDocSize(updatedMetric.getDocSize());
queryMetricUpdate.getMetric().setDocRanges(updatedMetric.getDocRanges());
Expand Down
Loading