From faf6a8d0b755c7559cee7572eb9aba69bbb26bc9 Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Tue, 31 Mar 2020 17:39:16 -0700 Subject: [PATCH] Include the total number of touched nodes in the query metrics. Total is stored under a key called "_total". --- edgraph/server.go | 5 +++++ query/query4_test.go | 1 + 2 files changed, 6 insertions(+) diff --git a/edgraph/server.go b/edgraph/server.go index 3dc554c0730..0b5327c3580 100644 --- a/edgraph/server.go +++ b/edgraph/server.go @@ -984,6 +984,11 @@ func processQuery(ctx context.Context, qc *queryContext) (*api.Response, error) resp.Metrics = &api.Metrics{ NumUids: er.Metrics, } + var total uint64 + for _, num := range resp.Metrics.NumUids { + total += num + } + resp.Metrics.NumUids["_total"] = total return resp, err } diff --git a/query/query4_test.go b/query/query4_test.go index 52a13a5e38c..3200a7ff181 100644 --- a/query/query4_test.go +++ b/query/query4_test.go @@ -1545,4 +1545,5 @@ func TestNumUids(t *testing.T) { metrics := processQueryForMetrics(t, query) require.Equal(t, metrics.NumUids["friend"], uint64(10)) require.Equal(t, metrics.NumUids["name"], uint64(16)) + require.Equal(t, metrics.NumUids["_total"], uint64(26)) }