File tree Expand file tree Collapse file tree
packages/google-cloud-bigtable/google/cloud/bigtable/data/_metrics/handlers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ def export(
154154 Write a set of metrics to Cloud Monitoring.
155155 This method is called by the OpenTelemetry SDK
156156 """
157- deadline = time .time () + (timeout_millis / 1000 )
157+ deadline = time .monotonic () + (timeout_millis / 1000 )
158158 metric_kind = MetricDescriptor .MetricKind .CUMULATIVE
159159 all_series : list [TimeSeries ] = []
160160 # process each metric from OTel format into Cloud Monitoring format
@@ -239,7 +239,11 @@ def _batch_write(
239239 write_ind = 0
240240 while write_ind < len (series ):
241241 # find time left for next batch
242- timeout = deadline - time .time () if deadline else gapic_v1 .method .DEFAULT
242+ timeout = (
243+ max (0.0 , deadline - time .monotonic ())
244+ if deadline
245+ else gapic_v1 .method .DEFAULT
246+ )
243247 # write next batch
244248 batch = series [write_ind : write_ind + max_batch_size ]
245249 self .client .create_service_time_series (
You can’t perform that action at this time.
0 commit comments