import * as mongoose from "mongoose";
...
this.mongoose.connection['db']['stats']((err, stats) => {
if (err) {
metricsLogger.logKeyValues( { ERROR: err });
return;
}
metricsLogger.logKeyValues({AvgObjectSize: stats.avgObjSize, fsTotalSize: stats.fsTotalSize,
fsUsedSize: stats.fsUsedSize});
});
Here's some sample code I'm playing around with. The stats object contains data that looks like this:
db="xxx" collections="1" views="0" objects="75" avgObjSize="731.3466666666667" dataSize="54851" storageSize="45056" numExtents="0" indexes="1" indexSize="36864" fsUsedSize="6353461248" fsTotalSize="43985149952" ok="1"
I'm hoping that there are latency and request count statistics somewhere stored in the mongoose connection... Or maybe someone knows if I can intercept all requests and capture my own latency metrics manually somehow?
Thanks,