Skip to content

Commit 7633912

Browse files
authored
Send additional 25th and 99th percentile for feature value metrics (feast-dev#511)
1 parent ca312be commit 7633912

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

ingestion/src/main/java/feast/ingestion/options/ImportOptions.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ public interface ImportOptions extends PipelineOptions, DataflowPipelineOptions,
6565
*/
6666
void setDeadLetterTableSpec(String deadLetterTableSpec);
6767

68-
// TODO: expound
69-
@Description("MetricsAccumulator exporter type to instantiate.")
68+
@Description("MetricsAccumulator exporter type to instantiate. Supported type: statsd")
7069
@Default.String("none")
7170
String getMetricsExporterType();
7271

@@ -86,10 +85,11 @@ public interface ImportOptions extends PipelineOptions, DataflowPipelineOptions,
8685
void setStatsdPort(int StatsdPort);
8786

8887
@Description(
89-
"Fixed window size in seconds (default 30) to apply before aggregation of numerical value of features"
90-
+ "and writing the aggregated value to StatsD. Refer to feast.ingestion.transform.metrics.WriteFeatureValueMetricsDoFn"
91-
+ "for details on the metric names and types.")
92-
@Default.Integer(30)
88+
"Fixed window size in seconds (default 60) to apply before aggregating the numerical value of "
89+
+ "features and exporting the aggregated values as metrics. Refer to "
90+
+ "feast/ingestion/transform/metrics/WriteFeatureValueMetricsDoFn.java"
91+
+ "for the metric nameas and types used.")
92+
@Default.Integer(60)
9393
int getWindowSizeInSecForFeatureValueMetric();
9494

9595
void setWindowSizeInSecForFeatureValueMetric(int seconds);

ingestion/src/main/java/feast/ingestion/transform/metrics/WriteFeatureValueMetricsDoFn.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ abstract static class Builder {
9090
public static String GAUGE_NAME_FEATURE_VALUE_MIN = "feature_value_min";
9191
public static String GAUGE_NAME_FEATURE_VALUE_MAX = "feature_value_max";
9292
public static String GAUGE_NAME_FEATURE_VALUE_MEAN = "feature_value_mean";
93+
public static String GAUGE_NAME_FEATURE_VALUE_PERCENTILE_25 = "feature_value_percentile_25";
9394
public static String GAUGE_NAME_FEATURE_VALUE_PERCENTILE_50 = "feature_value_percentile_50";
9495
public static String GAUGE_NAME_FEATURE_VALUE_PERCENTILE_90 = "feature_value_percentile_90";
9596
public static String GAUGE_NAME_FEATURE_VALUE_PERCENTILE_95 = "feature_value_percentile_95";
97+
public static String GAUGE_NAME_FEATURE_VALUE_PERCENTILE_99 = "feature_value_percentile_99";
9698

9799
@Setup
98100
public void setup() {
@@ -205,6 +207,12 @@ public void processElement(
205207
values[i] = valueList.get(i);
206208
}
207209

210+
double p25 = new Percentile().evaluate(values, 25);
211+
if (p25 < 0) {
212+
statsDClient.gauge(GAUGE_NAME_FEATURE_VALUE_PERCENTILE_25, 0, tags);
213+
}
214+
statsDClient.gauge(GAUGE_NAME_FEATURE_VALUE_PERCENTILE_25, p25, tags);
215+
208216
double p50 = new Percentile().evaluate(values, 50);
209217
if (p50 < 0) {
210218
statsDClient.gauge(GAUGE_NAME_FEATURE_VALUE_PERCENTILE_50, 0, tags);
@@ -222,6 +230,12 @@ public void processElement(
222230
statsDClient.gauge(GAUGE_NAME_FEATURE_VALUE_PERCENTILE_95, 0, tags);
223231
}
224232
statsDClient.gauge(GAUGE_NAME_FEATURE_VALUE_PERCENTILE_95, p95, tags);
233+
234+
double p99 = new Percentile().evaluate(values, 99);
235+
if (p99 < 0) {
236+
statsDClient.gauge(GAUGE_NAME_FEATURE_VALUE_PERCENTILE_99, 0, tags);
237+
}
238+
statsDClient.gauge(GAUGE_NAME_FEATURE_VALUE_PERCENTILE_99, p99, tags);
225239
}
226240
}
227241

0 commit comments

Comments
 (0)