Rust

Installation

Add the following dependency to your Cargo.toml file:

[dependencies]
telemetry-sh = "1.0.0"
serde_json = "1.0"
chrono = "0.4"  # For handling timestamps (used in the log data)

Usage

Import Library

Add the necessary imports to your Rust file:

use telemetry_sh::Telemetry;
use serde_json::json;
use chrono::Utc;

Initialize Client

Initialize the Telemetry client with your API key:

fn main() {
    let mut telemetry = Telemetry::new();
    telemetry.init("YOUR_API_KEY".to_string());
}

Log Some Data

Telemetry automatically creates tables when data is logged. In the following example, we log some Uber ride data to a table called uber_rides. Telemetry will automatically create this table and its corresponding schema with columns: city, price, and timestamp.

Query Some Data

You can query the data using SQL through the query API:

Example Main Function

Here is an example of how you can integrate logging and querying data in your main function:

This documentation provides an overview of how to set up and use the Rust SDK for Telemetry, with examples of logging and querying data.

Last updated