Skip to content

Use time ranges relative to the current time in code examples #2444

@magnusbaeck

Description

@magnusbaeck

Is your feature request related to a problem? Please describe.
At least one code example, v2/metrics/QueryTimeseriesData.go (I think; it's the one rendered at https://docs.datadoghq.com/api/latest/metrics/#query-timeseries-data-across-multiple-products anyway) uses an absolute timestamp range in the query, thus requiring the copying-and-pasting reader to manually adjust the range unless s/he happens to have meaningful Datadog data in that time range.

Describe the solution you'd like
Consider using a relative range like in the equivalent v1 example (https://docs.datadoghq.com/api/latest/metrics/#query-timeseries-points) so that the example code works out of the box (as long as you have at least one reporting host). There might be similar cases in other examples. It's helpful if examples can be compiled as-is.

Also, using a relative measure based on time.Now().UnixMillis() is instantly understandable. An opaque large integer is not.

Describe alternatives you've considered
N/A

Additional context
I tried the v1 endpoint first before realizing that it didn't support formulas, and I therefore switched to the v2 endpoint. Because the v1 example used a relative time range it didn't occur to me that I'd have to adjust that. I didn't, so the v2 query didn't return any results. I eventually filed Zendesk ticket 1592754 thinking this was a bug in the platform, which it of course wasn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions