Skip to content

Commit

Permalink
[ZK filter] Add per opcode decoder error metrics 2nd attempt (#31590)
Browse files Browse the repository at this point in the history
Signed-off-by: Zhewei Hu <zhewei.hu33@gmail.com>
  • Loading branch information
Winbobob authored Jan 8, 2024
1 parent 51b0a93 commit 79fed3b
Show file tree
Hide file tree
Showing 12 changed files with 491 additions and 260 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ message ZooKeeperProxy {
// Whether to emit per opcode response bytes metrics. If not set, it defaults to false.
bool enable_per_opcode_response_bytes_metrics = 8;

// [#not-implemented-hide:] Whether to emit per opcode decoder error metrics. If not set, it defaults to false.
// Whether to emit per opcode decoder error metrics. If not set, it defaults to false.
bool enable_per_opcode_decoder_error_metrics = 9;
}

Expand Down
4 changes: 4 additions & 0 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ new_features:
- area: access_log
change: |
Added support for ``%CONNECTION_ID%`` command operator for UDP session access log.
- area: zookeeper
change: |
Added support for emitting per opcode decoder error metrics via :ref:`enable_per_opcode_decoder_error_metrics
<envoy_v3_api_field_extensions.filters.network.zookeeper_proxy.v3.ZooKeeperProxy.enable_per_opcode_decoder_error_metrics>`.
deprecated:
- area: wasm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ static_resources:
stat_prefix: zookeeper
enable_per_opcode_request_bytes_metrics: true
enable_per_opcode_response_bytes_metrics: true
enable_per_opcode_decoder_error_metrics: true
enable_latency_threshold_metrics: true
default_latency_threshold: "0.1s"
latency_threshold_overrides:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,43 @@ Every configured ZooKeeper proxy filter has statistics rooted at *<stat_prefix>.

*_resp_bytes* are per-opcode metrics and will only be emitted when :ref:`enable_per_opcode_response_bytes_metrics <envoy_v3_api_field_extensions.filters.network.zookeeper_proxy.v3.ZooKeeperProxy.enable_per_opcode_response_bytes_metrics>` is set to ``true``.

*_decoder_error* are per-opcode metrics and will only be emitted when :ref:`enable_per_opcode_decoder_error_metrics <envoy_v3_api_field_extensions.filters.network.zookeeper_proxy.v3.ZooKeeperProxy.enable_per_opcode_decoder_error_metrics>` is set to ``true``.

The following counters are available:

.. csv-table::
:header: Name, Type, Description
:widths: 1, 1, 2

decoder_error, Counter, Number of times a message wasn't decoded
connect_decoder_error, Counter, Number of times a connect request or response message wasn't decoded
ping_decoder_error, Counter, Number of times a ping request or response message wasn't decoded
auth_decoder_error, Counter, Number of times a auth request or response message wasn't decoded
getdata_decoder_error, Counter, Number of times a getdata request or response message wasn't decoded
create_decoder_error, Counter, Number of times a create request or response message wasn't decoded
create2_decoder_error, Counter, Number of times a create2 request or response message wasn't decoded
createcontainer_decoder_error, Counter, Number of times a createcontainer request or response message wasn't decoded
createttl_decoder_error, Counter, Number of times a createttl request or response message wasn't decoded
setdata_decoder_error, Counter, Number of times a setdata request or response message wasn't decoded
getchildren_decoder_error, Counter, Number of times a getchildren request or response message wasn't decoded
getchildren2_decoder_error, Counter, Number of times a getchildren2 request or response message wasn't decoded
getephemerals_decoder_error, Counter, Number of times a getephemerals request or response message wasn't decoded
getallchildrennumber_decoder_error, Counter, Number of times a getallchildrennumber request or response message wasn't decoded
delete_decoder_error, Counter, Number of times a delete request or response message wasn't decoded
exists_decoder_error, Counter, Number of times a exists request or response message wasn't decoded
getacl_decoder_error, Counter, Number of times a getacl request or response message wasn't decoded
setacl_decoder_error, Counter, Number of times a setacl request or response message wasn't decoded
sync_decoder_error, Counter, Number of times a sync request or response message wasn't decoded
multi_decoder_error, Counter, Number of times a multi request or response message wasn't decoded
reconfig_decoder_error, Counter, Number of times a reconfig request or response message wasn't decoded
close_decoder_error, Counter, Number of times a close request or response message wasn't decoded
setauth_decoder_error, Counter, Number of times a setauth request or response message wasn't decoded
setwatches_decoder_error, Counter, Number of times a setwatches request or response message wasn't decoded
setwatches2_decoder_error, Counter, Number of times a setwatches2 request or response message wasn't decoded
addwatch_decoder_error, Counter, Number of times a addwatch request or response message wasn't decoded
checkwatches_decoder_error, Counter, Number of times a checkwatches request or response message wasn't decoded
removewatches_decoder_error, Counter, Number of times a removewatches request or response message wasn't decoded
check_decoder_error, Counter, Number of times a check request or response message wasn't decoded
request_bytes, Counter, Number of bytes in decoded request messages
connect_rq_bytes, Counter, Number of bytes in decoded connect request messages
ping_rq_bytes, Counter, Number of bytes in decoded ping request messages
Expand Down
7 changes: 5 additions & 2 deletions source/extensions/filters/network/zookeeper_proxy/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Network::FilterFactoryCb ZooKeeperConfigFactory::createFilterFactoryFromProtoTyp
proto_config.enable_per_opcode_request_bytes_metrics();
const bool enable_per_opcode_response_bytes_metrics =
proto_config.enable_per_opcode_response_bytes_metrics();
const bool enable_per_opcode_decoder_error_metrics =
proto_config.enable_per_opcode_decoder_error_metrics();
const bool enable_latency_threshold_metrics = proto_config.enable_latency_threshold_metrics();
const std::chrono::milliseconds default_latency_threshold(
PROTOBUF_GET_MS_OR_DEFAULT(proto_config, default_latency_threshold, 100));
Expand All @@ -49,8 +51,9 @@ Network::FilterFactoryCb ZooKeeperConfigFactory::createFilterFactoryFromProtoTyp

ZooKeeperFilterConfigSharedPtr filter_config(std::make_shared<ZooKeeperFilterConfig>(
stat_prefix, max_packet_bytes, enable_per_opcode_request_bytes_metrics,
enable_per_opcode_response_bytes_metrics, enable_latency_threshold_metrics,
default_latency_threshold, latency_threshold_overrides, context.scope()));
enable_per_opcode_response_bytes_metrics, enable_per_opcode_decoder_error_metrics,
enable_latency_threshold_metrics, default_latency_threshold, latency_threshold_overrides,
context.scope()));
auto& time_source = context.serverFactoryContext().mainThreadDispatcher().timeSource();

return [filter_config, &time_source](Network::FilterManager& filter_manager) -> void {
Expand Down
Loading

0 comments on commit 79fed3b

Please sign in to comment.