Rust Mobile Telemetry 🚀
Observability made simple for mobile backends and edge services.
rust_mobile_telemetry is a production-ready Rust crate that helps you understand exactly what is happening in your application. It provides tracing (timelines of operations) and metrics (counters, gauges) with minimal setup, tailored for mobile-backend environments where device metadata (like OS version or Device ID) is critical for debugging.
Why use this?
- 🔍 Instant Visibility: See full request traces and performance metrics immediately.
- 📱 Mobile-First: Automatically attaches mobile metadata (App Version, OS, Device ID) to every trace.
- ⚡ Zero-Config Defaults: Works out of the box with sensible defaults, but fully customizable.
- 🔌 OpenTelemetry Standard: Built on the industry-standard OpenTelemetry ecosystem, compatible with Jaeger, Prometheus, Honeycomb, Datadog, and more.
📦 Installation
Add this to your Cargo.toml:
[]
= "0.1.1"
🚀 Getting Started
1. Initialize Telemetry
Call init_telemetry at the start of your main function. This sets up the global tracer and meter.
use ;
async
2. Instrument Your Code
Wrap operations in spans to track how long they take.
use with_span;
3. Record Metrics
Count events or measure latencies.
use ;
⚙️ Configuration Options
You can configure the library using the ConfigBuilder or Environment Variables.
| Option | Builder Method | Env Variable | Description |
|---|---|---|---|
| Service Name | .service_name("name") |
OTEL_SERVICE_NAME |
Name of your service (e.g., auth-api). |
| Exporter | .exporter_type(type) |
N/A | Where to send data: Console (stdout) or Otlp (collector). |
| OTLP Endpoint | .otlp_endpoint("url") |
OTEL_EXPORTER_OTLP_ENDPOINT |
URL for OTLP exporter (default: http://localhost:4317). |
| Metrics | .enable_metrics(bool) |
N/A | Enable/disable metrics collection. |
| Tracing | .enable_tracing(bool) |
N/A | Enable/disable tracing. |
Example: Production Config (OTLP)
For production, you typically want to send data to an OpenTelemetry Collector or a vendor (like Honeycomb/Datadog).
let config = new
.service_name
.exporter_type // Send over network
.otlp_endpoint
.build;
❓ Troubleshooting
"File locking" error on Windows
If you see os error 32 during build or publish, it's likely an antivirus or the OS locking the build directory.
Fix: Restart your terminal or computer.
No output in Console?
Ensure you initialized with ExporterType::Console and that your application runs long enough to flush data (or call shutdown_telemetry()).
📄 License
MIT License. See LICENSE for details.