DataDog / datadog-lambda-js

The Datadog AWS Lambda Library for Node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sendDistributionMetricWithDate ignores date when using statsd

Nevon opened this issue · comments

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.

public sendDistributionMetricWithDate(
name: string,
value: number,
metricTime: Date,
forceAsync: boolean,
...tags: string[]
) {
if (this.isAgentRunning) {
this.statsDClient?.distribution(name, value, undefined, tags);
return;
}

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

@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.

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.