Skip to content

Commit

Permalink
Merge pull request #494 from weibocom/kv_no_metrics_20241021
Browse files Browse the repository at this point in the history
kv 不统计err req
  • Loading branch information
hustfisher authored Oct 21, 2024
2 parents 34db998 + 6b26e78 commit 99b481a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
11 changes: 10 additions & 1 deletion 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 @@ -250,6 +250,15 @@ impl Protocol for Kv {
{
None
}

// kv走mc binary协议,get miss属于error不统计,只统计上行请求
#[inline]
fn metric_err(&self, req_op: Operation) -> bool {
match req_op {
Operation::Store => true,
_ => false,
}
}
}

impl Kv {
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 sharding/src/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub use rawsuffix::RawSuffix;

pub mod crc;

use enum_dispatch::enum_dispatch;
use self::{bkdrsub::Bkdrsub, crc64::Crc64, fnv1::Fnv1F32, fnv1::Fnv1aF64};
use enum_dispatch::enum_dispatch;

// 占位hash,主要用于兼容服务框架,供mq等业务使用
pub const HASH_PADDING: &str = "padding";
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 99b481a

Please sign in to comment.