Skip to content

Commit

Permalink
refactor: use duration instead of _secs in config
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-bahjati committed Aug 1, 2024
1 parent 6b9a312 commit d0de1f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ key_store.mapping_key = "RelevantOracleMappingAddress"
[opentelemetry]

# Timeout in seconds for the OpenTelemetry exporter
exporter_timeout_secs = 3
exporter_timeout_duration = "3s"

# Endpoint URL for the OpenTelemetry exporter
exporter_endpoint = "http://127.0.0.1:4317"
10 changes: 7 additions & 3 deletions src/agent/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ use {
File,
},
serde::Deserialize,
std::path::Path,
std::{
path::Path,
time::Duration,
},
};

/// Configuration for all components of the Agent
Expand Down Expand Up @@ -88,6 +91,7 @@ impl Default for ChannelCapacities {

#[derive(Deserialize, Debug)]
pub struct OpenTelemetryConfig {
pub exporter_timeout_secs: u64,
pub exporter_endpoint: String,
#[serde(with = "humantime_serde")]
pub exporter_timeout_duration: Duration,
pub exporter_endpoint: String,
}
5 changes: 1 addition & 4 deletions src/bin/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use {
std::{
io::IsTerminal,
path::PathBuf,
time::Duration,
},
tracing_subscriber::{
prelude::*,
Expand Down Expand Up @@ -65,9 +64,7 @@ async fn main() -> Result<()> {
let otlp_exporter = opentelemetry_otlp::new_exporter()
.tonic()
.with_endpoint(&opentelemetry_config.exporter_endpoint)
.with_timeout(Duration::from_secs(
opentelemetry_config.exporter_timeout_secs,
));
.with_timeout(opentelemetry_config.exporter_timeout_duration);

// Set up the OpenTelemetry tracer
let tracer = opentelemetry_otlp::new_pipeline()
Expand Down

0 comments on commit d0de1f3

Please sign in to comment.