Skip to content

Commit cc4ecbc

Browse files
committed
fix: incorrect l7 metrics
1 parent 81af270 commit cc4ecbc

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

agent/src/common/l7_protocol_info.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -378,28 +378,26 @@ where
378378
param.flow_id, prev_info.msg_type, prev_info.time, cur_info.msg_type, cur_info.time,
379379
);
380380

381-
if prev_info.time > cur_info.time {
382-
if !cur_info.on_blacklist && cur_info.msg_type == LogMessageType::Request {
383-
timeout_counter.timeout[index] += 1;
384-
}
385-
if !prev_info.on_blacklist && prev_info.msg_type == LogMessageType::Request {
386-
timeout_counter.in_cache[index] += 1;
387-
}
388-
if !cur_info.on_blacklist {
381+
if cur_info.msg_type == prev_info.msg_type {
382+
let _ = timeout_counter.timeout[index].saturating_add(1);
383+
384+
let stats = if !cur_info.on_blacklist {
389385
Some(L7PerfStats::from(&cur_info))
390386
} else {
391387
None
392-
}
388+
};
389+
rtt_cache.put(key, cur_info).unwrap();
390+
391+
stats
393392
} else {
394-
if !prev_info.on_blacklist && prev_info.msg_type == LogMessageType::Request {
395-
timeout_counter.timeout[index] += 1;
393+
if !keep_prev {
394+
rtt_cache.pop(&key);
396395
}
397-
if !cur_info.on_blacklist && cur_info.msg_type == LogMessageType::Request {
398-
timeout_counter.in_cache[index] += 1;
399-
}
400-
let prev_info = rtt_cache.put(key, cur_info).unwrap();
401-
if !prev_info.on_blacklist {
402-
Some(L7PerfStats::from(&prev_info))
396+
397+
let _ = timeout_counter.in_cache[index].saturating_sub(1);
398+
399+
if !cur_info.on_blacklist {
400+
Some(L7PerfStats::from(&cur_info))
403401
} else {
404402
None
405403
}

agent/src/common/l7_protocol_log.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,13 @@ impl LogCache {
352352
pub fn is_request_of(&self, other: &Self) -> bool {
353353
self.msg_type == LogMessageType::Request
354354
&& other.msg_type == LogMessageType::Response
355-
&& self.time < other.time
355+
&& self.time <= other.time
356356
}
357357

358358
pub fn is_response_of(&self, other: &Self) -> bool {
359359
self.msg_type == LogMessageType::Response
360360
&& other.msg_type == LogMessageType::Request
361-
&& self.time > other.time
361+
&& self.time >= other.time
362362
}
363363
}
364364

0 commit comments

Comments
 (0)