My approach to figuring that out is to monkey-patch Term.prototype.run, simplified this is what it boils down to:
// Store the original .run()
const run = r._Term.prototype.run;
r._Term.prototype.run = function inspectRun(...args) {
// ...log the query...
return run.call(this, ...args).then(result => {
// ...log how much time the query took...
return result;
})
}
Question: Is r._Term pretty future-proof? If not, is this something that could live in core? I know it's been very useful for us!
I build a tiny module to figure out which queries are run and how long they take to complete: https://github.com/withspectrum/rethinkdb-inspector
My approach to figuring that out is to monkey-patch
Term.prototype.run
, simplified this is what it boils down to:Question: Is r._Term pretty future-proof? If not, is this something that could live in core? I know it's been very useful for us!