feat: add observability api foundation
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
use crank_core::{
|
||||
Agent, AgentId, AgentOperationBinding, AgentStatus, AgentVersion, AuthProfile, DescriptorId,
|
||||
ExportMode, InvitationToken, MembershipRole, Operation, OperationId, OperationStatus,
|
||||
PlatformApiKey, Protocol, SampleId, User, Workspace, WorkspaceId,
|
||||
ExportMode, InvitationToken, InvocationLevel, InvocationLog, InvocationSource, MembershipRole,
|
||||
Operation, OperationId, OperationStatus, PlatformApiKey, Protocol, SampleId, UsagePeriod,
|
||||
UsageRollup, User, Workspace, WorkspaceId,
|
||||
};
|
||||
use crank_mapping::MappingSet;
|
||||
use crank_schema::Schema;
|
||||
@@ -64,6 +65,52 @@ pub struct PlatformApiKeyRecord {
|
||||
pub api_key: PlatformApiKey,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct InvocationLogRecord {
|
||||
pub log: InvocationLog,
|
||||
pub operation_name: String,
|
||||
pub operation_display_name: String,
|
||||
pub agent_slug: Option<String>,
|
||||
pub agent_display_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UsageRollupRecord {
|
||||
pub rollup: UsageRollup,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UsageTimelinePoint {
|
||||
pub bucket_start: String,
|
||||
pub calls_ok: u64,
|
||||
pub calls_error: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UsageOperationBreakdown {
|
||||
pub operation_id: OperationId,
|
||||
pub operation_name: String,
|
||||
pub operation_display_name: String,
|
||||
pub protocol: Protocol,
|
||||
pub calls_total: u64,
|
||||
pub calls_error: u64,
|
||||
pub p50_ms: u64,
|
||||
pub p95_ms: u64,
|
||||
pub p99_ms: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UsageAgentBreakdown {
|
||||
pub agent_id: AgentId,
|
||||
pub agent_slug: String,
|
||||
pub agent_display_name: String,
|
||||
pub calls_total: u64,
|
||||
pub calls_error: u64,
|
||||
pub p50_ms: u64,
|
||||
pub p95_ms: u64,
|
||||
pub p99_ms: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct AgentSummary {
|
||||
pub id: AgentId,
|
||||
@@ -200,6 +247,46 @@ pub struct YamlImportJobCompletion {
|
||||
pub finished_at: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct CreateInvocationLogRequest<'a> {
|
||||
pub log: &'a InvocationLog,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ListInvocationLogsQuery<'a> {
|
||||
pub workspace_id: &'a WorkspaceId,
|
||||
pub level: Option<InvocationLevel>,
|
||||
pub search_text: Option<&'a str>,
|
||||
pub source: Option<InvocationSource>,
|
||||
pub operation_id: Option<&'a OperationId>,
|
||||
pub agent_id: Option<&'a AgentId>,
|
||||
pub created_after: Option<&'a str>,
|
||||
pub limit: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum UsageBucket {
|
||||
Hour,
|
||||
Day,
|
||||
Week,
|
||||
Month,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct UsageQuery<'a> {
|
||||
pub workspace_id: &'a WorkspaceId,
|
||||
pub period: UsagePeriod,
|
||||
pub source: Option<InvocationSource>,
|
||||
pub created_after: &'a str,
|
||||
pub bucket: UsageBucket,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UsageSummary {
|
||||
pub rollup: UsageRollup,
|
||||
pub success_rate: f64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct CreateVersionRequest<'a> {
|
||||
pub workspace_id: &'a WorkspaceId,
|
||||
|
||||
Reference in New Issue
Block a user