diff --git a/exporter/prometheus/prometheus.go b/exporter/prometheus/prometheus.go index 8cee76b3e..3d78b8317 100644 --- a/exporter/prometheus/prometheus.go +++ b/exporter/prometheus/prometheus.go @@ -257,7 +257,7 @@ func (c *collector) toMetric(desc *prometheus.Desc, v *view.View, row *view.Row) return prometheus.NewConstMetric(desc, prometheus.UntypedValue, data.Value, tagValues(row.Tags)...) case *view.LastValueData: - return prometheus.NewConstMetric(desc, prometheus.UntypedValue, data.Value, tagValues(row.Tags)...) + return prometheus.NewConstMetric(desc, prometheus.GaugeValue, data.Value, tagValues(row.Tags)...) default: return nil, fmt.Errorf("aggregation %T is not yet supported", v.Aggregation) diff --git a/exporter/prometheus/prometheus_test.go b/exporter/prometheus/prometheus_test.go index 7a132c300..af3c5b3c0 100644 --- a/exporter/prometheus/prometheus_test.go +++ b/exporter/prometheus/prometheus_test.go @@ -45,6 +45,7 @@ func newView(measureName string, agg *view.Aggregation) *view.View { func TestOnlyCumulativeWindowSupported(t *testing.T) { // See Issue https://github.com/census-instrumentation/opencensus-go/issues/214. count1 := &view.CountData{Value: 1} + lastValue1 := &view.LastValueData{Value: 56.7} tests := []struct { vds *view.Data want int @@ -64,6 +65,15 @@ func TestOnlyCumulativeWindowSupported(t *testing.T) { }, want: 1, }, + 2: { + vds: &view.Data{ + View: newView("TestOnlyCumulativeWindowSupported/m3", view.LastValue()), + Rows: []*view.Row{ + {Data: lastValue1}, + }, + }, + want: 1, + }, } for i, tt := range tests {