diff --git a/src/autoscaler/collection/TSDCache.go b/src/autoscaler/collection/TSDCache.go index 0079fd9c4..b717595f6 100644 --- a/src/autoscaler/collection/TSDCache.go +++ b/src/autoscaler/collection/TSDCache.go @@ -47,7 +47,7 @@ func (c *TSDCache) binarySearch(t int64) int { if l > r { return l } - m := (l + r) / 2 + m := l + (r-l)/2 if t <= c.data[m%c.capacity].GetTimestamp() { r = m - 1 } else { diff --git a/src/autoscaler/metricscollector/server/metric_handler.go b/src/autoscaler/metricscollector/server/metric_handler.go index 8f624a2f9..08081a744 100644 --- a/src/autoscaler/metricscollector/server/metric_handler.go +++ b/src/autoscaler/metricscollector/server/metric_handler.go @@ -135,7 +135,7 @@ func (h *MetricHandler) GetMetricHistories(w http.ResponseWriter, r *http.Reques if instanceIndex >= 0 { labels[models.MetricLabelInstanceIndex] = fmt.Sprintf("%d", instanceIndex) } - mtrcs, ok := h.queryFunc(appId, start, end, order, labels) + mtrcs, ok := h.queryFunc(appId, start, end+1, order, labels) if !ok { h.logger.Debug("get-metric-histories-query-cache-miss", lager.Data{"appId": appId, "metrictype": metricType, "instanceIndex": instanceIndex, "start": start, "end": end, "order": order}) mtrcs, err = h.database.RetrieveInstanceMetrics(appId, int(instanceIndex), metricType, start, end, order)