[][src]Struct ackorelic::transaction::Transaction

pub struct Transaction { /* fields omitted */ }

A transaction monitored by New Relic.

Methods

impl Transaction[src]

pub fn type(&self) -> &TransactionType[src]

Get the type of the transaction.

pub fn add_attribute<'a, T>(&self, name: &str, attribute: T) -> Result<()> where
    T: Into<Attribute<'a>>, 
[src]

Add an attribute to the transaction.

Returns an error if the New Relic SDK returns an error.

pub fn custom_segment<F, V>(&self, name: &str, category: &str, func: F) -> V where
    F: FnOnce(Segment) -> V, 
[src]

Create a custom segment within this transaction.

Example:

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

use newrelic::App;

let app = App::new("Test app", "Test license key")
    .expect("Could not create app");
let transaction = app
    .web_transaction("Test transaction")
    .expect("Could not start transaction");
transaction.custom_segment("Test segment", "Test category", |_| {
    thread::sleep(Duration::from_secs(1))
});

pub fn datastore_segment<F, V>(&self, params: &DatastoreParams, func: F) -> V where
    F: FnOnce(Segment) -> V, 
[src]

Create a datastore segment within this transaction.

Example:

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

use newrelic::{App, Datastore, DatastoreParamsBuilder};

let app = App::new("Test app", "Test license key")
    .expect("Could not create app");
let transaction = app
    .web_transaction("Test transaction")
    .expect("Could not start transaction");
let segment_params = DatastoreParamsBuilder::new(Datastore::Postgres)
    .collection("people")
    .operation("select")
    .build()
    .expect("Invalid datastore segment parameters");
transaction.datastore_segment(&segment_params, |_| {
    thread::sleep(Duration::from_secs(1))
});

pub fn external_segment<F, V>(&self, params: &ExternalParams, func: F) -> V where
    F: FnOnce(Segment) -> V, 
[src]

Create an external segment within this transaction.

Example:

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

use newrelic::{App, ExternalParamsBuilder};

let app = App::new("Test app", "Test license key")
    .expect("Could not create app");
let transaction = app
    .web_transaction("Test transaction")
    .expect("Could not start transaction");
let segment_params = ExternalParamsBuilder::new("https://www.rust-lang.org/")
    .procedure("GET")
    .library("reqwest")
    .build()
    .expect("Invalid external segment parameters");
transaction.external_segment(&segment_params, |_| {
    thread::sleep(Duration::from_secs(1))
});

pub fn notice_error(
    &self,
    priority: i32,
    message: &str,
    class: &str
) -> Result<()>
[src]

Record an error in this transaction.

priority is an arbitrary integer indicating the error priority. message is the error message; class is the error class or type.

pub fn ignore(&self) -> Result<()>[src]

Ignore this transaction.

Data for this transaction will not be sent to New Relic.

pub fn record_custom_metric(
    &self,
    metric_name: &str,
    duration: Duration
) -> Result<()>
[src]

Record a custom metric for this transaction.

The metric will be named according to metric_name and will record for duration.

pub fn custom_event(&self, event_type: &str) -> Result<CustomEvent>[src]

Create a custom event attached to this transaction.

Example:

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

use newrelic::App;

let app = App::new("Test app", "Test license key")
    .expect("Could not create app");
let transaction = app
    .web_transaction("Test transaction")
    .expect("Could not start transaction");
let custom_event = transaction.custom_event("My event")
    .expect("Could not create custom event");
custom_event.add_attribute("number of foos", 1_000);
custom_event.record();

pub fn end(&mut self)[src]

Explicitly end this transaction.

If this is not called, the transaction is automatically ended when dropped.

Trait Implementations

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> IntoSql for T[src]

fn into_sql<T>(self) -> Self::Expression where
    Self: AsExpression<T>, 
[src]

Convert self to an expression for Diesel's query builder. Read more

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
    &'a Self: AsExpression<T>, 
[src]

Convert &self to an expression for Diesel's query builder. Read more