feat: add activity/idle tracking to sessions - #19
Draft
sd2k wants to merge 2 commits into
Draft
Conversation
Add SessionStats struct and tracking methods to InProcessSession for monitoring session activity and resource usage: - SessionStats struct with created_at, last_activity, execution_count, total_execution_time, total_callback_invocations, and peak_memory_bytes - last_activity() - returns the time of last execution completion - idle_duration() - returns duration since last execution - execution_count() - returns total number of executions (now u64) - total_execution_time() - returns cumulative execution time - stats() - returns complete SessionStats snapshot - reset_stats() - clears statistics without affecting session state Statistics behavior: - Stats survive clear_state() (only clears Python state) - Stats are fully reset on reset() (new WASM instance) - reset_stats() preserves original creation time - reset_full() updates creation time Includes unit tests for SessionStats default values, reset behavior, and reset_full timestamp handling. Closes: eryx-cvr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SessionStatsstruct with activity metricsInProcessSession:last_activity()- time of last executionidle_duration()- duration since last executionexecution_count()- total executions (now u64)total_execution_time()- cumulative execution timestats()- full SessionStats snapshotreset_stats()- clear stats without affecting sessionBehavior
clear_state()(only clears Python state)reset()(new WASM instance)Test plan
🤖 Generated with Claude Code