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 Feast Serving histogram metrics #1240

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 @@ -16,6 +16,8 @@
*/
package feast.serving.service;

import static feast.common.models.FeatureTable.getFeatureTableStringRef;

import com.google.protobuf.Duration;
import feast.common.models.FeatureV2;
import feast.proto.core.FeatureProto;
Expand Down Expand Up @@ -162,6 +164,7 @@ public GetOnlineFeaturesResponse getOnlineFeatures(GetOnlineFeaturesRequestV2 re
entityValuesMap.get(entityRow).putAll(allValueMaps);
entityStatusesMap.get(entityRow).putAll(allStatusMaps);
}
populateHistogramMetrics(entityRows, 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 @@ -295,6 +298,30 @@ private static boolean checkOutsideMaxAge(
return timeDifference > maxAge.getSeconds();
}

/**
* Populate histogram metrics that can be used for analysing online retrieval calls
*
* @param entityRows entity rows provided in request
* @param featureReferences feature references provided in request
* @param project project name provided in request
*/
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()));

long countDistinctFeatureTables =
featureReferences.stream()
.map(featureReference -> getFeatureTableStringRef(project, featureReference))
.distinct()
.count();
Metrics.requestFeatureTableCount
.labels(project)
.observe(Double.valueOf(countDistinctFeatureTables));
}

/**
* Populate count metrics that can be used for analysing online retrieval calls
*
Expand Down
27 changes: 23 additions & 4 deletions serving/src/main/java/feast/serving/util/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,31 @@ public class Metrics {
.labelNames("method")
.register();

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

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

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

public static final Counter notFoundKeyCount =
Expand Down