From 983cf4cae96b57da1289d513f9e2f291f40f79e8 Mon Sep 17 00:00:00 2001 From: songy23 Date: Wed, 27 Mar 2019 15:56:00 -0700 Subject: [PATCH] Fix start time for Stackdriver Gauge metrics. --- .../opencensus/ext/stackdriver/stats_exporter/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/stats_exporter/__init__.py b/contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/stats_exporter/__init__.py index f083e17cc..0ed31a431 100644 --- a/contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/stats_exporter/__init__.py +++ b/contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/stats_exporter/__init__.py @@ -255,6 +255,9 @@ def create_time_series_list(self, v_data, option_resource_type, if timestamp_start == timestamp_end: # avoiding start_time and end_time to be equal timestamp_start = timestamp_start - 1 + else: + # For LastValue (Gauge), start and end time must be the same. + timestamp_start = timestamp_end start_time = point.interval.start_time start_time.seconds = int(timestamp_start)