Skip to content

Commit 5ff122a

Browse files
incorporate suggestions
1 parent cb1d328 commit 5ff122a

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

src/cli.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use crate::{
3535
pub const DEFAULT_USERNAME: &str = "admin";
3636
pub const DEFAULT_PASSWORD: &str = "admin";
3737

38+
pub const DATASET_FIELD_COUNT_LIMIT: usize = 250;
3839
#[derive(Parser)]
3940
#[command(
4041
name = "parseable",
@@ -371,10 +372,10 @@ pub struct Options {
371372

372373
#[arg(
373374
long,
374-
env = "P_DATASET_FIELDS_ALLOWED_LIMIT",
375-
default_value = "250",
375+
env = "P_DATASET_FIELD_COUNT_LIMIT",
376+
default_value_t = DATASET_FIELD_COUNT_LIMIT,
376377
value_parser = validation::validate_dataset_fields_allowed_limit,
377-
help = "allowed limit for fields count in a dataset"
378+
help = "total number of fields recommended in a dataset"
378379
)]
379380
pub dataset_fields_allowed_limit: usize,
380381
}

src/handlers/http/ingest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ pub enum PostError {
468468
#[error("Ingestion is not allowed to stream {0} as it is already associated with a different OTEL format")]
469469
IncorrectLogFormat(String),
470470
#[error("Failed to ingest events in dataset {0}. Total number of fields {1} exceeds the permissible limit of {2}. We recommend creating a new dataset beyond {2} for better query performance.")]
471-
FieldsLimitExceeded(String, usize, usize),
471+
FieldsCountLimitExceeded(String, usize, usize),
472472
}
473473

474474
impl actix_web::ResponseError for PostError {
@@ -497,7 +497,7 @@ impl actix_web::ResponseError for PostError {
497497
PostError::MissingTimePartition(_) => StatusCode::BAD_REQUEST,
498498
PostError::KnownFormat(_) => StatusCode::BAD_REQUEST,
499499
PostError::IncorrectLogFormat(_) => StatusCode::BAD_REQUEST,
500-
PostError::FieldsLimitExceeded(_, _, _) => StatusCode::BAD_REQUEST,
500+
PostError::FieldsCountLimitExceeded(_, _, _) => StatusCode::BAD_REQUEST,
501501
}
502502
}
503503

src/handlers/http/modal/utils/ingest_utils.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ use crate::{
4747
const IGNORE_HEADERS: [&str; 3] = [STREAM_NAME_HEADER_KEY, LOG_SOURCE_KEY, EXTRACT_LOG_KEY];
4848
const MAX_CUSTOM_FIELDS: usize = 10;
4949
const MAX_FIELD_VALUE_LENGTH: usize = 100;
50-
// Maximum allowed count for fields in a dataset
51-
pub const DATASET_FIELDS_ALLOWED_LIMIT: usize = 250;
5250

5351
pub async fn flatten_and_push_logs(
5452
json: Value,
@@ -216,29 +214,27 @@ fn verify_dataset_fields_count(stream_name: &str) -> Result<(), PostError> {
216214
.get_schema()
217215
.fields()
218216
.len();
219-
let dataset_fields_warn_threshold = 0.8 * DATASET_FIELDS_ALLOWED_LIMIT as f64;
217+
let dataset_fields_warn_threshold = 0.8 * PARSEABLE.options.dataset_fields_allowed_limit as f64;
220218
// Check if the fields count exceeds the warn threshold
221219
if fields_count > dataset_fields_warn_threshold as usize {
222220
tracing::warn!(
223-
"Fields count {0} for dataset {1} has exceeded the warning threshold of {2} fields, Parseable recommends creating a new dataset.",
224-
fields_count,
221+
"Total fields in dataset {0} has reached the warning threshold of {1}. Ingestion will not be possible after reaching {2} fields. We recommend creating a new dataset.",
225222
stream_name,
226-
dataset_fields_warn_threshold);
223+
dataset_fields_warn_threshold,
224+
PARSEABLE.options.dataset_fields_allowed_limit
225+
);
227226
}
228227
// Check if the fields count exceeds the limit
229228
// Return an error if the fields count exceeds the limit
230229
if fields_count > PARSEABLE.options.dataset_fields_allowed_limit {
231-
tracing::error!(
232-
"Ingestion has been stopped for dataset {0} as fields count {1} exceeds the allowed limit of {2}, Please create a new dataset.",
233-
stream_name,
234-
fields_count,
235-
PARSEABLE.options.dataset_fields_allowed_limit);
236-
// Return an error if the fields count exceeds the limit
237-
return Err(PostError::FieldsLimitExceeded(
230+
let error = PostError::FieldsCountLimitExceeded(
238231
stream_name.to_string(),
239232
fields_count,
240233
PARSEABLE.options.dataset_fields_allowed_limit,
241-
));
234+
);
235+
tracing::error!("{}", error);
236+
// Return an error if the fields count exceeds the limit
237+
return Err(error);
242238
}
243239
Ok(())
244240
}

src/option.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub mod validation {
9191
path::{Path, PathBuf},
9292
};
9393

94-
use crate::handlers::http::modal::utils::ingest_utils::DATASET_FIELDS_ALLOWED_LIMIT;
94+
use crate::cli::DATASET_FIELD_COUNT_LIMIT;
9595
use path_clean::PathClean;
9696

9797
use super::{Compression, Mode};
@@ -177,16 +177,16 @@ pub mod validation {
177177

178178
pub fn validate_dataset_fields_allowed_limit(s: &str) -> Result<usize, String> {
179179
if let Ok(size) = s.parse::<usize>() {
180-
if (1..=DATASET_FIELDS_ALLOWED_LIMIT).contains(&size) {
180+
if (1..=DATASET_FIELD_COUNT_LIMIT).contains(&size) {
181181
Ok(size)
182182
} else {
183183
Err(format!(
184-
"Invalid value for P_DATASET_FIELDS_ALLOWED_LIMIT. It should be between 1 and {}",
185-
DATASET_FIELDS_ALLOWED_LIMIT
184+
"Invalid value for P_DATASET_FIELD_COUNT_LIMIT. It should be between 1 and {}",
185+
DATASET_FIELD_COUNT_LIMIT
186186
))
187187
}
188188
} else {
189-
Err("Invalid value for P_DATASET_FIELDS_ALLOWED_LIMIT. It should be given as integer value".to_string())
189+
Err("Invalid value for P_DATASET_FIELD_COUNT_LIMIT. It should be given as integer value".to_string())
190190
}
191191
}
192192
}

0 commit comments

Comments
 (0)