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:
Add ReturnConsumedCapacity: INDEXES parameter to all executed requests to DynamoDB
On return from each request, extracted WriteCapacityUnits and ReadCapacityUnits from the response and call the logger function with them.
If there is a dynoInstance in the option, the DynamoDBCLient will be reused
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.
@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
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 inoptions
, and if it is:ReturnConsumedCapacity: INDEXES
parameter to all executed requests to DynamoDBdynoInstance
in the option, theDynamoDBCLient
will be reusedWhy 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.