Skip to content

Commit 6a425cb

Browse files
authored
Merge pull request #58 from posit-dev/feature/resource-usage
Add resource monitor
2 parents fc7882e + 31d90ff commit 6a425cb

File tree

18 files changed

+1237
-16
lines changed

18 files changed

+1237
-16
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/kallichore_api/.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ docs/ExecutionQueue.md
1212
docs/InterruptMode.md
1313
docs/NewSession.md
1414
docs/NewSession200Response.md
15+
docs/ResourceUsage.md
1516
docs/RestartSession.md
1617
docs/ServerConfiguration.md
1718
docs/ServerConfigurationLogLevel.md

crates/kallichore_api/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ To see how to make this your own, look here:
1414
[README]((https://openapi-generator.tech))
1515

1616
- API version: 1.0.0
17-
- Build date: 2025-11-12T12:51:21.340981-08:00[America/Los_Angeles]
17+
- Build date: 2026-01-06T09:23:26.564876-08:00[America/Los_Angeles]
1818
- Generator version: 7.17.0
1919

2020
For more information, please visit [https://posit.co](https://posit.co)
@@ -162,6 +162,7 @@ Method | HTTP request | Description
162162
- [InterruptMode](docs/InterruptMode.md)
163163
- [NewSession](docs/NewSession.md)
164164
- [NewSession200Response](docs/NewSession200Response.md)
165+
- [ResourceUsage](docs/ResourceUsage.md)
165166
- [RestartSession](docs/RestartSession.md)
166167
- [ServerConfiguration](docs/ServerConfiguration.md)
167168
- [ServerConfigurationLogLevel](docs/ServerConfigurationLogLevel.md)

crates/kallichore_api/api/openapi.yaml

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ components:
712712
process_id: 6
713713
input_prompt: input_prompt
714714
continuation_prompt: continuation_prompt
715-
busy_seconds: 5
715+
busy_seconds: 2
716716
kernel_info: "{}"
717717
session_id: session_id
718718
language: language
@@ -732,12 +732,18 @@ components:
732732
active: "{}"
733733
interrupt_mode: signal
734734
connected: true
735+
resource_usage:
736+
sampling_period_ms: 7
737+
thread_count: 2
738+
memory_bytes: 5
739+
cpu_percent: 5
740+
timestamp: 9
735741
session_mode: console
736742
initial_env:
737743
key: initial_env
738744
username: username
739745
status: uninitialized
740-
idle_seconds: 5
746+
idle_seconds: 3
741747
properties:
742748
session_id:
743749
description: A unique identifier for the session
@@ -796,6 +802,8 @@ components:
796802
description: "The kernel information, as returned by the kernel_info_request\
797803
\ message"
798804
type: object
805+
resource_usage:
806+
$ref: "#/components/schemas/resourceUsage"
799807
idle_seconds:
800808
description: "The number of seconds the session has been idle, or 0 if the\
801809
\ session is busy"
@@ -877,14 +885,54 @@ components:
877885
- uptime_seconds
878886
- version
879887
type: object
888+
resourceUsage:
889+
example:
890+
sampling_period_ms: 7
891+
thread_count: 2
892+
memory_bytes: 5
893+
cpu_percent: 5
894+
timestamp: 9
895+
properties:
896+
cpu_percent:
897+
description: The percentage of CPU used by the kernel process and its child
898+
processes
899+
format: int64
900+
type: integer
901+
memory_bytes:
902+
description: The amount of memory used by the kernel process and all of
903+
its child processes in bytes
904+
format: int64
905+
type: integer
906+
thread_count:
907+
description: The total number of threads used by the kernel process and
908+
its child processes (Linux only)
909+
format: int64
910+
type: integer
911+
sampling_period_ms:
912+
description: The sampling period in milliseconds over which the resource
913+
usage was measured
914+
format: int64
915+
type: integer
916+
timestamp:
917+
description: A Unix timestamp in milliseconds indicating when the resource
918+
usage was sampled
919+
format: int64
920+
type: integer
921+
required:
922+
- cpu_percent
923+
- memory_bytes
924+
- sampling_period_ms
925+
- thread_count
926+
- timestamp
927+
type: object
880928
sessionList:
881929
example:
882930
total: 0
883931
sessions:
884932
- process_id: 6
885933
input_prompt: input_prompt
886934
continuation_prompt: continuation_prompt
887-
busy_seconds: 5
935+
busy_seconds: 2
888936
kernel_info: "{}"
889937
session_id: session_id
890938
language: language
@@ -904,16 +952,22 @@ components:
904952
active: "{}"
905953
interrupt_mode: signal
906954
connected: true
955+
resource_usage:
956+
sampling_period_ms: 7
957+
thread_count: 2
958+
memory_bytes: 5
959+
cpu_percent: 5
960+
timestamp: 9
907961
session_mode: console
908962
initial_env:
909963
key: initial_env
910964
username: username
911965
status: uninitialized
912-
idle_seconds: 5
966+
idle_seconds: 3
913967
- process_id: 6
914968
input_prompt: input_prompt
915969
continuation_prompt: continuation_prompt
916-
busy_seconds: 5
970+
busy_seconds: 2
917971
kernel_info: "{}"
918972
session_id: session_id
919973
language: language
@@ -933,12 +987,18 @@ components:
933987
active: "{}"
934988
interrupt_mode: signal
935989
connected: true
990+
resource_usage:
991+
sampling_period_ms: 7
992+
thread_count: 2
993+
memory_bytes: 5
994+
cpu_percent: 5
995+
timestamp: 9
936996
session_mode: console
937997
initial_env:
938998
key: initial_env
939999
username: username
9401000
status: uninitialized
941-
idle_seconds: 5
1001+
idle_seconds: 3
9421002
properties:
9431003
total:
9441004
type: integer
@@ -952,13 +1012,18 @@ components:
9521012
type: object
9531013
serverConfiguration:
9541014
example:
1015+
resource_sample_interval_ms: 6
9551016
log_level: trace
9561017
idle_shutdown_hours: 0
9571018
properties:
9581019
idle_shutdown_hours:
9591020
description: The number of hours the server will wait before shutting down
9601021
idle sessions (-1 if idle shutdown is disabled)
9611022
type: integer
1023+
resource_sample_interval_ms:
1024+
description: The interval in milliseconds at which resource usage is sampled.
1025+
A value of 0 disables resource usage sampling.
1026+
type: integer
9621027
log_level:
9631028
$ref: "#/components/schemas/serverConfiguration_log_level"
9641029
type: object

crates/kallichore_api/docs/ActiveSession.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Name | Type | Description | Notes
2121
**execution_queue** | [***models::ExecutionQueue**](execution_queue.md) | |
2222
**status** | [***models::Status**](status.md) | |
2323
**kernel_info** | [***serde_json::Value**](.md) | The kernel information, as returned by the kernel_info_request message |
24+
**resource_usage** | [***models::ResourceUsage**](resourceUsage.md) | | [optional] [default to None]
2425
**idle_seconds** | **i32** | The number of seconds the session has been idle, or 0 if the session is busy |
2526
**busy_seconds** | **i32** | The number of seconds the session has been busy, or 0 if the session is idle |
2627
**socket_path** | **String** | The path to the Unix domain socket used to send/receive data from the session, if applicable | [optional] [default to None]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ResourceUsage
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**cpu_percent** | **i64** | The percentage of CPU used by the kernel process and its child processes |
7+
**memory_bytes** | **i64** | The amount of memory used by the kernel process and all of its child processes in bytes |
8+
**thread_count** | **i64** | The total number of threads used by the kernel process and its child processes (Linux only) |
9+
**sampling_period_ms** | **i64** | The sampling period in milliseconds over which the resource usage was measured |
10+
**timestamp** | **i64** | A Unix timestamp in milliseconds indicating when the resource usage was sampled |
11+
12+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
13+
14+

crates/kallichore_api/docs/ServerConfiguration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
66
**idle_shutdown_hours** | **i32** | The number of hours the server will wait before shutting down idle sessions (-1 if idle shutdown is disabled) | [optional] [default to None]
7+
**resource_sample_interval_ms** | **i32** | The interval in milliseconds at which resource usage is sampled. A value of 0 disables resource usage sampling. | [optional] [default to None]
78
**log_level** | [***models::ServerConfigurationLogLevel**](serverConfiguration_log_level.md) | | [optional] [default to None]
89

910
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

0 commit comments

Comments
 (0)