Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
bml1g12 opened this issue Oct 4, 2024 · 4 comments · Fixed by #3310
Closed
2 tasks done

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

bml1g12 opened this issue Oct 4, 2024 · 4 comments · Fixed by #3310
Assignees
Labels
confirmed The scope is clear, ready for implementation feature-request This item refers to a feature request for an existing or new utility help-wanted We would really appreciate some support from community for this one metrics This item relates to the Metrics Utility

Comments

@bml1g12
Copy link

bml1g12 commented Oct 4, 2024

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.

@bml1g12 bml1g12 added feature-request This item refers to a feature request for an existing or new utility triage This item has not been triaged by a maintainer, please wait labels Oct 4, 2024
@dreamorosi
Copy link
Contributor

Hi @bml1g12, thanks for opening this feature request!

I think it's more than valid since as you pointed out, the feature itself already present in another version of Powertools for AWS.

In terms of DX, we'll most likely align with the one introduced in the Python version rather than adding a new parameter to the method to add a metric.

I'll add this to the backlog and mark it as open for contributors. If anyone is interested to take it, please leave a comment so we can assign it you. Feel free to ask any questions.

If it's not picked up, we'll prioritize it to be worked on within the team as time allows it.

@dreamorosi dreamorosi added metrics This item relates to the Metrics Utility confirmed The scope is clear, ready for implementation and removed triage This item has not been triaged by a maintainer, please wait labels Oct 4, 2024
@dreamorosi dreamorosi moved this from Triage to Backlog in Powertools for AWS Lambda (TypeScript) Oct 4, 2024
@bml1g12
Copy link
Author

bml1g12 commented Oct 4, 2024

Hi @bml1g12, thanks for opening this feature request!

I think it's more than valid since as you pointed out, the feature itself already present in another version of Powertools for AWS.

In terms of DX, we'll most likely align with the one introduced in the Python version rather than adding a new parameter to the method to add a metric.

I'll add this to the backlog and mark it as open for contributors. If anyone is interested to take it, please leave a comment so we can assign it you. Feel free to ask any questions.

If it's not picked up, we'll prioritize it to be worked on within the team as time allows it.

That makes sense, thanks

@dreamorosi dreamorosi added the help-wanted We would really appreciate some support from community for this one label Oct 4, 2024
@dreamorosi
Copy link
Contributor

dreamorosi commented Oct 4, 2024

Also, @bml1g12, I missed your other question about the timestamp.

The timestamp is generated here, which is called during the publishStoredMetrics() method.

We should clarify this in the API docs of the feature.

@arnabrahman
Copy link
Contributor

I will work on this ✋️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed The scope is clear, ready for implementation feature-request This item refers to a feature request for an existing or new utility help-wanted We would really appreciate some support from community for this one metrics This item relates to the Metrics Utility
Projects
3 participants