Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def __init__(
OTEL_EXPORTER_OTLP_ENDPOINT, "http://localhost:4317"
)

self.shutdown_event = threading.Event()
parsed_url = urlparse(self._endpoint)

if parsed_url.scheme == "https":
Expand Down Expand Up @@ -313,7 +314,7 @@ def _export(
self._endpoint,
delay,
)
sleep(delay)
self.shutdown_event.wait(delay)
continue
else:
logger.error(
Expand All @@ -337,6 +338,7 @@ def shutdown(self, timeout_millis: float = 30_000, **kwargs) -> None:
# wait for the last export if any
self._export_lock.acquire(timeout=timeout_millis)
self._shutdown = True
self.shutdown_event.set()
self._export_lock.release()

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ def shutdown(self):
self._shutdown = True
with self._condition:
self._condition.notify_all()
self._worker_thread.join()
self._exporter.shutdown()
self._worker_thread.join()

def force_flush(self, timeout_millis: Optional[int] = None) -> bool:
if timeout_millis is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,11 @@ def _shutdown():
return

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

def force_flush(self, timeout_millis: float = 10_000) -> bool:
super().force_flush(timeout_millis=timeout_millis)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ def shutdown(self) -> None:
self.done = True
with self.condition:
self.condition.notify_all()
self.worker_thread.join()
self.span_exporter.shutdown()
self.worker_thread.join()

@lzchen lzchen Aug 16, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something here but isn't there reason we join before shutting down is because we want to wait for all the current telemetry in the queue to be exported before shutting down the exporter? Wouldn't we drop those pieces of telemetry if we switched the order?


@staticmethod
def _default_max_queue_size():
Expand Down