Skip to content

client-cloudwatch not taking milliseconds since 1970 #6862

@codermpl

Description

@codermpl

Checkboxes for prior research

Describe the bug

client-cloudwatch MetricDatum interface says.

    /**
     * <p>The time the metric data was received, expressed as the number of milliseconds
     *             since Jan 1, 1970 00:00:00 UTC.</p>
     * @public
     */
    Timestamp?: Date | undefined;

This seems to be conflicting. The comment says it should take number of ms, but the type signature says it should take a Date object. API documentation confirms it's supposed to take ms since 1970: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html

I'd be happy if it could take either Date or ms as a number. But seems like it should at least take ms since that's what the API spec says.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

"@aws-sdk/client-cloudwatch": "^3.734.0",

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

22

Reproduction Steps

Pass a number in Timestamp field for PutMetricData

Observed Behavior

Fails

Expected Behavior

Timestamp property accepts ms since 1970

Possible Solution

Allow passing either a Date or number to the Timestamp property.

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p3This is a minor priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions