Skip to content

Feature request: Ability to post custom timestamps with metrics #3153

Closed
@bml1g12

Description

@bml1g12

Use case

I've setup a cron job to log daily costs from cost explorer to cloudwatch metrics (i.e. looking at the previous day's data for each invocation). I realised today that it might not be possible to assign the correct timestamp using powertools for this use case, as I think it assumes the timestamp is the time of publishing?

Related to this, I could not see any documentation on https://docs.powertools.aws.dev/lambda/typescript/latest/core/metrics/ for how the timestamp is determined (is it time of addMetrics() or time of .flush()?

Solution/User Experience

Allow specification of timestamp with the addMetric() call

Alternative solutions

In the mean time, I think I'll need to use https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cloudwatch/command/PutMetricDataCommand/

I notice this feature seems to already be available in the Python toolkit: https://docs.powertools.aws.dev/lambda/python/latest/core/metrics/#changing-default-timestamp and maybe not in Java

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

Labels

confirmedThe scope is clear, ready for implementationfeature-requestThis item refers to a feature request for an existing or new utilityhelp-wantedWe would really appreciate some support from community for this onemetricsThis item relates to the Metrics Utility

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions