|
1
|
//! Sends timing data to the Onde Inference dashboard. |
|
2
|
//! |
|
3
|
//! GresIQ credentials are embedded in the SDK at build time — consumer apps |
|
4
|
//! never set them. Telemetry activates automatically when the SDK was built |
|
5
|
//! with a valid `.env` file containing `GRESIQ_API_KEY` and `GRESIQ_API_SECRET`. |
|
6
|
//! |
|
7
|
//! `ONDE_EDGE_ID` (read from the process environment at runtime) is what this |
|
8
|
//! machine gets called in the dashboard. Anything works — just keep it stable |
|
9
|
//! across restarts or you'll end up with duplicate edges. Defaults to |
|
10
|
//! `"onde-unknown"`. |
|
11
|
|
|
12
|
mod client; |
|
13
|
mod events; |
|
14
|
|
|
15
|
pub use client::PulseClient; |
|
16
|
pub use events::{InferenceEvent, ModelLoadedEvent}; |
|
17
|
|
|
18
|
use std::sync::atomic::{AtomicU64, Ordering}; |
|
19
|
|
|
20
|
/// Cheap unique ID per inference request. No uuid crate needed. |
|
21
|
/// Looks like `onde-1720000000000-42`. |
|
22
|
pub(crate) fn next_request_id() -> String { |
|
23
|
static COUNTER: AtomicU64 = AtomicU64::new(0); |
|
24
|
let ms = std::time::SystemTime::now() |
|
25
|
.duration_since(std::time::UNIX_EPOCH) |
|
26
|
.map(|d| d.as_millis() as u64) |
|
27
|
.unwrap_or(0); |
|
28
|
let seq = COUNTER.fetch_add(1, Ordering::Relaxed); |
|
29
|
format!("onde-{}-{}", ms, seq) |
|
30
|
} |