Move scattered magic constants into src/consts.rs
Centralizes engine tuning values, poll intervals, logfmt column regex fragments, and app/settings identity strings that were previously defined ad hoc across engine.rs, ingest.rs, logfmt.rs, profile.rs, settings.rs, and main.rs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A1ZJ3SrayzLzVndhVq9BmS
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
1c635bc530
commit
284e3562a2
+6
-8
@@ -1,4 +1,9 @@
|
||||
use crate::alerts::{self, AlertRuntimeState};
|
||||
use crate::consts::{
|
||||
DEFAULT_TIMELINE_BUCKET_MS, INGEST_LAG_WATERMARK_MAX_ENTRIES, INGEST_LAG_WATERMARK_WINDOW_MS,
|
||||
MAX_AUTO_DECLARED_PARAMS, MAX_NEW_AUTO_PARAMS_PER_LINE, MERGE_WINDOW_MS,
|
||||
OTTYL_RESERVED_PARAM_NAMES, SORT_HELPER_INDEX_PURGE_AFTER,
|
||||
};
|
||||
use crate::data_value::{DataValue, MetricPrimitiveKind, ParamDeclaration};
|
||||
use crate::dto::{
|
||||
BucketValueDto, LogEntryDto, LogsParams, MetricDeclarationDto, ParamDeclarationDto,
|
||||
@@ -605,7 +610,6 @@ fn build_auto_param_pattern(key: &str, group: &str, quoted: bool) -> String {
|
||||
/// will never recur meaningfully. Chosen alongside `MAX_NEW_AUTO_PARAMS_PER_LINE` (below) rather than
|
||||
/// on its own: a per-line cap alone still lets an unbounded *variety* of lines each contribute a few
|
||||
/// new keys forever, so this total ceiling is the actual backstop.
|
||||
const MAX_AUTO_DECLARED_PARAMS: usize = 64;
|
||||
|
||||
/// Per-line ceiling on how many *new* params a single ingested line may contribute to the auto-derived
|
||||
/// set. Without this, one unusually wide line (the fixture's WiFi stat dump has 20+ `key=value` pairs
|
||||
@@ -613,7 +617,6 @@ const MAX_AUTO_DECLARED_PARAMS: usize = 64;
|
||||
/// more representative lines ingested later. Pairs beyond the cap are simply never declared (from this
|
||||
/// line or any other, since a later line with fewer pairs would still need to reach them within its own
|
||||
/// per-line budget) — acceptable since they're exactly the low-value, one-off counters ticket 050 flags.
|
||||
const MAX_NEW_AUTO_PARAMS_PER_LINE: usize = 8;
|
||||
|
||||
fn auto_derived_param_count(index: &BTreeMap<IndexKey, DataValue>) -> usize {
|
||||
param_declarations_range(index).filter(|declaration| declaration.6).count()
|
||||
@@ -1662,7 +1665,6 @@ struct SortHelperIndexEntry {
|
||||
/// `Settings` (ticket 061 explicitly scopes that out) — a dropped index is always transparently
|
||||
/// rebuildable on the next query for that sort key, so this is purely a memory-bound knob, not a
|
||||
/// user-visible behavior change.
|
||||
const SORT_HELPER_INDEX_PURGE_AFTER: std::time::Duration = std::time::Duration::from_secs(300);
|
||||
|
||||
/// Derives a single named param's value from `text`, for helper-index maintenance where deriving
|
||||
/// every declared param (`derive_log_params`) per ingested line would be wasted work when only one
|
||||
@@ -1833,11 +1835,9 @@ fn approx_log_bytes(text: &str) -> u64 {
|
||||
|
||||
/// Ticket 073: how long a rolling ingestion-to-engine-processing lag sample stays eligible to be
|
||||
/// the reported high watermark.
|
||||
const INGEST_LAG_WATERMARK_WINDOW_MS: i64 = 5000;
|
||||
/// Ticket 073: at most this many lag samples are held at once — a fresh sample only displaces the
|
||||
/// current *lowest*-lag held sample (never appended past this cap), so the collection always
|
||||
/// reflects the highest few lags seen recently rather than every sample.
|
||||
const INGEST_LAG_WATERMARK_MAX_ENTRIES: usize = 5;
|
||||
|
||||
/// Records one `(engine processing time) - (ottyl_ts)` lag sample into the rolling high-watermark
|
||||
/// collection the wishlist asked for (ticket 073): up to `INGEST_LAG_WATERMARK_MAX_ENTRIES` samples,
|
||||
@@ -2128,7 +2128,7 @@ fn handle_query_inner(
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
let bucket_ms = params.bucket_ms.unwrap_or(1_000).max(1);
|
||||
let bucket_ms = params.bucket_ms.unwrap_or(DEFAULT_TIMELINE_BUCKET_MS).max(1);
|
||||
let mut buckets: BTreeMap<i64, u64> = BTreeMap::new();
|
||||
for (sequence, timestamp, text) in logs_range(index).filter(|(_, timestamp, _)| {
|
||||
params.start_ms.is_none_or(|start| timestamp.as_millis() >= start)
|
||||
@@ -2336,7 +2336,6 @@ fn windowed_rate_series(
|
||||
/// the value axis. Occurrence timestamps across different label groups (e.g. different hosts serving
|
||||
/// the same path) essentially never land on the same millisecond, so summing/averaging only requires
|
||||
/// matching *this* window to combine into "total over time" rather than going sparse (ticket 042).
|
||||
const MERGE_WINDOW_MS: i64 = 1_000;
|
||||
|
||||
/// Merges several series into one combined time series (ticket 042). A single sub-series is returned
|
||||
/// untouched — there's only one contributor, so there's nothing to merge and no reason to lose
|
||||
@@ -2421,7 +2420,6 @@ fn declared_value_kind(
|
||||
/// `compile_ottyl_ts_comparison`/`compile_ottyl_fmt_comparison` for the filter-bar equivalent, and
|
||||
/// `webapp/src/components/Docs.tsx` for the user-facing docs. Shared by `evaluate_promql` (dashboard
|
||||
/// panels, this file) and `crate::api::list_params` (`GET /api/params` discoverability).
|
||||
pub const OTTYL_RESERVED_PARAM_NAMES: [&str; 3] = ["ottyl_seq", "ottyl_ts", "ottyl_fmt"];
|
||||
|
||||
/// For `ottyl_seq`/`ottyl_ts` only (not `ottyl_fmt`, which `evaluate_promql` rejects outright before
|
||||
/// this is consulted): returns a `(sequence, timestamp_ms) -> value` mapping used to synthesize a
|
||||
|
||||
Reference in New Issue
Block a user