fauna / faunadb-jvm

Scala and Java driver for FaunaDB v4

Home Page:https://fauna.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expose billing metrics

berlix opened this issue · comments

Responses from Fauna include all sorts of extra headers:

  'x-byte-read-ops': '34',
  'x-byte-write-ops': '0',
  'x-compute-ops': '2',
  'x-faunadb-build': '20.11.00.rc8-01f9c94',
  'x-query-bytes-in': '120',
  'x-query-bytes-out': '4459',
  'x-query-time': '7',
  'x-read-ops': '27',
  'x-storage-bytes-read': '3047',
  'x-storage-bytes-write': '0',
  'x-txn-retries': '0',
  'x-txn-time': '1605653866258457',
  'x-write-ops': '0'

(see docs)

Of these, only x-txn-time is exposed by the JVM driver.

I can see a few ways in which those metrics could be exposed:

  • Like x-txn-time is (which is exposed through long FaunaClient.getLastTxnTime()).
  • By recording them onto the MetricRegistry which is already getting injected into FaunaClient.
  • By adding a method CompletableFuture<Pair<Value, Map<String, String>> queryWithHeaders(...) to FaunaClient which returns the response headers.
  • By making FaunaClient's constructor public so that one can decorate the Connection object to expose the metrics.
  • By enabling the injection of a ConnectionFactory into FaunaClient.Builder so that one can decorate the Connection object to expose the metrics.

I suppose that the second approach would the cleanest one.

Thanks! We have an internal ticket to fix this.

Hi Summer, that's great to hear! Any ETA on that?

Not yet--it's in triage.

@berlix I believe the release yesterday has fixed this. Please try it out and let us know if we need to reopen this issue!