Skip to content

Commit 8dc5d6f

Browse files
devin-ai-integration[bot]Convex, Inc.
authored and
Convex, Inc.
committed
Add uptime field to self-host beacon (#33830)
GitOrigin-RevId: f93c5777e9e71ce6f3762c6aedea6bf1fdb6bb2a
1 parent aff818f commit 8dc5d6f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/local_backend/src/beacon.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
//! This is similar to Sentry's self-hosted telemetry approach, focusing on
1111
//! anonymous and privacy-preserving metrics.
1212
13-
use std::time::Duration;
13+
use std::time::{
14+
Duration,
15+
SystemTime,
16+
};
1417

1518
use common::{
1619
backoff::Backoff,
@@ -29,6 +32,7 @@ const MAX_BACKOFF: Duration = Duration::from_secs(900); // 15 minutes
2932

3033
pub async fn start_beacon(runtime: ProdRuntime, database: Database<ProdRuntime>) {
3134
tracing::info!("Starting beacon coroutine...");
35+
let start_time = SystemTime::now();
3236
let mut backoff = Backoff::new(INITIAL_BACKOFF, MAX_BACKOFF);
3337

3438
loop {
@@ -38,11 +42,17 @@ pub async fn start_beacon(runtime: ProdRuntime, database: Database<ProdRuntime>)
3842
let globals = db_model.database_globals().await?;
3943

4044
let client = Client::new();
45+
let uptime = SystemTime::now()
46+
.duration_since(start_time)
47+
.unwrap_or_default()
48+
.as_secs();
49+
4150
let sent_json = serde_json::json!({
4251
"database_uuid": globals.id().to_string(),
4352
"migration_version": globals.version,
4453
"compiled_revision": COMPILED_REVISION,
4554
"commit_timestamp": COMMIT_TIMESTAMP,
55+
"uptime": uptime,
4656
});
4757
let url = "https://api.convex.dev/api/self_host_beacon";
4858
let response = client.post(url).json(&sent_json).send().await?;

0 commit comments

Comments
 (0)