MM-58281 Change performance timestamps to be floats (#27046)
* MM-58281 Change performance timestamps to be floats * Commit missed line
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3e734ee949
Коммит
b9f7d38cb1
@@ -111,8 +111,8 @@ func TestSubmitMetrics(t *testing.T) {
|
||||
|
||||
resp, err := th.Client.SubmitClientMetrics(th.Context.Context(), &model.PerformanceReport{
|
||||
Version: "0.1",
|
||||
Start: time.Now().Add(-1 * time.Minute).UnixMilli(),
|
||||
End: time.Now().UnixMilli(),
|
||||
Start: float64(time.Now().Add(-1 * time.Minute).UnixMilli()),
|
||||
End: float64(time.Now().UnixMilli()),
|
||||
Counters: []*model.MetricSample{
|
||||
{Metric: model.ClientLongTasks, Value: 1},
|
||||
},
|
||||
@@ -145,8 +145,8 @@ func TestSubmitMetrics(t *testing.T) {
|
||||
|
||||
resp, err := th.Client.SubmitClientMetrics(th.Context.Context(), &model.PerformanceReport{
|
||||
Version: "0.1",
|
||||
Start: time.Now().Add(-1 * time.Minute).UnixMilli(),
|
||||
End: time.Now().UnixMilli(),
|
||||
Start: float64(time.Now().Add(-1 * time.Minute).UnixMilli()),
|
||||
End: float64(time.Now().UnixMilli()),
|
||||
Counters: []*model.MetricSample{
|
||||
{Metric: model.ClientLongTasks, Value: 1},
|
||||
},
|
||||
|
||||
@@ -36,7 +36,7 @@ var (
|
||||
type MetricSample struct {
|
||||
Metric MetricType `json:"metric"`
|
||||
Value float64 `json:"value"`
|
||||
Timestamp int64 `json:"timestamp,omitempty"`
|
||||
Timestamp float64 `json:"timestamp,omitempty"`
|
||||
Labels map[string]string `json:"labels,omitempty"`
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ type PerformanceReport struct {
|
||||
Version string `json:"version"`
|
||||
ClientID string `json:"client_id"`
|
||||
Labels map[string]string `json:"labels"`
|
||||
Start int64 `json:"start"`
|
||||
End int64 `json:"end"`
|
||||
Start float64 `json:"start"`
|
||||
End float64 `json:"end"`
|
||||
Counters []*MetricSample `json:"counters"`
|
||||
Histograms []*MetricSample `json:"histograms"`
|
||||
}
|
||||
@@ -70,8 +70,8 @@ func (r *PerformanceReport) IsValid() error {
|
||||
}
|
||||
|
||||
now := time.Now().UnixMilli()
|
||||
if r.End < now-performanceReportTTLMilliseconds {
|
||||
return fmt.Errorf("report is outdated: %d", r.End)
|
||||
if r.End < float64(now-performanceReportTTLMilliseconds) {
|
||||
return fmt.Errorf("report is outdated: %f", r.End)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -23,8 +23,8 @@ func TestPerformanceReport_IsValid(t *testing.T) {
|
||||
report: &PerformanceReport{
|
||||
Version: "0.1.0",
|
||||
Labels: map[string]string{"platform": "linux"},
|
||||
Start: time.Now().UnixMilli() - 10000,
|
||||
End: time.Now().UnixMilli(),
|
||||
Start: float64(time.Now().UnixMilli() - 10000),
|
||||
End: float64(time.Now().UnixMilli()),
|
||||
},
|
||||
expected: nil,
|
||||
},
|
||||
@@ -38,8 +38,8 @@ func TestPerformanceReport_IsValid(t *testing.T) {
|
||||
report: &PerformanceReport{
|
||||
Version: "2.0.0",
|
||||
Labels: map[string]string{"platform": "linux"},
|
||||
Start: time.Now().UnixMilli() - 10000,
|
||||
End: time.Now().UnixMilli(),
|
||||
Start: float64(time.Now().UnixMilli() - 10000),
|
||||
End: float64(time.Now().UnixMilli()),
|
||||
},
|
||||
expected: fmt.Errorf("report version is not supported: server version: 0.1.0, report version: 2.0.0"),
|
||||
},
|
||||
@@ -48,8 +48,8 @@ func TestPerformanceReport_IsValid(t *testing.T) {
|
||||
report: &PerformanceReport{
|
||||
Version: "0.1.0",
|
||||
Labels: map[string]string{"platform": "linux"},
|
||||
Start: time.Now().UnixMilli(),
|
||||
End: time.Now().Add(-1 * time.Hour).UnixMilli(),
|
||||
Start: float64(time.Now().UnixMilli()),
|
||||
End: float64(time.Now().Add(-1 * time.Hour).UnixMilli()),
|
||||
},
|
||||
expected: fmt.Errorf("report timestamps are erroneous"),
|
||||
},
|
||||
@@ -58,10 +58,10 @@ func TestPerformanceReport_IsValid(t *testing.T) {
|
||||
report: &PerformanceReport{
|
||||
Version: "0.1.0",
|
||||
Labels: map[string]string{"platform": "linux"},
|
||||
Start: time.Now().Add(-7 * time.Minute).UnixMilli(),
|
||||
End: outdatedTimestamp,
|
||||
Start: float64(time.Now().Add(-7 * time.Minute).UnixMilli()),
|
||||
End: float64(outdatedTimestamp),
|
||||
},
|
||||
expected: fmt.Errorf("report is outdated: %d", outdatedTimestamp),
|
||||
expected: fmt.Errorf("report is outdated: %f", float64(outdatedTimestamp)),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user