Skip to content

Commit 6f6e634

Browse files
authored
Merge pull request #96 from zianazhao/dev/timeZone
Dev/time zone
2 parents b792693 + 029afb9 commit 6f6e634

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

pkg/collector/handler_clb_private.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ func (h *ClbPrivateHandler) GetSeriesByCustom(m *metric.TcmMetric) ([]*metric.Tc
145145
}
146146
return slist, nil
147147
}
148-
149148
func (h *ClbPrivateHandler) getSeriesByMetricType(m *metric.TcmMetric, ins instance.TcInstance) ([]*metric.TcmSeries, error) {
150149
var dimensions []string
151150
for _, v := range m.Meta.SupportDimensions {

pkg/metric/metric.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ func (m *TcmMetric) GetLatestPromMetrics(repo TcmMetricRepository) (pms []promet
6161
et := int64(0)
6262
now := time.Now().Unix()
6363
if m.Conf.StatDelaySeconds > 0 {
64-
st = now - m.Conf.StatPeriodSeconds - m.Conf.StatDelaySeconds
64+
st = now - m.Conf.StatNumSamples*m.Conf.StatPeriodSeconds - m.Conf.StatDelaySeconds
6565
et = now - m.Conf.StatDelaySeconds
6666
} else {
6767
st = now - m.Conf.StatNumSamples*m.Conf.StatPeriodSeconds
68+
et = now
6869
}
6970

7071
samplesList, err := repo.ListSamples(m, st, et)

pkg/util/time.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import "time"
66
func FormatTime(t time.Time, format string) string {
77
var local time.Time
88
_, offset := t.Zone()
9-
if offset == 0 {
10-
local = t.Add(8 * time.Hour)
11-
} else {
12-
local = t
13-
}
9+
local = t.Add(time.Duration(8*3600-offset) * time.Second)
1410
return local.Format(format)
1511
}

0 commit comments

Comments
 (0)