Skip to content

Allow setting timestamp of metrics. #69

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

Merged
merged 4 commits into from
Nov 25, 2020
Merged

Conversation

Grundlefleck
Copy link
Contributor

Issue #, if available: 61
#61

Description of changes:
Adds the MetricsLogger.setTimestamp() method.

One aspect I think core maintainers will have a much better sense of, if I set the timestamp should that be preserved across calls to flush()? I wasn't 100% sure what would be desired behaviour, so I took a guess and went for "yes, if set explicitly, preserve". For my own use case described in #61, I will be calling setTimeout in 100% of MetricsContext instances generated, so it would be irrelevant anyway.

Another guess I made was that if the timestamp is not set explicitly, the MetricsContext should reset the meta.Timestamp field to new Date(). I think this is less surprising behaviour for users who never call setTimestamp. Plus if I preserved the timestamp when not explicitly set, that would change the behaviour for all existing users, I thought it would only make sense to change behaviour for callers who are "opting in" by using setTimeout.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Adds the MetricsLogger.setTimestamp() call as discussed in awslabs#61
@jaredcnance
Copy link
Member

Thanks for the PR! I think this is the correct behavior. Preserving timestamp across flushes makes sense.

README.md Outdated

Sets the CloudWatch [timestamp](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#about_timestamp) that extracted metrics are associated with. If not set a default value of `new Date()` will be used.

If set, timestamp will be preserved across calls to flush().
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...for a given MetricsLogger instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified in a subsequent commit.

README.md Outdated

Examples:

```py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have updated, also removed the single other use of ```py that lead to my copypasta fail.

@Grundlefleck
Copy link
Contributor Author

@jaredcnance I can't see the CodeBuild failures but given
a) tests pass locally* and
b) CodeBuild passed on a previous commit and the only changes where to README.md

Does the build maybe need a retry? If you find it is something with the code please let me know and I'll try to reproduce and address it.

* I know, I know, "works on my machine" 😆

@jaredcnance
Copy link
Member

Build was failing because we are getting throttled by Docker Hub when pulling the CW Agent. We need to switch to using ECR, I believe. I rebuilt it and it passed, but I'm not sure why the status check hasn't been reported back to GitHub. I'm approving and merging the PR. Thanks!

@jaredcnance jaredcnance merged commit 2ec8a84 into awslabs:master Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants