Skip to content
This repository was archived by the owner on Dec 1, 2018. It is now read-only.

Commit 3c96668

Browse files
authored
Merge pull request #1643 from aleksandra-malinowska/stackdriver-sink-exporter-metrics-fix
Stackdriver sink: fix export duration/timestamp metrics
2 parents 34470a2 + 5bf98e8 commit 3c96668

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

metrics/sinks/manager.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ var (
4040
[]string{"exporter"},
4141
)
4242

43-
// Time spent exporting data to sink in microseconds.
43+
// Time spent exporting data to sink in milliseconds.
4444
exporterDuration = prometheus.NewSummaryVec(
4545
prometheus.SummaryOpts{
4646
Namespace: "heapster",
4747
Subsystem: "exporter",
48-
Name: "duration_microseconds",
49-
Help: "Time spent exporting data to sink in microseconds.",
48+
Name: "duration_milliseconds",
49+
Help: "Time spent exporting data to sink in milliseconds.",
5050
},
5151
[]string{"exporter"},
5252
)
@@ -148,12 +148,17 @@ func (this *sinkManager) Stop() {
148148

149149
func export(s core.DataSink, data *core.DataBatch) {
150150
startTime := time.Now()
151-
defer lastExportTimestamp.
152-
WithLabelValues(s.Name()).
153-
Set(float64(time.Now().Unix()))
154-
defer exporterDuration.
155-
WithLabelValues(s.Name()).
156-
Observe(float64(time.Since(startTime)) / float64(time.Microsecond))
151+
152+
defer func() {
153+
lastExportTimestamp.
154+
WithLabelValues(s.Name()).
155+
Set(float64(time.Now().Unix()))
156+
}()
157+
defer func() {
158+
exporterDuration.
159+
WithLabelValues(s.Name()).
160+
Observe(float64(time.Since(startTime)) / float64(time.Millisecond))
161+
}()
157162

158163
s.ExportData(data)
159164
}

0 commit comments

Comments
 (0)