pub struct TensorBaseMetricsBackend(/* private fields */);Expand description
Scale-out TensorBase metrics storage over its ClickHouse-compatible protocol.
Use connect with a full protocol URL or
connect_host for the default native port (9528). Pair this type
with TensorBaseEventsBackend when building the runtime.
§Examples
Facade wiring through Spectra::builder() (requires the spectra crate with the
tensorbase feature):
ⓘ
use std::sync::Arc;
use spectra::{Spectra, TensorBaseEventsBackend, TensorBaseMetricsBackend};
let url = "tcp://127.0.0.1:9528";
let spectra = Spectra::builder()
.metrics_backend(Arc::new(TensorBaseMetricsBackend::connect(url).await?))
.events_backend(Arc::new(TensorBaseEventsBackend::connect(url).await?))
.build()?;Implementations§
Source§impl TensorBaseMetricsBackend
impl TensorBaseMetricsBackend
Sourcepub async fn connect(url: &str) -> Result<TensorBaseMetricsBackend, Error>
pub async fn connect(url: &str) -> Result<TensorBaseMetricsBackend, Error>
Connect with a full TensorBase protocol URL and ensure metrics tables exist.
Accepts tcp://host:9528 (native) or an HTTP ClickHouse-compatible endpoint. The call
is async and executes DDL.
§Examples
ⓘ
use spectra_backend_tensorbase::TensorBaseMetricsBackend;
let backend = TensorBaseMetricsBackend::connect("tcp://127.0.0.1:9528").await?;Sourcepub async fn connect_host(host: &str) -> Result<TensorBaseMetricsBackend, Error>
pub async fn connect_host(host: &str) -> Result<TensorBaseMetricsBackend, Error>
Sourcepub fn in_memory_stub() -> TensorBaseMetricsBackend
pub fn in_memory_stub() -> TensorBaseMetricsBackend
In-memory stub that preserves the TensorBase engine type for storage-contract tests.
§Examples
use spectra_backend_tensorbase::TensorBaseMetricsBackend;
use spectra_core::{MetricsStorageBackend, StorageEngineType};
let backend = TensorBaseMetricsBackend::in_memory_stub();
assert_eq!(backend.engine_type(), StorageEngineType::TensorBase);Trait Implementations§
Source§impl MetricsStorageBackend for TensorBaseMetricsBackend
impl MetricsStorageBackend for TensorBaseMetricsBackend
Source§fn engine_type(&self) -> StorageEngineType
fn engine_type(&self) -> StorageEngineType
Returns the engine type for this backend.
Source§fn record_counter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
labels: &'life2 Value,
delta: i64,
ts: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
TensorBaseMetricsBackend: 'async_trait,
fn record_counter<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
labels: &'life2 Value,
delta: i64,
ts: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
TensorBaseMetricsBackend: 'async_trait,
Records a counter increment.
Source§fn record_gauge<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
labels: &'life2 Value,
value: f64,
ts: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
TensorBaseMetricsBackend: 'async_trait,
fn record_gauge<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
labels: &'life2 Value,
value: f64,
ts: DateTime<Utc>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
TensorBaseMetricsBackend: 'async_trait,
Records a gauge sample.
Source§fn record_metrics_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
rows: &'life1 [MetricWriteRow],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
TensorBaseMetricsBackend: 'async_trait,
fn record_metrics_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
rows: &'life1 [MetricWriteRow],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
TensorBaseMetricsBackend: 'async_trait,
Batch write metrics (default: per-row dispatch).
Source§fn query_range<'life0, 'async_trait>(
&'life0 self,
query: MetricsQueryRange,
) -> Pin<Box<dyn Future<Output = Result<Vec<MetricPoint>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
TensorBaseMetricsBackend: 'async_trait,
fn query_range<'life0, 'async_trait>(
&'life0 self,
query: MetricsQueryRange,
) -> Pin<Box<dyn Future<Output = Result<Vec<MetricPoint>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
TensorBaseMetricsBackend: 'async_trait,
Queries a time range of metric points.
Auto Trait Implementations§
impl !RefUnwindSafe for TensorBaseMetricsBackend
impl !UnwindSafe for TensorBaseMetricsBackend
impl Freeze for TensorBaseMetricsBackend
impl Send for TensorBaseMetricsBackend
impl Sync for TensorBaseMetricsBackend
impl Unpin for TensorBaseMetricsBackend
impl UnsafeUnpin for TensorBaseMetricsBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more