From d5fe189b68b60e315d3116ba5c693de6104595bf Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Wed, 1 Apr 2020 15:33:33 -0700 Subject: [PATCH] Include the total number of touched nodes in the query metrics. (#5073) 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 ed60090fb90..338fce43cc0 100644 --- a/edgraph/server.go +++ b/edgraph/server.go @@ -987,6 +987,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)) }