diff --git a/src/splunk_otel/distro.py b/src/splunk_otel/distro.py index 8ca78ea5..5415dbfe 100644 --- a/src/splunk_otel/distro.py +++ b/src/splunk_otel/distro.py @@ -91,7 +91,9 @@ def check_service_name(self): self.env.setval(OTEL_SERVICE_NAME, _DEFAULT_SERVICE_NAME) def set_profiling_env(self): - if self.env.is_true(SPLUNK_PROFILER_ENABLED, "false"): + profiler_enabled = self.env.is_true(SPLUNK_PROFILER_ENABLED, "false") + snapshot_profiler_enabled = self.env.is_true(SPLUNK_SNAPSHOT_PROFILER_ENABLED, "false") + if profiler_enabled or snapshot_profiler_enabled: logs_endpt = self.env.getval(SPLUNK_PROFILER_LOGS_ENDPOINT) if logs_endpt: self.env.setval(OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, logs_endpt) diff --git a/src/splunk_otel/profile.py b/src/splunk_otel/profile.py index 4735b3da..66a06398 100644 --- a/src/splunk_otel/profile.py +++ b/src/splunk_otel/profile.py @@ -278,8 +278,8 @@ def _loop(self): start_time_seconds = time.monotonic() if self.pause_at is not None and start_time_seconds >= self.pause_at: - # The pause deadline has been reached, sleep until woken again. - self.wakeup_event.wait() + self.wakeup_event.clear() # clear event so next line will block + self.wakeup_event.wait() # wait for event.set() (either via start() or stop()) continue self.target() @@ -290,13 +290,12 @@ def _loop(self): def stop(self): self.running = False self.pause_at = None - self.wakeup_event.set() - self.thread.join() + self.wakeup_event.set() # unblock _loop() if waiting, so it can return and thread can exit + if self.thread.is_alive(): + self.thread.join() def pause_after(self, seconds: float): - # The timer will stay running until pause_at has been reached. self.pause_at = time.monotonic() + seconds - self.wakeup_event.clear() class _StringTable: