Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix _time_ns import
  • Loading branch information
aabmass committed May 6, 2022
commit aa6e4a15c53d8562705bde5d41fabfbdb0b27439
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.util.instrumentation import InstrumentationScope
from opentelemetry.util._once import Once
from opentelemetry.util._time import time_ns
from opentelemetry.util._time import _time_ns

_logger = getLogger(__name__)

Expand Down Expand Up @@ -371,10 +371,10 @@ def __init__(
self._shutdown = False

def force_flush(self, timeout_millis: float = 10_000) -> bool:
deadline_ns = time_ns() + timeout_millis * 10**6
deadline_ns = _time_ns() + timeout_millis * 10**6

for metric_reader in self._sdk_config.metric_readers:
current_ts = time_ns()
current_ts = _time_ns()
if current_ts >= deadline_ns:
raise Exception("Timed out while flushing metric readers")
metric_reader.collect(
Expand All @@ -383,7 +383,7 @@ def force_flush(self, timeout_millis: float = 10_000) -> bool:
return True

def shutdown(self, timeout_millis: float = 30_000):
deadline_ns = time_ns() + timeout_millis * 10**6
deadline_ns = _time_ns() + timeout_millis * 10**6

def _shutdown():
self._shutdown = True
Expand All @@ -397,7 +397,7 @@ def _shutdown():
metric_reader_error = {}

for metric_reader in self._sdk_config.metric_readers:
current_ts = time_ns()
current_ts = _time_ns()
try:
if current_ts >= deadline_ns:
raise Exception(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from opentelemetry.sdk._metrics.metric_reader import MetricReader
from opentelemetry.sdk._metrics.point import AggregationTemporality, Metric
from opentelemetry.util._once import Once
from opentelemetry.util._time import time_ns
from opentelemetry.util._time import _time_ns

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -225,7 +225,7 @@ def _receive_metrics(
detach(token)

def shutdown(self, timeout_millis: float = 30_000, **kwargs) -> None:
deadline_ns = time_ns() + timeout_millis * 10**6
deadline_ns = _time_ns() + timeout_millis * 10**6

def _shutdown():
self._shutdown = True
Expand All @@ -236,5 +236,5 @@ def _shutdown():
return

self._shutdown_event.set()
self._daemon_thread.join(timeout=(deadline_ns - time_ns()) / 10**9)
self._exporter.shutdown(timeout=(deadline_ns - time_ns()) / 10**6)
self._daemon_thread.join(timeout=(deadline_ns - _time_ns()) / 10**9)
self._exporter.shutdown(timeout=(deadline_ns - _time_ns()) / 10**6)