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 //! `ONDE_PULSE_COUNTRY` (or `ChatEngine::with_pulse_country`) declares the
13 //! device's ISO 3166-1 alpha-2 country for the public Pulse globe. It is only
14 //! written with `ONDE_PULSE_DUAL_WRITE` and an Onde app id, and
15 //! `ONDE_DISABLE_PULSE_GEOGRAPHY=1` turns it off on its own. Leave it unset
16 //! and no location is ever sent.
17
18 mod client;
19 mod events;
20
21 pub use client::PulseClient;
22 pub use events::{InferenceEvent, ModelLoadedEvent};
23
24 use std::sync::atomic::{AtomicU64, Ordering};
25
26 /// Cheap unique ID per inference request. No uuid crate needed.
27 /// Looks like `onde-1720000000000-42`.
28 pub(crate) fn next_request_id() -> String {
29 static COUNTER: AtomicU64 = AtomicU64::new(0);
30 let ms = std::time::SystemTime::now()
31 .duration_since(std::time::UNIX_EPOCH)
32 .map(|d| d.as_millis() as u64)
33 .unwrap_or(0);
34 let seq = COUNTER.fetch_add(1, Ordering::Relaxed);
35 format!("onde-{}-{}", ms, seq)
36 }