8000 Fix parsing metrics with decimal timestamp by nhulston · Pull Request #17 · DataDog/serverless-components · GitHub
[go: up one dir, main page]

Skip to content

Fix parsing metrics with decimal timestamp #17

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

Merged
merged 1 commit into from
May 8, 2025

Conversation

nhulston
Copy link
Contributor
@nhulston nhulston commented May 8, 2025

What does this PR do?

When receiving metrics over dogstatsd, we receive metrics in the format: metric.name:15|c|#env:dev|T1656581409, where T1656581409 is the timestamp.

We parse the timestamp as i64, which means that if the timestamp is a float such as T1656581409.123, the parse will fail, and we fallback to now.

Motivation

Just for flexibility. Even though metrics are rounded to the nearest 10 second bucket, we should still support decimal input.

E.g. v108 of datadog-lambda-python sends timestamped metrics with decimals. Therefore, we currently fallback to now since the parse as u64 fails.

Additional Notes

Describe how to test/QA your changes

I tested manually with local builds of Node+Extension, where Node was sending timestamps with a decimal:
Screenshot 2025-05-08 at 10 56 49 AM
Screenshot 2025-05-08 at 11 07 35 AM

And timestamped metrics now work as expected:
Screenshot 2025-05-08 at 10 59 58 AM

Also added a basic unit test

@nhulston nhulston marked this pull request as ready for review May 8, 2025 15:04
@nhulston nhulston force-pushed the nicholas.hulston/also-parse-float-timestamps branch from 698cce4 to 492f44f Compare May 8, 2025 15:07
@nhulston nhulston merged commit e37f0a1 into main May 8, 2025
25 checks passed
@nhulston nhulston deleted the nicholas.hulston/also-parse-float-timestamps branch May 8, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0