pub struct SequenceLearner;Expand description
Sequence learner for discovering behavioral patterns
Implementations§
Source§impl SequenceLearner
impl SequenceLearner
Sourcepub async fn discover_sequences_from_traces(
provider: &dyn TraceQueryProvider,
min_frequency: f64,
min_requests_per_trace: Option<usize>,
) -> Result<Vec<BehavioralSequence>>
pub async fn discover_sequences_from_traces( provider: &dyn TraceQueryProvider, min_frequency: f64, min_requests_per_trace: Option<usize>, ) -> Result<Vec<BehavioralSequence>>
Discover sequences from trace correlation
Uses trace_id/span_id to find correlated request sequences and identifies common patterns.
This implementation:
- Queries database for requests grouped by trace_id
- Orders by timestamp within each trace
- Identifies common subsequences (e.g., login → list → detail)
- Calculates transition probabilities between steps
- Returns reusable behavioral sequences
Sourcepub fn learn_sequence_pattern(
sequences: &[Vec<(String, String, Option<u64>)>],
min_frequency: f64,
) -> Result<Vec<BehavioralSequence>>
pub fn learn_sequence_pattern( sequences: &[Vec<(String, String, Option<u64>)>], min_frequency: f64, ) -> Result<Vec<BehavioralSequence>>
Learn sequence pattern from a set of request sequences
Analyzes multiple sequences to extract common patterns and calculate confidence scores.
Each sequence is represented as (endpoint, method, delay_ms) tuples.
Sourcepub fn match_sequence<'a>(
sequences: &'a [BehavioralSequence],
endpoint: &str,
method: &str,
conditions: Option<&HashMap<String, String>>,
) -> Option<(&'a BehavioralSequence, usize)>
pub fn match_sequence<'a>( sequences: &'a [BehavioralSequence], endpoint: &str, method: &str, conditions: Option<&HashMap<String, String>>, ) -> Option<(&'a BehavioralSequence, usize)>
Check if an incoming request matches a learned sequence
Returns the matching sequence and current step index if found.
Sourcepub fn find_next_step(
sequence: &BehavioralSequence,
current_step_idx: usize,
endpoint: &str,
method: &str,
) -> Option<usize>
pub fn find_next_step( sequence: &BehavioralSequence, current_step_idx: usize, endpoint: &str, method: &str, ) -> Option<usize>
Find the next step in a sequence given the current step
Returns the next step index if found, or None if sequence is complete.
Auto Trait Implementations§
impl Freeze for SequenceLearner
impl RefUnwindSafe for SequenceLearner
impl Send for SequenceLearner
impl Sync for SequenceLearner
impl Unpin for SequenceLearner
impl UnsafeUnpin for SequenceLearner
impl UnwindSafe for SequenceLearner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more