From e4a73f003a8f7ee5272de3f5c8fb6a9a6c4eca44 Mon Sep 17 00:00:00 2001 From: ieQu1 <99872536+ieQu1@users.noreply.github.com> Date: Sun, 19 May 2024 09:20:16 +0200 Subject: [PATCH] feat(ds): Implement format_status callback Reduce volume of logs and crash reports from DS --- .../src/emqx_ds_replication_layer_egress.erl | 9 ++++++++- .../src/emqx_ds_storage_layer.erl | 20 ++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/apps/emqx_durable_storage/src/emqx_ds_replication_layer_egress.erl b/apps/emqx_durable_storage/src/emqx_ds_replication_layer_egress.erl index 9201ccf04..dc76aecf0 100644 --- a/apps/emqx_durable_storage/src/emqx_ds_replication_layer_egress.erl +++ b/apps/emqx_durable_storage/src/emqx_ds_replication_layer_egress.erl @@ -33,7 +33,7 @@ -export([start_link/2, store_batch/3]). %% behavior callbacks: --export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2]). +-export([init/1, format_status/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2]). %% internal exports: -export([]). @@ -129,6 +129,13 @@ init([DB, Shard]) -> }, {ok, S}. +format_status(#s{db = DB, shard = Shard, queue = Q}) -> + #{ + db => DB, + shard => Shard, + queue => queue:len(Q) + }. + handle_call( #enqueue_req{ messages = Msgs, diff --git a/apps/emqx_durable_storage/src/emqx_ds_storage_layer.erl b/apps/emqx_durable_storage/src/emqx_ds_storage_layer.erl index 438955367..57930fa72 100644 --- a/apps/emqx_durable_storage/src/emqx_ds_storage_layer.erl +++ b/apps/emqx_durable_storage/src/emqx_ds_storage_layer.erl @@ -52,7 +52,7 @@ ]). %% gen_server --export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2]). +-export([init/1, format_status/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2]). %% internal exports: -export([db_dir/1]). @@ -586,6 +586,24 @@ init({ShardId, Options}) -> commit_metadata(S), {ok, S}. +format_status(#s{shard_id = ShardId, db = DB, cf_refs = CFRefs, schema = Schema, shard = Shard}) -> + #{ + id => ShardId, + db => DB, + cf_refs => CFRefs, + schema => Schema, + shard => + maps:map( + fun + (?GEN_KEY(_), _Schema) -> + '...'; + (_K, Val) -> + Val + end, + Shard + ) + }. + handle_call(#call_update_config{since = Since, options = Options}, _From, S0) -> case handle_update_config(S0, Since, Options) of S = #s{} ->