[][src]Crate ackorelic

A Rust wrapper over the New Relic C SDK.

See also the [rocket_newrelic] crate for example integration with the Rocket web framework.


Note: versions 0.1.0 onwards of this crate are completely incompatible with previous versions as they move away from the deprecated New Relic SDK to the newer New Relic C SDK. This has additional requirements: see https://docs.newrelic.com/docs/agents/c-sdk/get-started/introduction-c-sdk for details.

In particular, the New Relic SDK will not link against musl - see the newrelic-sys crate for more details.

See https://github.com/hjr3/newrelic-rs for the <0.1.0 repository.

Usage

Add this crate to your Cargo.toml:

[dependencies]
new-relic = "0.2"

You can then instrument your code as follows:

use std::{env, thread, time::Duration};

use newrelic::{App, NewRelicConfig};

fn main() {
    let license_key =
        env::var("NEW_RELIC_LICENSE_KEY").unwrap_or_else(|_| "example-license-key".to_string());
    let app = App::new("my app", &license_key).expect("Could not create app");

    // Start a web transaction and a segment
    let _transaction = app
        .web_transaction("Transaction name")
        .expect("Could not start transaction");
    thread::sleep(Duration::from_secs(1));

    // Transaction ends automatically.

    // App is destroyed automatically.
}

There are several more detailed examples in the examples directory of the crate repository, demonstrating features such as simple and nested segments and custom events.

This crate still requires the New Relic daemon to be running as per the documentation for the New Relic C SDK; be sure to read this first.

Re-exports

pub use crate::transaction::Attribute;
pub use crate::transaction::Transaction;

Modules

acko_segment
newrelic_fn
nr_connection
nr_init
skill
tables
transaction
utils

Structs

App

A New Relic application.

AppConfig

Application config used by New Relic.

CustomEvent

A custom event to be added to a transaction.

DatastoreParams

Parameters used to instrument datastore segments.

DatastoreParamsBuilder

Builder for parameters used to instrument datastore segments.

ExternalParams

Parameters used to instrument external segments.

ExternalParamsBuilder

Builder for parameters used to instrument external calls.

NewRelicConfig

Custom configuration used to connect to the New Relic daemon.

Segment

A segment within a transaction.

Enums

Datastore

The datastore type, used when instrumenting a datastore segment.

Error

An error caused by the New Relic SDK.

LogLevel

An enum representing the available verbosity levels of the logger.

LogOutput

The output of the New Relic SDK logs.

Type Definitions

Result

A Result used by the New Relic library.