From 98c697e68b97cc32cfbf01cc7aa73f18a1e641c1 Mon Sep 17 00:00:00 2001 From: Sarah Hassan Date: Tue, 29 Oct 2024 16:40:24 -0700 Subject: [PATCH] fix bad ods keys Summary: bad ODS on msgdbtest ``` Bad ODS key: raft.transport.file.send.error.badrecord.-576448691609.19551027200 Original metric: {'raft.transport.file.send',{error,{badrecord,{-576448691609,19551027200}}}} ``` Differential Revision: D65180264 fbshipit-source-id: 1b15a2940060a26628a8aabd181f32bb412b2175 --- src/wa_raft_transport.erl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/wa_raft_transport.erl b/src/wa_raft_transport.erl index 1ebf85e..149623c 100644 --- a/src/wa_raft_transport.erl +++ b/src/wa_raft_transport.erl @@ -530,7 +530,7 @@ handle_call(Request, _From, #state{} = State) -> when Request :: {complete, ID :: transport_id(), FileID :: file_id(), Status :: term(), Pid :: pid()}. handle_cast({complete, ID, FileID, Status, Pid}, #state{counters = Counters} = State) -> NowMillis = erlang:system_time(millisecond), - ?RAFT_COUNT({'raft.transport.file.send', Status}), + ?RAFT_COUNT({'raft.transport.file.send', normalize_status(Status)}), Result0 = update_file_info(ID, FileID, fun (Info) -> case Info of @@ -852,3 +852,15 @@ scan_transport(_ID, Info) -> -spec schedule_scan() -> reference(). schedule_scan() -> erlang:send_after(?RAFT_TRANSPORT_SCAN_INTERVAL_SECS * 1000, self(), scan). + +-spec normalize_status(term()) -> atom(). +normalize_status(Status) when is_atom(Status) -> + Status; +normalize_status({_Error, Reason}) when is_atom(Reason) -> + Reason; +normalize_status({_Error, Reason}) when is_tuple(Reason) -> + normalize_status(element(1, Reason)); +normalize_status({Error, _Reason}) when is_atom(Error) -> + Error; +normalize_status(_) -> + unknown.