Skip to content

Commit 56d8959

Browse files
authored
Add request feature counter metric (#1272)
Signed-off-by: Terence <terencelimxp@gmail.com>
1 parent 7561970 commit 56d8959

2 files changed

Lines changed: 33 additions & 9 deletions

File tree

serving/src/main/java/feast/serving/service/OnlineServingServiceV2.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public GetOnlineFeaturesResponse getOnlineFeatures(GetOnlineFeaturesRequestV2 re
165165
entityStatusesMap.get(entityRow).putAll(allStatusMaps);
166166
}
167167
populateHistogramMetrics(entityRows, featureReferences, projectName);
168+
populateFeatureCountMetrics(featureReferences, projectName);
168169

169170
// Build response field values from entityValuesMap and entityStatusesMap
170171
// Response field values should be in the same order as the entityRows provided by the user.
@@ -309,15 +310,19 @@ private void populateHistogramMetrics(
309310
List<GetOnlineFeaturesRequestV2.EntityRow> entityRows,
310311
List<FeatureReferenceV2> featureReferences,
311312
String project) {
312-
Metrics.requestEntityCount.labels(project).observe(Double.valueOf(entityRows.size()));
313-
Metrics.requestFeatureCount.labels(project).observe(Double.valueOf(featureReferences.size()));
313+
Metrics.requestEntityCountDistribution
314+
.labels(project)
315+
.observe(Double.valueOf(entityRows.size()));
316+
Metrics.requestFeatureCountDistribution
317+
.labels(project)
318+
.observe(Double.valueOf(featureReferences.size()));
314319

315320
long countDistinctFeatureTables =
316321
featureReferences.stream()
317322
.map(featureReference -> getFeatureTableStringRef(project, featureReference))
318323
.distinct()
319324
.count();
320-
Metrics.requestFeatureTableCount
325+
Metrics.requestFeatureTableCountDistribution
321326
.labels(project)
322327
.observe(Double.valueOf(countDistinctFeatureTables));
323328
}
@@ -344,4 +349,15 @@ private void populateCountMetrics(
344349
}
345350
});
346351
}
352+
353+
private void populateFeatureCountMetrics(
354+
List<FeatureReferenceV2> featureReferences, String project) {
355+
featureReferences
356+
.parallelStream()
357+
.forEach(
358+
featureReference ->
359+
Metrics.requestFeatureCount
360+
.labels(project, FeatureV2.getFeatureStringRef(featureReference))
361+
.inc());
362+
}
347363
}

serving/src/main/java/feast/serving/util/Metrics.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,41 @@ public class Metrics {
2929
.labelNames("method")
3030
.register();
3131

32-
public static final Histogram requestEntityCount =
32+
public static final Histogram requestEntityCountDistribution =
3333
Histogram.build()
3434
.buckets(1, 2, 5, 10, 20, 50, 100, 200)
35-
.name("request_entity_count")
35+
.name("request_entity_count_distribution")
3636
.subsystem("feast_serving")
3737
.help("Number of entity rows per request")
3838
.labelNames("project")
3939
.register();
4040

41-
public static final Histogram requestFeatureCount =
41+
public static final Histogram requestFeatureCountDistribution =
4242
Histogram.build()
4343
.buckets(1, 2, 5, 10, 15, 20, 30, 50)
44-
.name("request_feature_count")
44+
.name("request_feature_count_distribution")
4545
.subsystem("feast_serving")
4646
.help("Number of feature rows per request")
4747
.labelNames("project")
4848
.register();
4949

50-
public static final Histogram requestFeatureTableCount =
50+
public static final Histogram requestFeatureTableCountDistribution =
5151
Histogram.build()
5252
.buckets(1, 2, 5, 10, 20)
53-
.name("request_feature_table_count")
53+
.name("request_feature_table_count_distribution")
5454
.subsystem("feast_serving")
5555
.help("Number of feature tables per request")
5656
.labelNames("project")
5757
.register();
5858

59+
public static final Counter requestFeatureCount =
60+
Counter.build()
61+
.name("request_feature_count")
62+
.subsystem("feast_serving")
63+
.help("number of feature rows requested")
64+
.labelNames("project", "feature_name")
65+
.register();
66+
5967
public static final Counter notFoundKeyCount =
6068
Counter.build()
6169
.name("not_found_feature_count")

0 commit comments

Comments
 (0)