DataDog / datadog-lambda-js

The Datadog AWS Lambda Library for Node
Apache License 2.0
113 stars 35 forks source link

sendDistributionMetricWithDate ignores date when using statsd #394

Closed Nevon closed 1 year ago

Nevon commented 1 year ago

Expected Behavior

Calling sendDistributionMetricWithDate with a date should result in skipping client side aggregation and instead submit a metric for the past.

Actual Behavior

When the metric is submitted via statsd, the timestamp argument is ignored and not included in the statsd datagram, making the metric be submitted for the current timestamp instead.

https://github.com/DataDog/datadog-lambda-js/blob/364d862e127123f8eea177619907966ecf41f80e/src/metrics/listener.ts#L129-L139

The distribution stat function from hot-shots does not accept a timestamp, which I'm guessing is why this wasn't implemented in datadog-lambda-js in the first place. I have reported this here. I'm not sure if it would work to manually construct the datagram rather than using the distribution stats function, but it might be a possible workaround.

Steps to Reproduce the Problem

  1. Use the Datadog lambda extension
  2. Call sendDistributionMetricWithDate with a timestamp in the past
  3. See that the metric is recorded with the current timestamp
tianchu commented 1 year ago

@Nevon you were correct, historically dogstatsd protocol didn't have a field for timestamp. Do you mind filing a format FR to Datadog support with some business context? Now it's technically feasible, it's essentially a priority question for us.

tianchu commented 1 year ago

Closing due to lack of activities. For anyone else running into the similar need, feel free to reopen or submit a FR through the Datadog Support.