mapbox / dyno

simple dynamodb client
MIT License
78 stars 28 forks source link

Add costLogger #158

Closed miafan23 closed 1 year ago

miafan23 commented 1 year ago

Added a new type of logger that logs structured capacity usage data (ReadCapacityUnits and WriteCapacityUnits) that we can easily use for all our services to get a clear picture of which requests from which service are responsible for our costs.

Detect if the costLogger is set in options, and if it is:

Why don't we use the logger option of DynamoDBClient? It is bonded with the instance, so it is impossible to use different logger for each endpoint while sharing the DynamoDBClient instance.

miafan23 commented 1 year ago

@Miroko Thank you so much for catching this. We did miss this method! I did some updates to make the dynamoInstance to be as part of the options so that it is easy to reuse the client for multi method. The usage could be seen in this unit test