getmoto / moto

A library that allows you to easily mock out tests based on AWS infrastructure.
http://docs.getmoto.org/en/latest/
Apache License 2.0
7.6k stars 2.04k forks source link

KinesisBackend.put_record should notify cloudwatch metrics #7498

Open LMaterne opened 6 months ago

LMaterne commented 6 months ago

https://github.com/getmoto/moto/blob/005ead33329c04faf3165840c5297bb4cbe44ed3/moto/kinesis/models.py#L410 should include some update to cloudwatch metrics at least for the IncomingRecords and IncomingBytes Basic Stream-level Metrics.

bblommers commented 6 months ago

Hi @LMaterne, I'll mark it as an enhancement.

Can you elaborate a bit on what your test would look like?

The docs specifically mention that The metrics [..] are pushed to CloudWatch every minute., but that approach doesn't make a lot of sense for unit tests, as (I hope that) they don't run for that long.

I can think of a few approaches around this, but having some insight into how this feature would be used would be helpful to make sure that the solution makes sense.

LMaterne commented 6 months ago

My concrete test case looks like this: I want to test a lambda function that scales the number of shard counts in provisioned kinesis streams based on the amount of incoming traffic. The logic uses the stream metrics for that. The integration test would look like putting some messages into a newly created kinesis stream and checking if the lambda function scales the stream correctly. My current solution: Do not put records into the stream but directly update the cloudwatch metrics.