Skip to content

Commit

Permalink
Add missing key count metric (#816)
Browse files Browse the repository at this point in the history
* Add missing key count metric

* Refactor metrics counter

* Rename function

Co-authored-by: Terence <terence.limxp@go-jek.com>
  • Loading branch information
terryyylim and Terence authored Jun 23, 2020
1 parent a16d7ee commit a1207b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public GetOnlineFeaturesResponse getOnlineFeatures(GetOnlineFeaturesRequest requ
entityStatusesMap.get(entityRow).putAll(statusMap);

// Populate metrics/log request
populateStaleKeyCountMetrics(statusMap, featureSetRequest);
populateCountMetrics(statusMap, featureSetRequest);
});
populateRequestCountMetrics(featureSetRequest);
logFeatureRows.add(featureRows);
Expand Down Expand Up @@ -287,7 +287,7 @@ private void logFeatureRowsTrace(
scope.span().log(ImmutableMap.of("event", "featureRows", "value", loggableFeatureRows));
}

private void populateStaleKeyCountMetrics(
private void populateCountMetrics(
Map<String, FieldStatus> statusMap, FeatureSetRequest featureSetRequest) {
String project = featureSetRequest.getSpec().getProject();
statusMap
Expand All @@ -296,6 +296,9 @@ private void populateStaleKeyCountMetrics(
es -> {
String featureRefString = es.getKey();
FieldStatus status = es.getValue();
if (status == FieldStatus.NOT_FOUND) {
Metrics.notFoundKeyCount.labels(project, featureRefString).inc();
}
if (status == FieldStatus.OUTSIDE_MAX_AGE) {
Metrics.staleKeyCount.labels(project, featureRefString).inc();
}
Expand Down
12 changes: 2 additions & 10 deletions serving/src/main/java/feast/serving/util/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,14 @@ public class Metrics {
.labelNames("project", "feature_name")
.register();

public static final Counter missingKeyCount =
public static final Counter notFoundKeyCount =
Counter.build()
.name("missing_feature_count")
.name("not_found_feature_count")
.subsystem("feast_serving")
.help("number requested feature rows that were not found")
.labelNames("project", "feature_name")
.register();

public static final Counter invalidEncodingCount =
Counter.build()
.name("invalid_encoding_feature_count")
.subsystem("feast_serving")
.help("number requested feature rows that were stored with the wrong encoding")
.labelNames("project", "feature_name")
.register();

public static final Counter staleKeyCount =
Counter.build()
.name("stale_feature_count")
Expand Down

0 comments on commit a1207b5

Please sign in to comment.