Skip to content

Commit

Permalink
Merge pull request #96 from zianazhao/dev/timeZone
Browse files Browse the repository at this point in the history
Dev/time zone
  • Loading branch information
zero3233 authored Feb 2, 2023
2 parents b792693 + 029afb9 commit 6f6e634
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
1 change: 0 additions & 1 deletion pkg/collector/handler_clb_private.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func (h *ClbPrivateHandler) GetSeriesByCustom(m *metric.TcmMetric) ([]*metric.Tc
}
return slist, nil
}

func (h *ClbPrivateHandler) getSeriesByMetricType(m *metric.TcmMetric, ins instance.TcInstance) ([]*metric.TcmSeries, error) {
var dimensions []string
for _, v := range m.Meta.SupportDimensions {
Expand Down
3 changes: 2 additions & 1 deletion pkg/metric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ func (m *TcmMetric) GetLatestPromMetrics(repo TcmMetricRepository) (pms []promet
et := int64(0)
now := time.Now().Unix()
if m.Conf.StatDelaySeconds > 0 {
st = now - m.Conf.StatPeriodSeconds - m.Conf.StatDelaySeconds
st = now - m.Conf.StatNumSamples*m.Conf.StatPeriodSeconds - m.Conf.StatDelaySeconds
et = now - m.Conf.StatDelaySeconds
} else {
st = now - m.Conf.StatNumSamples*m.Conf.StatPeriodSeconds
et = now
}

samplesList, err := repo.ListSamples(m, st, et)
Expand Down
6 changes: 1 addition & 5 deletions pkg/util/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import "time"
func FormatTime(t time.Time, format string) string {
var local time.Time
_, offset := t.Zone()
if offset == 0 {
local = t.Add(8 * time.Hour)
} else {
local = t
}
local = t.Add(time.Duration(8*3600-offset) * time.Second)
return local.Format(format)
}

0 comments on commit 6f6e634

Please sign in to comment.