faastjs > FaastModuleProxy > costSnapshot
FaastModuleProxy.costSnapshot() method
Get a near real-time cost estimate of cloud function invocations.
Signature:
costSnapshot(): Promise<CostSnapshot>;
Returns:
Promise<CostSnapshot>
a Promise for a CostSnapshot.
Remarks
A cost snapshot provides a near real-time estimate of the costs of the cloud functions invoked. The cost estimate only includes the cost of successfully completed calls. Unsuccessful calls may lack the data required to provide cost information. Calls that are still in flight are not included in the cost snapshot. For this reason, it is typically a good idea to get a cost snapshot after awaiting the result of FaastModule.cleanup().
Code example:
const faastModule = await faast("aws", m);
try {
// invoke cloud functions on faastModule.functions.*
} finally {
await faastModule.cleanup();
const costSnapshot = await faastModule.costSnapshot();
console.log(costSnapshot);
}