Skip to content

Commit a7ddefe

Browse files
committed
address comments
1 parent a159099 commit a7ddefe

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

src/agent/config.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pub struct Config {
3232
pub metrics_server: metrics::Config,
3333
#[serde(default)]
3434
pub remote_keypair_loader: services::keypairs::Config,
35+
#[serde(default)]
36+
pub opentelemetry: OpenTelemetryConfig,
3537
}
3638

3739
impl Config {
@@ -83,3 +85,19 @@ impl Default for ChannelCapacities {
8385
}
8486
}
8587
}
88+
89+
90+
#[derive(Deserialize, Debug)]
91+
pub struct OpenTelemetryConfig {
92+
pub exporter_timeout_secs: u64,
93+
pub exporter_endpoint: String,
94+
}
95+
96+
impl Default for OpenTelemetryConfig {
97+
fn default() -> Self {
98+
Self {
99+
exporter_timeout_secs: 3,
100+
exporter_endpoint: "http://127.0.0.1:4317".to_string(),
101+
}
102+
}
103+
}

src/bin/agent.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,31 @@ struct Arguments {
3434

3535
#[tokio::main]
3636
async fn main() -> Result<()> {
37+
let args = Arguments::parse();
38+
39+
if !args.config.as_path().exists() {
40+
return Err(anyhow!("No config found under {:?}", args.config.to_str()));
41+
}
42+
43+
println!("Loading config from {:?}", args.config.display());
44+
45+
// Parse config early for logging channel capacity
46+
let config = Config::new(args.config).context("Could not parse config")?;
47+
3748
// Initialize a Tracing Subscriber
3849
let fmt_layer = tracing_subscriber::fmt::layer()
3950
.with_file(false)
4051
.with_line_number(true)
4152
.with_thread_ids(true)
42-
.with_target(true)
4353
.with_ansi(std::io::stderr().is_terminal());
4454

4555
// Set up the OpenTelemetry exporter, defaults to 127.0.0.1:4317
4656
let otlp_exporter = opentelemetry_otlp::new_exporter()
4757
.tonic()
48-
.with_timeout(Duration::from_secs(3));
58+
.with_endpoint(&config.opentelemetry.exporter_endpoint)
59+
.with_timeout(Duration::from_secs(
60+
config.opentelemetry.exporter_timeout_secs,
61+
));
4962

5063
// Set up the OpenTelemetry tracer
5164
let tracer = opentelemetry_otlp::new_pipeline()
@@ -69,17 +82,6 @@ async fn main() -> Result<()> {
6982
registry.with(fmt_layer.json()).init();
7083
}
7184

72-
let args = Arguments::parse();
73-
74-
if !args.config.as_path().exists() {
75-
return Err(anyhow!("No config found under {:?}", args.config.to_str()));
76-
}
77-
78-
println!("Loading config from {:?}", args.config.display());
79-
80-
// Parse config early for logging channel capacity
81-
let config = Config::new(args.config).context("Could not parse config")?;
82-
8385
// Launch the application. If it fails, print the full backtrace and exit. RUST_BACKTRACE
8486
// should be set to 1 for this otherwise it will only print the top-level error.
8587
if let Err(err) = start(config).await {

0 commit comments

Comments
 (0)