xtrace-client
Rust HTTP SDK for the xtrace observability service.
Installation
[]
= "0.0.15"
To enable automatic metric collection via tracing:
[]
= { = "0.0.15", = ["tracing"] }
Basic Usage
use ;
use HashMap;
use Utc;
async
tracing Integration (feature = "tracing")
XtraceLayer is a tracing::Layer that automatically pushes metrics to xtrace from tracing events and span durations — no manual push calls needed.
use SubscriberExt;
use SubscriberInitExt;
use ;
async
Metrics are batched (up to 50 per flush or every 500 ms) and pushed in a background thread — the tracing hot path is never blocked.
Available Methods
| Method | Endpoint |
|---|---|
healthz |
GET /healthz |
ingest_batch |
POST /v1/l/batch |
list_traces |
GET /api/public/traces |
get_trace |
GET /api/public/traces/:id |
metrics_daily |
GET /api/public/metrics/daily |
push_metrics |
POST /v1/metrics/batch |
query_metrics |
GET /api/public/metrics/query |
list_metric_names |
GET /api/public/metrics/names |
Metrics Query Parameters
query_metrics supports downsampling and aggregation:
| Parameter | Values | Default |
|---|---|---|
name |
metric name (required) | — |
from / to |
ISO8601 timestamps | last 1 hour |
labels |
JSON label filter | — |
step |
1m 5m 1h 1d |
1m |
agg |
avg max min sum last p50 p90 p99 |
avg |
group_by |
label key to group series by | — |
use MetricsQueryParams;
use HashMap;
let result = client.query_metrics.await?;
for series in &result.data