change setup timestamp model for prometheus target.

This commit is contained in:
Zhang Jiajun 2018-03-30 14:39:20 +08:00
parent 053f124c92
commit 049cb0387c

View File

@ -318,11 +318,11 @@ func (b *Exporter) Listen(e <-chan Events) {
if err == nil {
if ev.relative {
gauge.Add(event.Value())
gauge.SetTimestamp(timestamp)
} else {
gauge.Set(event.Value())
}
gauge.SetTimestamp(timestamp)
eventStats.WithLabelValues("gauge").Inc()
} else {
log.Debugf(regErrF, metricName, err)
@ -348,12 +348,13 @@ func (b *Exporter) Listen(e <-chan Events) {
)
if err == nil {
histogram.Observe(event.Value() / 1000) // prometheus presumes seconds, statsd millisecond
histogram.SetTimestamp(timestamp)
eventStats.WithLabelValues("timer").Inc()
} else {
log.Debugf(regErrF, metricName, err)
conflictingEventStats.WithLabelValues("timer").Inc()
}
histogram.SetTimestamp(timestamp)
case timerTypeDefault, timerTypeSummary:
summary, err := b.Summaries.Get(
metricName,
@ -362,12 +363,13 @@ func (b *Exporter) Listen(e <-chan Events) {
)
if err == nil {
summary.Observe(event.Value())
summary.SetTimestamp(timestamp)
eventStats.WithLabelValues("timer").Inc()
} else {
log.Debugf(regErrF, metricName, err)
conflictingEventStats.WithLabelValues("timer").Inc()
}
summary.SetTimestamp(timestamp)
default:
panic(fmt.Sprintf("unknown timer type '%s'", t))
}