TelemetryBuilder

Struct TelemetryBuilder 

Source
pub struct TelemetryBuilder {}
Expand description

Builder for configuring telemetry

Implementations§

Source§

impl TelemetryBuilder

Source

pub fn new() -> Self

Create a new telemetry builder

Source

pub fn service_name(self, _name: impl Into<String>) -> Self

Set the service name

Examples found in repository?
examples/basic.rs (line 45)
10fn main() {
11    println!("telemetry-kit v{}", env!("CARGO_PKG_VERSION"));
12    println!();
13    println!("This is a placeholder example.");
14    println!("The actual implementation is under development.");
15    println!();
16    
17    // This is how it will work in v0.1.0+:
18    println!("Example of planned API:");
19    println!();
20    println!(r#"
21    use telemetry_kit::prelude::*;
22
23    #[tokio::main]
24    async fn main() -> Result<(), Box<dyn std::error::Error>> {{
25        let _guard = telemetry_kit::init()
26            .service_name("my-app")
27            .endpoint("https://telemetry.myapp.com")
28            .anonymous()
29            .init()?;
30        
31        do_work().await?;
32        
33        Ok(())
34    }}
35
36    #[instrument]
37    async fn do_work() -> Result<(), Box<dyn std::error::Error>> {{
38        // Your code here - automatically instrumented!
39        Ok(())
40    }}
41    "#);
42    
43    // Current minimal implementation:
44    let _guard = telemetry_kit::init()
45        .service_name("basic-example")
46        .init();
47    
48    println!();
49    println!("✓ Basic initialization successful (placeholder)");
50}
Source

pub fn init(self) -> Result<TelemetryGuard, TelemetryError>

Initialize telemetry (placeholder)

§Errors

Currently returns Ok(()), but will return errors for invalid configuration in future versions.

Examples found in repository?
examples/basic.rs (line 46)
10fn main() {
11    println!("telemetry-kit v{}", env!("CARGO_PKG_VERSION"));
12    println!();
13    println!("This is a placeholder example.");
14    println!("The actual implementation is under development.");
15    println!();
16    
17    // This is how it will work in v0.1.0+:
18    println!("Example of planned API:");
19    println!();
20    println!(r#"
21    use telemetry_kit::prelude::*;
22
23    #[tokio::main]
24    async fn main() -> Result<(), Box<dyn std::error::Error>> {{
25        let _guard = telemetry_kit::init()
26            .service_name("my-app")
27            .endpoint("https://telemetry.myapp.com")
28            .anonymous()
29            .init()?;
30        
31        do_work().await?;
32        
33        Ok(())
34    }}
35
36    #[instrument]
37    async fn do_work() -> Result<(), Box<dyn std::error::Error>> {{
38        // Your code here - automatically instrumented!
39        Ok(())
40    }}
41    "#);
42    
43    // Current minimal implementation:
44    let _guard = telemetry_kit::init()
45        .service_name("basic-example")
46        .init();
47    
48    println!();
49    println!("✓ Basic initialization successful (placeholder)");
50}

Trait Implementations§

Source§

impl Default for TelemetryBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.