Skip to main content

systemprompt_analytics/models/cli/
tool.rs

1//! CLI-facing tool-usage analytics rows.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use chrono::{DateTime, Utc};
7use serde::{Deserialize, Serialize};
8use sqlx::FromRow;
9
10#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
11pub struct ToolListRow {
12    pub tool_name: String,
13    pub server_name: String,
14    pub execution_count: i64,
15    pub success_count: i64,
16    pub avg_time: f64,
17    pub last_used: DateTime<Utc>,
18}
19
20#[derive(Debug, Clone, Copy, Serialize, Deserialize, FromRow)]
21pub struct ToolStatsRow {
22    pub total_tools: i64,
23    pub total_executions: i64,
24    pub successful: i64,
25    pub failed: i64,
26    pub timeout: i64,
27    pub avg_time: f64,
28    pub p95_time: f64,
29}
30
31#[derive(Debug, Clone, Copy, Serialize, Deserialize, FromRow)]
32pub struct ToolSummaryRow {
33    pub total: i64,
34    pub successful: i64,
35    pub failed: i64,
36    pub timeout: i64,
37    pub avg_time: f64,
38    pub p95_time: f64,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
42pub struct ToolStatusBreakdownRow {
43    pub status: String,
44    pub status_count: i64,
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
48pub struct ToolErrorRow {
49    pub error_msg: Option<String>,
50    pub error_count: i64,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
54pub struct ToolAgentUsageRow {
55    pub agent_name: Option<String>,
56    pub usage_count: i64,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
60pub struct ToolExecutionRow {
61    pub created_at: DateTime<Utc>,
62    pub status: Option<String>,
63    pub execution_time_ms: Option<i32>,
64}