Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

newrelic/newrelic-telemetry-sdk-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

New Relic Open Source archived project banner.

Archival Notice

As of August 2023, we are archiving the Telemetry SDK C project.

New Relic Rust Telemetry SDK

Build status Release

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.

Getting Started

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;
}

Find and use your data

Tips on how to find and query your data in New Relic:

For general querying information, see:

Support

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

License

The Rust Telemetry SDK is licensed under the Apache 2.0 License.

Limitations

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.