mirror of
https://github.com/TabbyML/tabby
synced 2024-11-22 00:08:06 +00:00
feat(core): add webserver in telemetry (#1896)
This commit is contained in:
parent
103caa00f4
commit
00674c841a
@ -133,6 +133,14 @@ pub async fn main(config: &Config, args: &ServeArgs) {
|
||||
warn!("'--webserver' is enabled by default since 0.11, and will be removed in the next major release. Please remove this flag from your command.");
|
||||
}
|
||||
|
||||
#[allow(unused_assignments)]
|
||||
let mut webserver = None;
|
||||
|
||||
#[cfg(feature = "ee")]
|
||||
{
|
||||
webserver = Some(!args.no_webserver)
|
||||
}
|
||||
|
||||
#[cfg(feature = "ee")]
|
||||
let ws = if !args.no_webserver {
|
||||
Some(tabby_webserver::public::WebserverHandle::new(create_event_logger()).await)
|
||||
@ -150,7 +158,7 @@ pub async fn main(config: &Config, args: &ServeArgs) {
|
||||
}
|
||||
|
||||
let code = Arc::new(create_code_search(repository_access));
|
||||
let mut api = api_router(args, config, logger.clone(), code.clone()).await;
|
||||
let mut api = api_router(args, config, logger.clone(), code.clone(), webserver).await;
|
||||
let mut ui = Router::new()
|
||||
.merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", ApiDoc::openapi()))
|
||||
.fallback(|| async { axum::response::Redirect::temporary("/swagger-ui") });
|
||||
@ -164,7 +172,7 @@ pub async fn main(config: &Config, args: &ServeArgs) {
|
||||
ui = new_ui;
|
||||
};
|
||||
|
||||
start_heartbeat(args);
|
||||
start_heartbeat(args, webserver);
|
||||
run_app(api, Some(ui), args.host, args.port).await
|
||||
}
|
||||
|
||||
@ -183,6 +191,7 @@ async fn api_router(
|
||||
config: &Config,
|
||||
logger: Arc<dyn EventLogger>,
|
||||
code: Arc<dyn CodeSearch>,
|
||||
webserver: Option<bool>,
|
||||
) -> Router {
|
||||
let completion_state = if let Some(model) = &args.model {
|
||||
Some(Arc::new(
|
||||
@ -219,6 +228,7 @@ async fn api_router(
|
||||
args.model.as_deref(),
|
||||
args.chat_model.as_deref(),
|
||||
&args.device,
|
||||
webserver,
|
||||
));
|
||||
|
||||
routers.push({
|
||||
@ -313,11 +323,12 @@ async fn api_router(
|
||||
root
|
||||
}
|
||||
|
||||
fn start_heartbeat(args: &ServeArgs) {
|
||||
fn start_heartbeat(args: &ServeArgs, webserver: Option<bool>) {
|
||||
let state = health::HealthState::new(
|
||||
args.model.as_deref(),
|
||||
args.chat_model.as_deref(),
|
||||
&args.device,
|
||||
webserver,
|
||||
);
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
|
@ -20,10 +20,16 @@ pub struct HealthState {
|
||||
cpu_count: usize,
|
||||
cuda_devices: Vec<String>,
|
||||
version: Version,
|
||||
webserver: Option<bool>,
|
||||
}
|
||||
|
||||
impl HealthState {
|
||||
pub fn new(model: Option<&str>, chat_model: Option<&str>, device: &Device) -> Self {
|
||||
pub fn new(
|
||||
model: Option<&str>,
|
||||
chat_model: Option<&str>,
|
||||
device: &Device,
|
||||
webserver: Option<bool>,
|
||||
) -> Self {
|
||||
let (cpu_info, cpu_count) = read_cpu_info();
|
||||
|
||||
let cuda_devices = match read_cuda_devices() {
|
||||
@ -40,6 +46,7 @@ impl HealthState {
|
||||
cpu_count,
|
||||
cuda_devices,
|
||||
version: Version::new(),
|
||||
webserver,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
3
website/docs/configuration.md
vendored
3
website/docs/configuration.md
vendored
@ -93,7 +93,7 @@ Tabby collects usage stats by default. This data will only be used by the Tabby
|
||||
|
||||
### What data is collected?
|
||||
We collect non-sensitive data that helps us understand how Tabby is used. For now we collects `serve` command you used to start the server.
|
||||
As of the date 10/07/2023, the following information has been collected:
|
||||
As of the date 04/18/2024, the following information has been collected:
|
||||
|
||||
```rust
|
||||
struct HealthState {
|
||||
@ -105,6 +105,7 @@ struct HealthState {
|
||||
cpu_count: usize,
|
||||
cuda_devices: Vec<String>,
|
||||
version: Version,
|
||||
webserver: Option<bool>,
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user