Skip to content

Commit

Permalink
fix: small refactor
Browse files Browse the repository at this point in the history
Signed-off-by: hlts2 <[email protected]>
  • Loading branch information
hlts2 committed Aug 6, 2024
1 parent 0264959 commit 373cafc
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions rust/libs/observability/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Config {
pub meter: Meter,
}

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Default)]
pub struct Tracer {
pub enabled: bool,
}
Expand All @@ -42,13 +42,7 @@ pub struct Meter {

impl Config {
pub fn new() -> Self {
Self {
enabled: false,
endpoint: "".to_string(),
attributes: HashMap::new(),
tracer: Tracer::default(),
meter: Meter::default(),
}
Self::default()
}

pub fn enabled(mut self, enabled: bool) -> Self {
Expand Down Expand Up @@ -84,7 +78,13 @@ impl Config {

impl Default for Config {
fn default() -> Self {
Self::new()
Self {
enabled: false,
endpoint: "".to_string(),
attributes: HashMap::new(),
tracer: Tracer::default(),
meter: Meter::default(),
}
}
}

Expand All @@ -101,7 +101,7 @@ impl From<&Config> for Resource {

impl Tracer {
pub fn new() -> Self {
Self { enabled: false }
Tracer::default()
}

pub fn enabled(mut self, enabled: bool) -> Self {
Expand All @@ -110,19 +110,9 @@ impl Tracer {
}
}

impl Default for Tracer {
fn default() -> Self {
Self::new()
}
}

impl Meter {
pub fn new() -> Self {
Self {
enabled: false,
export_duration: Duration::from_secs(1),
export_timeout_duration: Duration::from_secs(5),
}
Meter::default()
}

pub fn enabled(mut self, enabled: bool) -> Self {
Expand All @@ -143,6 +133,10 @@ impl Meter {

impl Default for Meter {
fn default() -> Self {
Self::new()
Self {
enabled: false,
export_duration: Duration::from_secs(1),
export_timeout_duration: Duration::from_secs(5),
}
}
}

0 comments on commit 373cafc

Please sign in to comment.