| 1 |
From: Daniel Swarbrick <[email protected]> |
| 2 |
Date: Fri, 28 Jul 2023 03:31:51 +0800 |
| 3 |
Subject: Use explicit int64 types for millisecond-resolution timestamps |
| 4 |
|
| 5 |
Bug: https://github.com/prometheus/client_golang/issues/1132 |
| 6 |
Last-Update: 2022-09-16 |
| 7 |
|
| 8 |
Untyped ints on 32-bit archs will lead to overflows when trying to store |
| 9 |
millisecond-resolution Unix timestamps. This patch specifies them as int64. |
| 10 |
--- |
| 11 |
api/prometheus/v1/api.go | 4 ++-- |
| 12 |
api/prometheus/v1/api_test.go | 4 ++-- |
| 13 |
2 files changed, 4 insertions(+), 4 deletions(-) |
| 14 |
|
| 15 |
diff --git a/api/prometheus/v1/api.go b/api/prometheus/v1/api.go |
| 16 |
index 8a72f9b..c83e185 100644 |
| 17 |
--- a/api/prometheus/v1/api.go |
| 18 |
+++ b/api/prometheus/v1/api.go |
| 19 |
@@ -686,8 +686,8 @@ type TSDBHeadStats struct { |
| 20 |
NumSeries int `json:"numSeries"` |
| 21 |
NumLabelPairs int `json:"numLabelPairs"` |
| 22 |
ChunkCount int `json:"chunkCount"` |
| 23 |
- MinTime int `json:"minTime"` |
| 24 |
- MaxTime int `json:"maxTime"` |
| 25 |
+ MinTime int64 `json:"minTime"` |
| 26 |
+ MaxTime int64 `json:"maxTime"` |
| 27 |
} |
| 28 |
|
| 29 |
// WalReplayStatus represents the wal replay status. |
| 30 |
diff --git a/api/prometheus/v1/api_test.go b/api/prometheus/v1/api_test.go |
| 31 |
index bacf6a0..1eb6336 100644 |
| 32 |
--- a/api/prometheus/v1/api_test.go |
| 33 |
+++ b/api/prometheus/v1/api_test.go |
| 34 |
@@ -1060,8 +1060,8 @@ func TestAPIs(t *testing.T) { |
| 35 |
"numSeries": 18476, |
| 36 |
"numLabelPairs": 4301, |
| 37 |
"chunkCount": 72692, |
| 38 |
- "minTime": 1634644800304, |
| 39 |
- "maxTime": 1634650590304, |
| 40 |
+ "minTime": int64(1634644800304), |
| 41 |
+ "maxTime": int64(1634650590304), |
| 42 |
}, |
| 43 |
"seriesCountByMetricName": []interface{}{ |
| 44 |
map[string]interface{}{ |