Skip to content
Open
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
4 changes: 3 additions & 1 deletion src/splunk_otel/distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions src/splunk_otel/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand Down
Loading