feat: add observability api foundation

This commit is contained in:
a.tolmachev
2026-03-30 00:00:13 +03:00
parent 0a1680f24e
commit be9ee95cbe
21 changed files with 1535 additions and 94 deletions
+1
View File
@@ -45,3 +45,4 @@ define_id!(UserId);
define_id!(AgentId);
define_id!(InvitationId);
define_id!(PlatformApiKeyId);
define_id!(InvocationLogId);
+6 -2
View File
@@ -2,6 +2,7 @@ pub mod access;
pub mod agent;
pub mod auth;
pub mod ids;
pub mod observability;
pub mod operation;
pub mod protocol;
pub mod workspace;
@@ -16,8 +17,11 @@ pub use auth::{
BearerAuthConfig, SecretRef,
};
pub use ids::{
AgentId, AuthProfileId, DescriptorId, InvitationId, OperationId, PlatformApiKeyId, SampleId,
ToolId, UserId, WorkspaceId,
AgentId, AuthProfileId, DescriptorId, InvitationId, InvocationLogId, OperationId,
PlatformApiKeyId, SampleId, ToolId, UserId, WorkspaceId,
};
pub use observability::{
InvocationLevel, InvocationLog, InvocationSource, InvocationStatus, UsagePeriod, UsageRollup,
};
pub use operation::{
ConfigExport, ExecutionConfig, GeneratedDraft, GeneratedDraftStatus, GraphqlTarget,
+81
View File
@@ -0,0 +1,81 @@
use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::{AgentId, OperationId, WorkspaceId};
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum InvocationSource {
AdminTestRun,
AgentToolCall,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum InvocationLevel {
Debug,
Info,
Warn,
Error,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum InvocationStatus {
Ok,
Error,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum UsagePeriod {
#[serde(rename = "30m")]
Last30Minutes,
#[serde(rename = "1h")]
LastHour,
#[serde(rename = "6h")]
Last6Hours,
#[serde(rename = "24h")]
Last24Hours,
#[serde(rename = "7d")]
Last7Days,
#[serde(rename = "30d")]
Last30Days,
#[serde(rename = "90d")]
Last90Days,
#[serde(rename = "this_month")]
ThisMonth,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct InvocationLog {
pub id: crate::ids::InvocationLogId,
pub workspace_id: WorkspaceId,
pub agent_id: Option<AgentId>,
pub operation_id: OperationId,
pub source: InvocationSource,
pub level: InvocationLevel,
pub status: InvocationStatus,
pub tool_name: String,
pub message: String,
pub request_id: Option<String>,
pub status_code: Option<u16>,
pub duration_ms: u64,
pub error_kind: Option<String>,
pub request_preview: Value,
pub response_preview: Value,
pub created_at: String,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct UsageRollup {
pub workspace_id: WorkspaceId,
pub agent_id: Option<AgentId>,
pub operation_id: Option<OperationId>,
pub period: UsagePeriod,
pub calls_total: u64,
pub calls_ok: u64,
pub calls_error: u64,
pub p50_ms: u64,
pub p95_ms: u64,
pub p99_ms: u64,
}