Skip to content

Commit

Permalink
kv 不统计retrieve err req
Browse files Browse the repository at this point in the history
  • Loading branch information
hustfisher committed Oct 21, 2024
1 parent fb02c06 commit 6b26e78
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
11 changes: 7 additions & 4 deletions protocol/src/kv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ use super::Flag;
use super::Protocol;
use crate::kv::client::Client;
use crate::kv::error::Error;
use crate::Command;
use crate::HandShake;
use crate::HashedCommand;
use crate::RequestProcessor;
use crate::Stream;
use crate::{Command, Operation};
use ds::RingSlice;

use sharding::hash::Hash;
Expand Down Expand Up @@ -251,10 +251,13 @@ impl Protocol for Kv {
None
}

// kv目前也不统计error,因为kv走mc binary协议,error基本都是get miss这种,不需要统计
// kv走mc binary协议,get miss属于error不统计,只统计上行请求
#[inline]
fn metric_err(&self) -> bool {
false
fn metric_err(&self, req_op: Operation) -> bool {
match req_op {
Operation::Store => true,
_ => false,
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions protocol/src/memcache/binary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub use packet::Binary;
pub struct MemcacheBinary;

use crate::{
Command, Commander, Error, Flag, HashedCommand, Metric, MetricItem, Protocol, RequestProcessor,
Result, Stream, Writer,
Command, Commander, Error, Flag, HashedCommand, Metric, MetricItem, Operation, Protocol,
RequestProcessor, Result, Stream, Writer,
};

use sharding::hash::Hash;
Expand Down Expand Up @@ -193,7 +193,7 @@ impl Protocol for MemcacheBinary {

// mc目前不需要统计error,因为mc的error基本都是get miss,del not-found这种,这种错误不需要统计
#[inline]
fn metric_err(&self) -> bool {
fn metric_err(&self, _req_op: Operation) -> bool {
false
}
}
Expand Down
2 changes: 1 addition & 1 deletion protocol/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub trait Proto: Unpin + Clone + Send + Sync + 'static {
1_u8
}

fn metric_err(&self) -> bool {
fn metric_err(&self, _req_op: Operation) -> bool {
true
}
}
Expand Down
2 changes: 1 addition & 1 deletion stream/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ where
self.num.rx();
// 统计请求耗时、异常响应
self.rtt += start.elapsed();
if self.parser.metric_err() && !cmd.ok() {
if self.parser.metric_err(req.operation()) && !cmd.ok() {
self.err += 1;
}

Expand Down
2 changes: 1 addition & 1 deletion stream/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ where
}

// 不区分是否last,这样更精确的感知总的异常响应数量
if self.parser.metric_err() && !rsp_ok {
if self.parser.metric_err(op) && !rsp_ok {
*self.metrics.err() += 1;
}
}
Expand Down

0 comments on commit 6b26e78

Please sign in to comment.