File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 10
10
//! This is similar to Sentry's self-hosted telemetry approach, focusing on
11
11
//! anonymous and privacy-preserving metrics.
12
12
13
- use std:: time:: Duration ;
13
+ use std:: time:: {
14
+ Duration ,
15
+ SystemTime ,
16
+ } ;
14
17
15
18
use common:: {
16
19
backoff:: Backoff ,
@@ -29,6 +32,7 @@ const MAX_BACKOFF: Duration = Duration::from_secs(900); // 15 minutes
29
32
30
33
pub async fn start_beacon ( runtime : ProdRuntime , database : Database < ProdRuntime > ) {
31
34
tracing:: info!( "Starting beacon coroutine..." ) ;
35
+ let start_time = SystemTime :: now ( ) ;
32
36
let mut backoff = Backoff :: new ( INITIAL_BACKOFF , MAX_BACKOFF ) ;
33
37
34
38
loop {
@@ -38,11 +42,17 @@ pub async fn start_beacon(runtime: ProdRuntime, database: Database<ProdRuntime>)
38
42
let globals = db_model. database_globals ( ) . await ?;
39
43
40
44
let client = Client :: new ( ) ;
45
+ let uptime = SystemTime :: now ( )
46
+ . duration_since ( start_time)
47
+ . unwrap_or_default ( )
48
+ . as_secs ( ) ;
49
+
41
50
let sent_json = serde_json:: json!( {
42
51
"database_uuid" : globals. id( ) . to_string( ) ,
43
52
"migration_version" : globals. version,
44
53
"compiled_revision" : COMPILED_REVISION ,
45
54
"commit_timestamp" : COMMIT_TIMESTAMP ,
55
+ "uptime" : uptime,
46
56
} ) ;
47
57
let url = "https://api.convex.dev/api/self_host_beacon" ;
48
58
let response = client. post ( url) . json ( & sent_json) . send ( ) . await ?;
You can’t perform that action at this time.
0 commit comments