What is the New Relic Rust Telemetry SDK?
- It's a helper library that supports sending New Relic data from within your Rust application.
- It's the foundation of New Relic's C Telemetry SDK.
- It’s an example of "best practices" for sending us data.
The Telemetry SDK provides you, the end-user programmer, with a Client
that sends Spans
to New Relic. Individual spans are collected together into batches (via a SpanBatch
object), and clients send these batches. It serves as a foundation for getting open-standards based telemetry data like OpenCensus, OpenTracing, and OpenTelemetry into New Relic. You can use this to build tracers/exporters, such as ones based on these open standards.
This SDK currently supports sending spans to the Trace API.
This project is currently in an alpha state. The API of this crate is likely to change, therefore there's no API documentation available yet.
In order to send telemetry data to New Relic APIs, you will need an Insert API key. To find out how to generate this key, see our docs.
The Rust Telemetry SDK is not published on crates.io
yet. In order to use it in your Rust application, you have to clone this
repository locally and include the crate via the local path name. If you
cloned the Rust Telemetry SDK into a vendor
subfolder of your Rust crate,
you can add it as a dependency to your crate by adding the following dependency
to your Cargo.toml
:
[dependencies]
newrelic-telemetry = { path = "vendor/newrelic-telemetry-sdk-rust" }
This is a simple application that sends a single span via the asynchronous client:
use newrelic_telemetry::{ClientBuilder, Span};
use std::env;
use std::time::{SystemTime, UNIX_EPOCH};
#[tokio::main]
async fn main() {
// Obtain a license key from the environment.
let license_key = env::var("NEW_RELIC_API_KEY").unwrap();
// Build an asynchronous client.
let client = ClientBuilder::new(&license_key).build().unwrap();
// Create a span and a span batch.
let span = Span::new(
"e9f54a2c322d7578",
"1b1bf29379951c1d",
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_millis() as u64,
)
.name("/index.html")
.attribute("username", "user")
.service_name("Telemetry Application");
let span_batch = vec![span].into();
// Send a span batch and await the future.
client.send_spans(span_batch).await;
}
Tips on how to find and query your data in New Relic:
For general querying information, see:
New Relic hosts and moderates an online forum where customers can interact with New Relic employees as well as other customers to get help and share best practices. Like all official New Relic open source projects, there's a related Community topic in the New Relic Explorers Hub. You can find this project's topic/threads in the Telemetry SDK section of Explorers Hub
We encourage your contributions to improve the Rust Telemetry SDK! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project. If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at opensource@newrelic.com.
The Rust Telemetry SDK is licensed under the Apache 2.0 License.
The New Relic Telemetry APIs are rate limited. Please reference the documentation for New Relic Metric API and New Relic Trace API requirements and limits on the specifics of the rate limits.