Skip to content

Commit 3c5f412

Browse files
committed
doc: add comments for #validateEmfTimestamp inside setTimestamp function
1 parent 16f893b commit 3c5f412

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/metrics/src/Metrics.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,13 @@ class Metrics extends Utility implements MetricsInterface {
587587
* @param timestamp - The timestamp to set, which can be a number or a Date object.
588588
*/
589589
public setTimestamp(timestamp: number | Date): void {
590+
/**
591+
* The timestamp must be a Date object or an integer representing an epoch time.
592+
* This should not exceed 14 days in the past or be more than 2 hours in the future.
593+
* Any metrics failing to meet this criteria will be skipped by Amazon CloudWatch.
594+
* See: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html
595+
* See: https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch-Logs-Monitoring-CloudWatch-Metrics.html
596+
**/
590597
if (!this.#validateEmfTimestamp(timestamp)) {
591598
this.#logger.warn(
592599
"This metric doesn't meet the requirements and will be skipped by Amazon CloudWatch. " +

0 commit comments

Comments
 (0)