Instead, the start time should be time.Now() with the seconds truncated (i.e. rounded down to the nearest minute). Since the Metrics API only stores data at minutely granularity, using time.Now() is effectively rounding up to the next minute, which makes the effective delay less than the configured delay.
For example:
Delay (configured): 120 seconds
Current time: 00:10:05
Query interval (actual): 00:08:05 / PT1M
Query interval (effective): 00:09:00 / PT1M (only metrics with timestamp 00:09:00 will be matched)
The query interval
timeFrom
is taken by applying the configured delay totime.Now()
https://github.com/Dabz/ccloudexporter/blob/77195baebee292593d6a56255a971e5c415beb41/cmd/internal/collector/query.go#L72Instead, the start time should be
time.Now()
with the seconds truncated (i.e. rounded down to the nearest minute). Since the Metrics API only stores data at minutely granularity, usingtime.Now()
is effectively rounding up to the next minute, which makes the effective delay less than the configured delay.For example:
120 seconds
00:10:05
00:08:05 / PT1M
00:09:00 / PT1M
(only metrics with timestamp00:09:00
will be matched)65 seconds
(00:10:05 - 00:09:00)