Num_uids query metrics returns a count with empty key

Moved from GitHub dgraph/4367

Posted by danielmai:

What version of Dgraph are you using?

master (747c8478c6b1e023246b6b91b68072b72a3f1036)

Have you tried reproducing the issue with the latest release?

No, query metrics aren’t in the latest release (v1.1.0).

What is the hardware spec (RAM, OS)?

Ubuntu Linux

Steps to reproduce the issue (command/config used to run Dgraph).

  1. Run a Dgraph cluster
  2. Run a query using uid()
{
  q(func: uid(0x1))
}
  1. The query metrics for num_uids has an empty string for a JSON key:
{
  "data": {
    "q": []
  },
  "extensions": {
...
    "metrics": {
      "num_uids": {
        "": 1
      }
    }
  }
}

If I run the following query, I get a different num_uids count based on the number of uid() lookups there are.

{
  q(func: uid(0x1,0x2,0x3)) 
}
{
  "data": {
    "q": []
  },
  "extensions": {
...
    "metrics": {
      "num_uids": {
        "": 3
      }
    }
  }
}

Expected behaviour and actual result.

It’s not obvious to me what "": 3 is referring to at first glance. Can it have a better name?

martinmr commented :

The key is supposed to be the predicate the uids are associated with. But I guess since the query is not asking for any predicates, so the uids are not associated to one.

I think fixing the issue would be to associate these uids with a special keyword (e.g
_unknown_predicate_). The code changes are simple but the hard part would be choosing a keyword.