-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add :metrics option to capture headers #625
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Many JS driver users will appreciate this feature. I made a few suggestions.
Can we add another method to Client as a shorthand for setting the /**
* Executes a query via the FaunaDB Query API.
* See the [docs](https://app.fauna.com/documentation/reference/queryapi),
* and the query functions in this documentation.
* @param expression {module:query~ExprArg}
* The query to execute. Created from {@link module:query} functions.
* @param {?Object} options
* Object that configures the current query, overriding FaunaDB client options.
* @param {?string} options.secret FaunaDB secret (see [Reference Documentation](https://app.fauna.com/documentation/intro/security))
* @return {external:Promise<Object>} An object containing the FaunaDB response object and the list of query metrics incurred by the request.
*/
Client.prototype.queryWithMetrics = function(expression, options) {
options = Object.assign({}, options, { withMetrics: true })
return this._execute('POST', '', query.wrap(expression), null, options)
} |
Co-authored-by: Cleve Stuart <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor suggestions.
Also, we should include a test and an update to README.md
describing this feature.
Co-authored-by: Cleve Stuart <[email protected]>
Notes
Current limitations of the JS driver prevent easy access to usage metrics provided in the response headers from the DB. This PR adds a
:metrics
option to allow programmatic access to those metrics.How to test
yarn test