Skip to content

[BUG] timestamp parameter gets overwritten with execution time on lambda_metric #398

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

Closed
TheGBG opened this issue Nov 23, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@TheGBG
Copy link

TheGBG commented Nov 23, 2023

Expected Behavior

When I pass timestamp parameter to datadog_lambda.metric.lambda_metric function, the x-axis (time) of that metric on the monitor should reflect that value passed.

Actual Behavior

The value reflected is the time where the function gets called

Steps to Reproduce the Problem

I am leaving out authentication details as those are handled via env variables on the lambda.

from datadog_lambda.metric import lambda_metric

params = {
            "metric_name": "foo",
            "value": 42,
            "timestamp": 1700748937,  # 2023-11-23 15:16:37
        }
        
lambda_metric(**params)

The code is running on a docker-based lambda. I've passed the timestamp as milliseconds since the epoch, and also as seconds, and none of them seem to affect the x-axis of the monitor.

I am also aware of the following restrictions:

The timestamp associated with the metric value. Note: Metric timestamps cannot be more than ten minutes in the future or more than one hour in the past.

Source

I have also seen that this other issue on the JS API mentions that this functionality is available on Python API.

Specifications

  • Datadog Lambda Layer version: 50
  • Python version: 3.10
  • Base image: public.ecr.aws/lambda/python:3.10
  • Docker extension: public.ecr.aws/datadog/lambda-extension:5
  • Datadog library version: datadog-lambda==4.81.0

Let me know if you need me to provide more code or the Dockerfile. Thanks in advance.

@TheGBG TheGBG changed the title timestamp parameter gets overwritten with execution time on datadog_lambda.metric.lambda_metric [BUG] timestamp parameter gets overwritten with execution time on lambda_metric Nov 23, 2023
@hghotra hghotra self-assigned this Dec 13, 2023
@duncanista duncanista added the enhancement New feature or request label Feb 5, 2024
@duncanista
Copy link
Contributor

Hey @TheGBG,

This should have been explained and fixed by #501

Timestamps are only allowed from the last 4 hours, or else the Datadog backend will not acknowledge them properly.

Let me know if you have any questions. Feel free to re-open this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants