fix(metrics): use Unix()*1000 for V2 timeseries API timestamps#58
Closed
cballou wants to merge 1 commit into
Closed
fix(metrics): use Unix()*1000 for V2 timeseries API timestamps#58cballou wants to merge 1 commit into
cballou wants to merge 1 commit into
Conversation
…s API timestamps The Datadog V2 timeseries query API expects millisecond timestamps, but using time.Time.UnixMilli() directly caused query failures. The root cause is that parseTimeParam returns time values with nanosecond precision (from time.Now() and time.Duration arithmetic), and UnixMilli() faithfully includes the sub-second millisecond component. This produces timestamps that are not on clean second boundaries, which the API rejects or misinterprets. Switching to Unix() * 1000 truncates sub-second precision and produces second-aligned millisecond timestamps that the API accepts reliably.
Collaborator
|
@cballou mind fixing the failure? If not I'm happy to pick this up, I suspect this might exist on other APIs as well so that's a good catch. |
platinummonkey
added a commit
that referenced
this pull request
Feb 13, 2026
…rseTimeToUnixMilli Moves the Unix()*1000 fix from the metrics V2 callsite into ParseTimeToUnixMilli so all callers (logs, RUM, error tracking, metrics) produce second-aligned timestamps by default. Fixes the CI build failure from #58 where tests referenced an undefined parseTimeParam symbol. - Change ParseTimeToUnixMilli to use Unix()*1000 instead of UnixMilli() - Simplify metrics V2 query to use ParseTimeToUnixMilli directly - Fix test references from parseTimeParam to util.ParseTimeToUnixMilli Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4 tasks
Collaborator
|
merged into #61 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
time.Time.UnixMilli()withUnix() * 1000to produce second-aligned millisecond timestamps that the Datadog V2 API accepts reliablyDetails
parseTimeParamreturnstime.Timevalues with nanosecond precision (fromtime.Now()andtime.Durationarithmetic).UnixMilli()faithfully includes the sub-second millisecond component, producing timestamps that are not on clean second boundaries. The API rejects or misinterprets these.Unix() * 1000truncates sub-second precision and produces second-aligned millisecond timestamps.Test plan
pup metrics querywith V2 timeseries endpoint and confirm queries succeed