nat.runtime.metrics#
Per-user workflow resource usage monitoring models and collector.
Attributes#
Classes#
Session lifecycle metrics for a per-user workflow. |
|
Request-level metrics for a per-user workflow. |
|
Memory/resource count metrics for a per-user workflow. |
|
Combined resource usage metrics for a single per-user workflow. |
|
Response model for the /monitor/users endpoint. |
|
Collector for per-user workflow metrics. |
Module Contents#
- logger#
- class PerUserSessionMetrics(/, **data: Any)#
Bases:
pydantic.BaseModelSession lifecycle metrics for a per-user workflow.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- created_at: datetime.datetime = None#
- last_activity: datetime.datetime = None#
- class PerUserRequestMetrics(/, **data: Any)#
Bases:
pydantic.BaseModelRequest-level metrics for a per-user workflow.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.
- class PerUserMemoryMetrics(/, **data: Any)#
Bases:
pydantic.BaseModelMemory/resource count metrics for a per-user workflow.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.
- class PerUserResourceUsage(/, **data: Any)#
Bases:
pydantic.BaseModelCombined resource usage metrics for a single per-user workflow.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- session: PerUserSessionMetrics = None#
- requests: PerUserRequestMetrics = None#
- memory: PerUserMemoryMetrics = None#
- class PerUserMonitorResponse(/, **data: Any)#
Bases:
pydantic.BaseModelResponse model for the /monitor/users endpoint.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- timestamp: datetime.datetime = None#
- users: list[PerUserResourceUsage] = None#
- class PerUserMetricsCollector(
- session_manager: nat.runtime.session.SessionManager,
Collector for per-user workflow metrics.
This class aggregates metrics from SessionManager’s per-user builders and provides methods to collect metrics for individual users or all users.
Initialize the collector with a SessionManager reference.
- Args:
session_manager: The SessionManager instance to collect metrics from
- _session_manager#
- async collect_user_metrics(user_id: str) PerUserResourceUsage | None#
Collect metrics for a specific user.
- Args:
user_id: The user identifier to collect metrics for
- Returns:
PerUserResourceUsage if user exists, None otherwise
- async collect_all_metrics() PerUserMonitorResponse#
Collect metrics for all active per-user workflows.
- Returns:
PerUserMonitorResponse with all user metrics
- _build_user_metrics(
- user_id: str,
- builder_info,
Build metrics for a single user from builder info.
- Args:
user_id: The user identifier builder_info: The PerUserBuilderInfo instance
- Returns:
PerUserResourceUsage with all metrics