pub struct ModelMetricsRepository {
pub base: BaseRepository<ModelMetrics>,
}Expand description
模型性能指标Repository
Fields§
§base: BaseRepository<ModelMetrics>Implementations§
Source§impl ModelMetricsRepository
impl ModelMetricsRepository
pub fn new(query_executor: Box<dyn QueryExecutor>) -> Self
Sourcepub async fn find_by_deployment_id(
&self,
deployment_id: Uuid,
start_time: DateTime<Utc>,
end_time: DateTime<Utc>,
context: &QueryContext,
) -> DatabaseResult<Vec<ModelMetrics>>
pub async fn find_by_deployment_id( &self, deployment_id: Uuid, start_time: DateTime<Utc>, end_time: DateTime<Utc>, context: &QueryContext, ) -> DatabaseResult<Vec<ModelMetrics>>
根据部署ID获取指标
Examples found in repository?
examples/burncloud_usage.rs (line 212)
198async fn advanced_query_examples(db: &BurnCloudDatabase) -> Result<(), Box<dyn std::error::Error>> {
199 let context = QueryContext::default();
200
201 // 时间范围查询
202 let start_time = chrono::Utc::now() - chrono::Duration::hours(24);
203 let end_time = chrono::Utc::now();
204
205 // 获取过去24小时的系统指标
206 let recent_metrics = db.system_metrics.find_by_time_range(start_time, end_time, &context).await?;
207 println!("📊 过去24小时系统指标: {} 条记录", recent_metrics.len());
208
209 // 获取特定部署的性能指标
210 if let Some(deployment) = db.deployments.get_running_deployments(&context).await?.first() {
211 let deployment_metrics = db.model_metrics
212 .find_by_deployment_id(deployment.id, start_time, end_time, &context)
213 .await?;
214 println!("📈 部署 {} 的性能指标: {} 条记录", deployment.name, deployment_metrics.len());
215
216 // 获取该部署的错误日志
217 let error_logs = db.request_logs.find_errors(start_time, end_time, &context).await?;
218 println!("❌ 过去24小时错误日志: {} 条记录", error_logs.len());
219 }
220
221 Ok(())
222}Sourcepub async fn get_latest_for_deployment(
&self,
deployment_id: Uuid,
context: &QueryContext,
) -> DatabaseResult<Option<ModelMetrics>>
pub async fn get_latest_for_deployment( &self, deployment_id: Uuid, context: &QueryContext, ) -> DatabaseResult<Option<ModelMetrics>>
获取部署的最新指标
Auto Trait Implementations§
impl Freeze for ModelMetricsRepository
impl !RefUnwindSafe for ModelMetricsRepository
impl Send for ModelMetricsRepository
impl Sync for ModelMetricsRepository
impl Unpin for ModelMetricsRepository
impl !UnwindSafe for ModelMetricsRepository
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more