Skip to content
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
10 changes: 10 additions & 0 deletions go/internal/feast/metrics/lookup_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ func (m *LookupMetricsAggregator) RecordFromFeatureVectors(vectors []*onlineserv
return
}
for _, vector := range vectors {
if vector.FeatureViewName == "" {
// Entity/join-key columns don't belong to a feature view; skip them
// so they aren't misreported as "unknown" feature lookups.
continue
}
for _, status := range vector.Statuses {
m.Record(vector.Name, vector.FeatureViewName, status)
}
Expand All @@ -80,6 +85,11 @@ func (m *LookupMetricsAggregator) RecordFromRangeFeatureVectors(vectors []*onlin
return
}
for _, vector := range vectors {
if vector.FeatureViewName == "" {
// Entity/join-key columns don't belong to a feature view; skip them
// so they aren't misreported as "unknown" feature lookups.
continue
}
for _, entityStatuses := range vector.RangeStatuses {
for _, status := range entityStatuses {
m.Record(vector.Name, vector.FeatureViewName, status)
Expand Down
60 changes: 60 additions & 0 deletions go/internal/feast/metrics/lookup_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,66 @@ func TestRecordFromFeatureVectors(t *testing.T) {
assert.Equal(t, int64(2), totalByFeature["fv_a__f2"])
}

func TestRecordFromFeatureVectors_SkipsEntityColumns(t *testing.T) {
fake := &fakeStatsdClient{}
agg := newTestAggregator(fake)

vectors := []*onlineserving.FeatureVector{
{
Name: "exp_user_id",
FeatureViewName: "",
Statuses: []serving.FieldStatus{serving.FieldStatus_PRESENT},
},
{
Name: "fv_a__f1",
FeatureViewName: "fv_a",
Statuses: []serving.FieldStatus{serving.FieldStatus_NOT_FOUND},
},
}

agg.RecordFromFeatureVectors(vectors)
agg.Emit()

totalCalls := filterCalls(fake.calls, LookupRequestsMetric)
assert.Len(t, totalCalls, 1)
assert.Equal(t, "fv_a__f1", findTag(totalCalls[0].tags, "feature:"))

for _, c := range fake.calls {
assert.NotContains(t, c.tags, "feature_view:unknown")
assert.NotContains(t, c.tags, "feature:exp_user_id")
}
}

func TestRecordFromRangeFeatureVectors_SkipsEntityColumns(t *testing.T) {
fake := &fakeStatsdClient{}
agg := newTestAggregator(fake)

vectors := []*onlineserving.RangeFeatureVector{
{
Name: "eg_user_id",
FeatureViewName: "",
RangeStatuses: [][]serving.FieldStatus{{serving.FieldStatus_PRESENT}},
},
{
Name: "sfv__f1",
FeatureViewName: "sfv",
RangeStatuses: [][]serving.FieldStatus{{serving.FieldStatus_NOT_FOUND}},
},
}

agg.RecordFromRangeFeatureVectors(vectors)
agg.Emit()

totalCalls := filterCalls(fake.calls, LookupRequestsMetric)
assert.Len(t, totalCalls, 1)
assert.Equal(t, "sfv__f1", findTag(totalCalls[0].tags, "feature:"))

for _, c := range fake.calls {
assert.NotContains(t, c.tags, "feature_view:unknown")
assert.NotContains(t, c.tags, "feature:eg_user_id")
}
}

func TestRecordFromRangeFeatureVectors(t *testing.T) {
fake := &fakeStatsdClient{}
agg := newTestAggregator(fake)
Expand Down
Loading