From d3dd51ba4e86cbd43a5c9abde2eae1415a83d249 Mon Sep 17 00:00:00 2001 From: Pablo Collins Date: Fri, 3 Apr 2026 18:05:44 -0400 Subject: [PATCH 1/2] fix snapshot profiling --- src/splunk_otel/distro.py | 5 ++++- src/splunk_otel/profile.py | 11 +++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/splunk_otel/distro.py b/src/splunk_otel/distro.py index 8ca78ea5..149ab359 100644 --- a/src/splunk_otel/distro.py +++ b/src/splunk_otel/distro.py @@ -91,7 +91,10 @@ 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"): + profiling_active = self.env.is_true(SPLUNK_PROFILER_ENABLED, "false") or self.env.is_true( + SPLUNK_SNAPSHOT_PROFILER_ENABLED, "false" + ) + if profiling_active: 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..6f2616d3 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() # deadline reached, now 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 _loop() 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: From fe8c0cc636a23a7ba1c78efa30a7b1400c02b0c5 Mon Sep 17 00:00:00 2001 From: Pablo Collins Date: Fri, 3 Apr 2026 18:12:48 -0400 Subject: [PATCH 2/2] fix snapshot profiling --- src/splunk_otel/distro.py | 7 +++---- src/splunk_otel/profile.py | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/splunk_otel/distro.py b/src/splunk_otel/distro.py index 149ab359..5415dbfe 100644 --- a/src/splunk_otel/distro.py +++ b/src/splunk_otel/distro.py @@ -91,10 +91,9 @@ def check_service_name(self): self.env.setval(OTEL_SERVICE_NAME, _DEFAULT_SERVICE_NAME) def set_profiling_env(self): - profiling_active = self.env.is_true(SPLUNK_PROFILER_ENABLED, "false") or self.env.is_true( - SPLUNK_SNAPSHOT_PROFILER_ENABLED, "false" - ) - if profiling_active: + 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 6f2616d3..66a06398 100644 --- a/src/splunk_otel/profile.py +++ b/src/splunk_otel/profile.py @@ -279,7 +279,7 @@ def _loop(self): if self.pause_at is not None and start_time_seconds >= self.pause_at: self.wakeup_event.clear() # clear event so next line will block - self.wakeup_event.wait() # deadline reached, now wait for event.set() (either via start() or stop()) + self.wakeup_event.wait() # wait for event.set() (either via start() or stop()) continue self.target() @@ -290,7 +290,7 @@ def _loop(self): def stop(self): self.running = False self.pause_at = None - self.wakeup_event.set() # unblock _loop() if waiting, so _loop() can return and thread can exit + self.wakeup_event.set() # unblock _loop() if waiting, so it can return and thread can exit if self.thread.is_alive(): self.thread.join()