mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-09-12 04:44:52 +00:00
error reason can't be in nested json
This commit is contained in:
parent
01d6e0ba32
commit
0d03dc1d81
@ -415,7 +415,7 @@ async fn main() -> Result<(), RouterError> {
|
|||||||
|
|
||||||
if let Some(ref ua) = user_agent {
|
if let Some(ref ua) = user_agent {
|
||||||
let start_event =
|
let start_event =
|
||||||
usage_stats::UsageStatsEvent::new(ua.clone(), usage_stats::EventType::Start);
|
usage_stats::UsageStatsEvent::new(ua.clone(), usage_stats::EventType::Start, None);
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
start_event.send().await;
|
start_event.send().await;
|
||||||
});
|
});
|
||||||
@ -459,7 +459,7 @@ async fn main() -> Result<(), RouterError> {
|
|||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
if let Some(ref ua) = user_agent {
|
if let Some(ref ua) = user_agent {
|
||||||
let stop_event =
|
let stop_event =
|
||||||
usage_stats::UsageStatsEvent::new(ua.clone(), usage_stats::EventType::Stop);
|
usage_stats::UsageStatsEvent::new(ua.clone(), usage_stats::EventType::Stop, None);
|
||||||
stop_event.send().await;
|
stop_event.send().await;
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -469,13 +469,15 @@ async fn main() -> Result<(), RouterError> {
|
|||||||
if !disable_crash_reports {
|
if !disable_crash_reports {
|
||||||
let error_event = usage_stats::UsageStatsEvent::new(
|
let error_event = usage_stats::UsageStatsEvent::new(
|
||||||
ua.clone(),
|
ua.clone(),
|
||||||
usage_stats::EventType::Error(e.to_string()),
|
usage_stats::EventType::Error,
|
||||||
|
Some(e.to_string()),
|
||||||
);
|
);
|
||||||
error_event.send().await;
|
error_event.send().await;
|
||||||
} else {
|
} else {
|
||||||
let unknow_error_event = usage_stats::UsageStatsEvent::new(
|
let unknow_error_event = usage_stats::UsageStatsEvent::new(
|
||||||
ua.clone(),
|
ua.clone(),
|
||||||
usage_stats::EventType::Error("unknow_error".to_string()),
|
usage_stats::EventType::Error,
|
||||||
|
Some("unknow_error".to_string()),
|
||||||
);
|
);
|
||||||
unknow_error_event.send().await;
|
unknow_error_event.send().await;
|
||||||
}
|
}
|
||||||
|
@ -34,20 +34,23 @@ impl UserAgent {
|
|||||||
pub enum EventType {
|
pub enum EventType {
|
||||||
Start,
|
Start,
|
||||||
Stop,
|
Stop,
|
||||||
Error(String),
|
Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct UsageStatsEvent {
|
pub struct UsageStatsEvent {
|
||||||
user_agent: UserAgent,
|
user_agent: UserAgent,
|
||||||
event_type: EventType,
|
event_type: EventType,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
error_reason: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UsageStatsEvent {
|
impl UsageStatsEvent {
|
||||||
pub fn new(user_agent: UserAgent, event_type: EventType) -> Self {
|
pub fn new(user_agent: UserAgent, event_type: EventType, error_reason: Option<String>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
user_agent,
|
user_agent,
|
||||||
event_type,
|
event_type,
|
||||||
|
error_reason,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub async fn send(&self) {
|
pub async fn send(&self) {
|
||||||
|
Loading…
Reference in New Issue
Block a user