File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 5454import com .google .monitoring .v3 .TimeInterval ;
5555import com .google .monitoring .v3 .TimeSeries ;
5656import com .google .monitoring .v3 .TypedValue ;
57+ import com .google .protobuf .Timestamp ;
5758import com .google .protobuf .util .Timestamps ;
5859import io .opentelemetry .api .common .AttributeKey ;
5960import io .opentelemetry .api .common .Attributes ;
@@ -281,11 +282,19 @@ private static TimeSeries convertPointToBigtableTimeSeries(
281282 metricBuilder .putLabels (CLIENT_UID_KEY .getKey (), taskId );
282283 builder .setMetric (metricBuilder .build ());
283284
285+ MetricKind kind = convertMetricKind (metricData );
286+
287+ Timestamp endTimestamp = Timestamps .fromNanos (pointData .getEpochNanos ());
288+ Timestamp startTimestamp ;
289+
290+ if (kind == GAUGE ) {
291+ // GAUGE metrics must have start_time equal to end_time.
292+ startTimestamp = endTimestamp ;
293+ } else {
294+ startTimestamp = Timestamps .fromNanos (pointData .getStartEpochNanos ());
295+ }
284296 TimeInterval timeInterval =
285- TimeInterval .newBuilder ()
286- .setStartTime (Timestamps .fromNanos (pointData .getStartEpochNanos ()))
287- .setEndTime (Timestamps .fromNanos (pointData .getEpochNanos ()))
288- .build ();
297+ TimeInterval .newBuilder ().setStartTime (startTimestamp ).setEndTime (endTimestamp ).build ();
289298
290299 builder .addPoints (createPoint (metricData .getType (), pointData , timeInterval ));
291300
You can’t perform that action at this time.
0 commit comments