Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions examples/invalid_metrics_variant.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
generator:
- http:
seed: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53,
59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131]
headers:
content-type: "application/x-protobuf"
target_uri: "http://127.0.0.1:4318/v1/metrics"
bytes_per_second: "6 MiB"
parallel_connections: 5
method:
post:
maximum_prebuild_cache_size_bytes: "512 MiB"
variant: "opentelemetry_metrics"

blackhole:
- http:
binding_addr: "127.0.0.1:9091"
body_variant: "nothing"
- http:
binding_addr: "127.0.0.1:9092"
body_variant: "nothing"
- http:
binding_addr: "127.0.0.1:9093"
body_variant: "nothing"

target_metrics:
- prometheus:
uri: "http://127.0.0.1:5000/telemetry"
1 change: 1 addition & 0 deletions lading/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ serde = { workspace = true }
serde_json = { workspace = true }
serde_qs = { version = "0.15", default-features = false }
serde_yaml = { version = "0.9" }
serde_path_to_error = { version = "0.1" }
thiserror = { workspace = true }
tokio = { workspace = true, features = [
"rt",
Expand Down
21 changes: 18 additions & 3 deletions lading/src/bin/lading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
LadingObserver(#[from] lading::observer::Error),
#[error("Failed to deserialize Lading config: {0}")]
SerdeYaml(#[from] serde_yaml::Error),
#[error("Configuration error at {path}: {message}")]
ConfigPath { path: String, message: String },
#[error("Lading failed to sync servers {0}")]
Send(#[from] tokio::sync::broadcast::error::SendError<Option<i32>>),
#[error("Parsing Prometheus address failed: {0}")]
Expand Down Expand Up @@ -267,9 +269,22 @@
}

fn parse_config(contents: &str) -> Result<Config, Error> {
serde_yaml::from_str(contents).map_err(|err| {
error!("Configuration validation failed: {}", err);
Error::SerdeYaml(err)
let deserializer = serde_yaml::Deserializer::from_str(contents);
serde_path_to_error::deserialize(deserializer).map_err(|err| {

Check warning on line 273 in lading/src/bin/lading.rs

View workflow job for this annotation

GitHub Actions / Rust Actions (Check/Fmt/Clippy) (ubuntu-latest, fmt)

Diff in /home/runner/work/lading/lading/lading/src/bin/lading.rs

Check warning on line 273 in lading/src/bin/lading.rs

View workflow job for this annotation

GitHub Actions / Rust Actions (Check/Fmt/Clippy) (macos-latest, fmt)

Diff in /Users/runner/work/lading/lading/lading/src/bin/lading.rs
let path_info = err.path().to_string();
let inner_message = err.inner().to_string();

// Clean up the message to avoid redundancy - remove the path info if it's already in the inner message
let message = if inner_message.contains(&path_info) {
inner_message
} else {
format!("{} (at {})", inner_message, path_info)
};
error!("Configuration validation failed: {}", message);
Error::ConfigPath {
path: path_info,
message,
}
})
}

Expand Down
Loading