Skip to content

Commit 45ec068

Browse files
committed
updated deadlines
1 parent 194679d commit 45ec068

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • packages/google-cloud-bigtable/google/cloud/bigtable/data/_metrics/handlers

packages/google-cloud-bigtable/google/cloud/bigtable/data/_metrics/handlers/gcp_exporter.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)