[−][src]Struct ackorelic::Segment
A segment within a transaction.
Use segments to instrument transactions with greater granularity.
Segments are created using the various methods on a Transaction
.
Segments can be nested by calling the various _nested
methods on
an existing segment.
Methods
impl<'a> Segment<'a>
[src]
pub fn custom(transaction: &'a Transaction, name: &str, category: &str) -> Self
[src]
Doc
pub fn custom_nested<F, V>(&self, name: &str, category: &str, func: F) -> V where
F: FnOnce(Segment) -> V,
[src]
F: FnOnce(Segment) -> V,
Create a new segment nested within this one.
name
and category
will have any null bytes removed before
creating the segment.
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("Transaction name") .expect("Could not start transaction"); let value = transaction.custom_segment("Segment name", "Segment category", |s| { thread::sleep(Duration::from_secs(1)); let expensive_val_1 = s.custom_nested("First nested segment", "Nested category", |_| { thread::sleep(Duration::from_secs(1)); 3 }); let expensive_val_2 = s.custom_nested("Second nested segment", "Nested category", |_| { thread::sleep(Duration::from_secs(1)); 2 }); expensive_val_1 * expensive_val_2 });
pub fn datastore_nested<F, V>(&self, params: &DatastoreParams, func: F) -> V where
F: FnOnce(Segment) -> V,
[src]
F: FnOnce(Segment) -> V,
Create a new datastore segment nested within this one.
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("Transaction name") .expect("Could not start transaction"); let value = transaction.custom_segment("Segment name", "Segment category", |s| { thread::sleep(Duration::from_secs(1)); let datastore_segment_params = DatastoreParamsBuilder::new(Datastore::Postgres) .collection("people") .operation("select") .build() .expect("Invalid datastore segment parameters"); let expensive_val = s.datastore_nested(&datastore_segment_params, |_| { thread::sleep(Duration::from_secs(1)); 3 }); expensive_val * 2 });
pub fn external_nested<F, V>(&self, params: &ExternalParams, func: F) -> V where
F: FnOnce(Segment) -> V,
[src]
F: FnOnce(Segment) -> V,
Create a new external segment nested within this one.
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("Transaction name") .expect("Could not start transaction"); let value = transaction.custom_segment("Segment name", "Segment category", |s| { thread::sleep(Duration::from_secs(1)); let external_segment_params = ExternalParamsBuilder::new("https://www.rust-lang.org/") .procedure("GET") .library("reqwest") .build() .expect("Invalid external segment parameters"); let expensive_val = s.external_nested(&external_segment_params, |_| { thread::sleep(Duration::from_secs(1)); 3 }); expensive_val * 2 });
pub fn end(&mut self)
[src]
Explicitly end this segment.
If this is not called, the segment is automatically ended when dropped.
Trait Implementations
Auto Trait Implementations
impl<'a> Unpin for Segment<'a>
impl<'a> !Sync for Segment<'a>
impl<'a> !Send for Segment<'a>
impl<'a> UnwindSafe for Segment<'a>
impl<'a> RefUnwindSafe for Segment<'a>
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> IntoSql for T
[src]
fn into_sql<T>(self) -> Self::Expression where
Self: AsExpression<T>,
[src]
Self: AsExpression<T>,
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]
&'a Self: AsExpression<T>,
Convert &self
to an expression for Diesel's query builder. Read more