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

Add request feature counter metric #1272

Merged
Merged
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 @@ -165,6 +165,7 @@ public GetOnlineFeaturesResponse getOnlineFeatures(GetOnlineFeaturesRequestV2 re
entityStatusesMap.get(entityRow).putAll(allStatusMaps);
}
populateHistogramMetrics(entityRows, featureReferences, projectName);
populateFeatureCountMetrics(featureReferences, projectName);

// Build response field values from entityValuesMap and entityStatusesMap
// Response field values should be in the same order as the entityRows provided by the user.
Expand Down Expand Up @@ -309,15 +310,19 @@ private void populateHistogramMetrics(
List<GetOnlineFeaturesRequestV2.EntityRow> entityRows,
List<FeatureReferenceV2> featureReferences,
String project) {
Metrics.requestEntityCount.labels(project).observe(Double.valueOf(entityRows.size()));
Metrics.requestFeatureCount.labels(project).observe(Double.valueOf(featureReferences.size()));
Metrics.requestEntityCountDistribution
.labels(project)
.observe(Double.valueOf(entityRows.size()));
Metrics.requestFeatureCountDistribution
.labels(project)
.observe(Double.valueOf(featureReferences.size()));

long countDistinctFeatureTables =
featureReferences.stream()
.map(featureReference -> getFeatureTableStringRef(project, featureReference))
.distinct()
.count();
Metrics.requestFeatureTableCount
Metrics.requestFeatureTableCountDistribution
.labels(project)
.observe(Double.valueOf(countDistinctFeatureTables));
}
Expand All @@ -344,4 +349,15 @@ private void populateCountMetrics(
}
});
}

private void populateFeatureCountMetrics(
List<FeatureReferenceV2> featureReferences, String project) {
featureReferences
.parallelStream()
.forEach(
featureReference ->
Metrics.requestFeatureCount
.labels(project, FeatureV2.getFeatureStringRef(featureReference))
.inc());
}
}
20 changes: 14 additions & 6 deletions serving/src/main/java/feast/serving/util/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,41 @@ public class Metrics {
.labelNames("method")
.register();

public static final Histogram requestEntityCount =
public static final Histogram requestEntityCountDistribution =
Histogram.build()
.buckets(1, 2, 5, 10, 20, 50, 100, 200)
.name("request_entity_count")
.name("request_entity_count_distribution")
.subsystem("feast_serving")
.help("Number of entity rows per request")
.labelNames("project")
.register();

public static final Histogram requestFeatureCount =
public static final Histogram requestFeatureCountDistribution =
Histogram.build()
.buckets(1, 2, 5, 10, 15, 20, 30, 50)
.name("request_feature_count")
.name("request_feature_count_distribution")
.subsystem("feast_serving")
.help("Number of feature rows per request")
.labelNames("project")
.register();

public static final Histogram requestFeatureTableCount =
public static final Histogram requestFeatureTableCountDistribution =
Histogram.build()
.buckets(1, 2, 5, 10, 20)
.name("request_feature_table_count")
.name("request_feature_table_count_distribution")
.subsystem("feast_serving")
.help("Number of feature tables per request")
.labelNames("project")
.register();

public static final Counter requestFeatureCount =
Counter.build()
.name("request_feature_count")
.subsystem("feast_serving")
.help("number of feature rows requested")
.labelNames("project", "feature_name")
.register();

public static final Counter notFoundKeyCount =
Counter.build()
.name("not_found_feature_count")
Expand Down