tracker icon indicating copy to clipboard operation
tracker copied to clipboard

Send trace headers with database requests

Open sleepycat opened this issue 3 years ago • 0 comments

This commit moves the initialization of the database query/transaction objects into the same function that creates the graphql context per request. With the request in hand we're basically just passing any trace headers that are included into the db connection config options.

The end result is that something like this:

$ curl -s -H "x-request-id: d7c32387-3feb-452b-8df1-2d8338b3ea22" -H "Content-Type: application/json" -d '{"query": "{findVerifiedDomains(first: 1) { totalCount  }}"}' http://localhost:4000/graphql | jq .
{
  "data": {
    "findVerifiedDomains": {
      "totalCount": 22754

    }

  }

}

Results in a request to the datbase like this:

POST /_db/track_dmarc/_api/cursor HTTP/1.1
x-request-id: d7c32387-3feb-452b-8df1-2d8338b3ea22
authorization: Basic asdfasdf
content-type: application/json
x-arango-version: 30400
content-length: 1617
Host: localhost:8529
Connection: keep-alive
...

This should give us better visibility into API <> DB communications.

Closes #3172

sleepycat avatar May 10 '22 19:05 sleepycat