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
4 changes: 4 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ byte-unit = { version = "5.2", default-features = false, features = [
"byte",
"serde",
] }
chrono = "0.4.42"
sha2 = { version = "0.10", default-features = false }
metrics = { version = "0.24" }
metrics-util = "0.20"
Expand Down
2 changes: 2 additions & 0 deletions lading_payload/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ description = "A tool for load testing daemons."
[dependencies]
bytes = { workspace = true }
byte-unit = { workspace = true }
chrono = { workspace = true }
opentelemetry-proto = { workspace = true }
prost = { workspace = true }
rand = { workspace = true, features = ["small_rng", "std", "std_rng"] }
Expand All @@ -32,6 +33,7 @@ arbitrary = { version = "1", optional = true, features = ["derive"] }
proptest = { workspace = true }
proptest-derive = { workspace = true }
criterion = { version = "0.8", features = ["html_reports"] }
tempfile = { workspace = true }

[features]
default = []
Expand Down
24 changes: 24 additions & 0 deletions lading_payload/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ pub enum Error {
/// `StaticChunks` payload creation error
#[error(transparent)]
StaticChunks(#[from] crate::static_chunks::Error),
/// Static timestamp-grouped payload creation error
#[error(transparent)]
StaticTimestamped(#[from] crate::static_timestamped::Error),
/// Error for crate deserialization
#[error("Deserialization error: {0}")]
Deserialize(#[from] crate::Error),
Expand Down Expand Up @@ -354,6 +357,27 @@ impl Cache {
total_bytes.get(),
)?
}
crate::Config::StaticTimestamped {
static_path,
timestamp_format,
emit_placeholder,
start_line_index,
} => {
let span = span!(Level::INFO, "fixed", payload = "static-second");
let _guard = span.enter();
let mut serializer = crate::StaticTimestamped::new(
static_path,
timestamp_format,
*emit_placeholder,
*start_line_index,
)?;
construct_block_cache_inner(
&mut rng,
&mut serializer,
maximum_block_bytes,
total_bytes.get(),
)?
}
crate::Config::OpentelemetryTraces(config) => {
let mut pyld = crate::OpentelemetryTraces::with_config(*config, &mut rng)?;
let span = span!(Level::INFO, "fixed", payload = "otel-traces");
Expand Down
22 changes: 22 additions & 0 deletions lading_payload/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub use opentelemetry::metric::OpentelemetryMetrics;
pub use opentelemetry::trace::OpentelemetryTraces;
pub use splunk_hec::SplunkHec;
pub use static_chunks::StaticChunks;
pub use static_timestamped::StaticTimestamped;
pub use statik::Static;
pub use syslog::Syslog5424;

Expand All @@ -41,6 +42,7 @@ pub mod opentelemetry;
pub mod procfs;
pub mod splunk_hec;
pub mod static_chunks;
pub mod static_timestamped;
pub mod statik;
pub mod syslog;
pub mod trace_agent;
Expand Down Expand Up @@ -139,6 +141,23 @@ pub enum Config {
/// all files under it (non-recursively) will be read line by line.
static_path: PathBuf,
},
/// Generates static data grouped by second; each block contains one
/// second's worth of logs as determined by a parsed timestamp prefix.
StaticTimestamped {
/// Defines the file path to read static variant data from. Content is
/// assumed to be line-oriented.
static_path: PathBuf,
/// Chrono-compatible timestamp format string used to parse the leading
/// timestamp in each line.
timestamp_format: String,
/// Emit a minimal placeholder block (single newline) for seconds with
/// no lines. When false, empty seconds are skipped.
#[serde(default)]
emit_placeholder: bool,
/// Optional starting line offset; lines before this index are skipped.
#[serde(default)]
start_line_index: Option<u64>,
},
/// Generates a line of printable ascii characters
Ascii,
/// Generates a json encoded line
Expand Down Expand Up @@ -179,6 +198,8 @@ pub enum Payload {
Static(Static),
/// Static file content, chunked into lines that fill blocks as closely as possible.
StaticChunks(StaticChunks),
/// Static file content grouped into one-second blocks based on timestamps
StaticTimestamped(StaticTimestamped),
/// Syslog RFC 5424 format
Syslog(Syslog5424),
/// OpenTelemetry traces
Expand Down Expand Up @@ -208,6 +229,7 @@ impl Serialize for Payload {
Payload::SplunkHec(ser) => ser.to_bytes(rng, max_bytes, writer),
Payload::Static(ser) => ser.to_bytes(rng, max_bytes, writer),
Payload::StaticChunks(ser) => ser.to_bytes(rng, max_bytes, writer),
Payload::StaticTimestamped(ser) => ser.to_bytes(rng, max_bytes, writer),
Payload::Syslog(ser) => ser.to_bytes(rng, max_bytes, writer),
Payload::OtelTraces(ser) => ser.to_bytes(rng, max_bytes, writer),
Payload::OtelLogs(ser) => ser.to_bytes(rng, max_bytes, writer),
Expand Down
Loading
Loading