From 118bf12ba77dafcd6170b04fd2a6cc427a69ab52 Mon Sep 17 00:00:00 2001 From: Gustaw Lippa Date: Mon, 15 Jul 2024 16:39:09 +0200 Subject: [PATCH] Rename sent/received to out/in --- big_tests/tests/bosh_SUITE.erl | 8 +-- big_tests/tests/graphql_metric_SUITE.erl | 6 +-- big_tests/tests/mim_c2s_SUITE.erl | 12 ++--- big_tests/tests/websockets_SUITE.erl | 8 +-- .../MongooseIM-metrics.md | 51 +++++++++---------- src/c2s/mongoose_c2s.erl | 8 +-- src/c2s/mongoose_c2s_listener.erl | 8 +-- src/c2s/mongoose_c2s_ranch.erl | 12 ++--- 8 files changed, 56 insertions(+), 57 deletions(-) diff --git a/big_tests/tests/bosh_SUITE.erl b/big_tests/tests/bosh_SUITE.erl index d9e3448083a..aa4ef662386 100644 --- a/big_tests/tests/bosh_SUITE.erl +++ b/big_tests/tests/bosh_SUITE.erl @@ -960,7 +960,7 @@ negative_instrumentation_events() -> [{Name, #{}} || Name <- negative_instrumentation_events_names()]. negative_instrumentation_events_names() -> - [c2s_tcp_data_sent, - c2s_tcp_data_received, - c2s_tls_data_sent, - c2s_tls_data_received]. + [c2s_tcp_data_out, + c2s_tcp_data_in, + c2s_tls_data_out, + c2s_tls_data_in]. diff --git a/big_tests/tests/graphql_metric_SUITE.erl b/big_tests/tests/graphql_metric_SUITE.erl index 27ea5c4fde9..99a3b0735d3 100644 --- a/big_tests/tests/graphql_metric_SUITE.erl +++ b/big_tests/tests/graphql_metric_SUITE.erl @@ -253,7 +253,7 @@ get_metrics_as_dicts_with_nonexistent_key(Config) -> Result = get_metrics_as_dicts_with_keys([<<"not_existing">>], Config), ParsedResult = get_ok_value([data, metric, getMetricsAsDicts], Result), Map = dict_objects_to_map(ParsedResult), - RecvName = [<<"global">>, <<"c2s_xmpp_stanza_size_received">>, <<"byte_size">>], + RecvName = [<<"global">>, <<"c2s_xmpp_element_size_in">>, <<"byte_size">>], [] = maps:get(RecvName, Map). get_metrics_as_dicts_empty_args(Config) -> @@ -261,7 +261,7 @@ get_metrics_as_dicts_empty_args(Config) -> Result = get_metrics_as_dicts([], [<<"median">>], Config), ParsedResult = get_ok_value([data, metric, getMetricsAsDicts], Result), Map = dict_objects_to_map(ParsedResult), - RecvName = [<<"global">>, <<"c2s_xmpp_stanza_size_received">>, <<"byte_size">>], + RecvName = [<<"global">>, <<"c2s_xmpp_element_size_in">>, <<"byte_size">>], [#{<<"key">> := <<"median">>, <<"value">> := Median}] = maps:get(RecvName, Map), ?assert(is_integer(Median)), %% Empty keys @@ -377,7 +377,7 @@ check_node_result_is_valid(ResList, MetricsAreGlobal) -> [#{<<"key">> := <<"value">>,<<"value">> := V} | _] = maps:get([<<"global">>,<<"sm_unique_sessions">>,<<"count">>], Map), ?assert(is_integer(V)), - HistObjects = maps:get([<<"global">>, <<"c2s_xmpp_stanza_size_received">>, <<"byte_size">>], Map), + HistObjects = maps:get([<<"global">>, <<"c2s_xmpp_element_size_in">>, <<"byte_size">>], Map), check_histogram(kv_objects_to_map(HistObjects)). check_histogram(Map) -> diff --git a/big_tests/tests/mim_c2s_SUITE.erl b/big_tests/tests/mim_c2s_SUITE.erl index 994c8eaedc5..9efe2bd9e77 100644 --- a/big_tests/tests/mim_c2s_SUITE.erl +++ b/big_tests/tests/mim_c2s_SUITE.erl @@ -244,15 +244,15 @@ instrumentation_events() -> ++ [{c2s_message_processing_time, #{host_type => domain_helper:host_type()}}]. tcp_instrumentation_events() -> - [{c2s_tcp_data_sent, #{}}, - {c2s_tcp_data_received, #{}}]. + [{c2s_tcp_data_out, #{}}, + {c2s_tcp_data_in, #{}}]. tls_instrumentation_events() -> - [{c2s_tls_data_sent, #{}}, - {c2s_tls_data_received, #{}}]. + [{c2s_tls_data_out, #{}}, + {c2s_tls_data_in, #{}}]. common_instrumentation_events() -> HostType = domain_helper:host_type(), [{c2s_message_processing_time, #{host_type => HostType}}, - {c2s_xmpp_stanza_size_received, #{}}, - {c2s_xmpp_stanza_size_sent, #{}}]. + {c2s_xmpp_element_size_in, #{}}, + {c2s_xmpp_element_size_out, #{}}]. diff --git a/big_tests/tests/websockets_SUITE.erl b/big_tests/tests/websockets_SUITE.erl index a44dc5b639b..7d1ca274103 100644 --- a/big_tests/tests/websockets_SUITE.erl +++ b/big_tests/tests/websockets_SUITE.erl @@ -177,7 +177,7 @@ negative_instrumentation_events() -> [{Name, #{}} || Name <- negative_instrumentation_events_names()]. negative_instrumentation_events_names() -> - [c2s_tcp_data_sent, - c2s_tcp_data_received, - c2s_tls_data_sent, - c2s_tls_data_received]. + [c2s_tcp_data_out, + c2s_tcp_data_in, + c2s_tls_data_out, + c2s_tls_data_in]. diff --git a/doc/operation-and-maintenance/MongooseIM-metrics.md b/doc/operation-and-maintenance/MongooseIM-metrics.md index 642eef15879..058e10a1819 100644 --- a/doc/operation-and-maintenance/MongooseIM-metrics.md +++ b/doc/operation-and-maintenance/MongooseIM-metrics.md @@ -181,32 +181,31 @@ Metrics specific to an extension, e.g. Message Archive Management, are described | `[global, processQueueLengths]` | probe | The number of queued messages in the internal message queue of every erlang process, and the internal queue of every fsm (ejabberd\_s2s). This is sampled every 30 seconds asynchronously. It is a good indicator of an overloaded system: if too many messages are queued at the same time, the system is not able to process the data at the rate it was designed for. | ### Data metrics - -| Metric name | Type | Description | -|-------------------------------------------------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `[global, c2s_xmpp_stanza_size_received, byte_size]` | histogram | A size (in bytes) of a received stanza after decryption. | -| `[global, c2s_xmpp_stanza_size_sent, byte_size]` | histogram | A size (in bytes) of a sent stanza before encryption. | -| `[global, c2s_tcp_data_received, byte_size]` | spiral | A size (in bytes) of unencrypted data received from a client via TCP channel. | -| `[global, c2s_tcp_data_sent, byte_size]` | spiral | A size (in bytes) of unencrypted data sent to a client via TCP channel. | -| `[global, c2s_tls_data_received, byte_size]` | spiral | A size (in bytes) of a data received from a client via TLS channel after decryption. | -| `[global, c2s_tls_data_sent, byte_size]` | spiral | A size (in bytes) of a data sent to a client via TLS channel before encryption. | -| `[global, mod_bosh_data_received, byte_size]` | spiral | A size (in bytes) of a data received from a client via BOSH connection. | -| `[global, mod_bosh_data_sent, byte_size]` | spiral | A size (in bytes) of a data sent to a client via BOSH connection. | -| `[global, mod_websocket_data_received, byte_size]` | spiral | A size (in bytes) of a data received from a client via WebSocket connection. | -| `[global, mod_websocket_data_sent, byte_size]` | spiral | A size (in bytes) of a data sent to a client via WebSocket connection. | -| `[global, s2s_xmpp_element_size_in, byte_size]` | histogram | A size (in bytes) of a received XML element after decryption. | -| `[global, s2s_xmpp_element_size_out, byte_size]` | histogram | A size (in bytes) of a sent XML element before encryption. | -| `[global, s2s_tcp_data_in, byte_size]` | spiral | A size (in bytes) of unencrypted data in from a client via TCP channel. | -| `[global, s2s_tcp_data_out, byte_size]` | spiral | A size (in bytes) of unencrypted data out to a client via TCP channel. | -| `[global, s2s_tls_data_in, byte_size]` | spiral | A size (in bytes) of a data in from a client via TLS channel after decryption. | -| `[global, s2s_tls_data_out, byte_size]` | spiral | A size (in bytes) of a data out to a client via TLS channel before encryption. | -| `[global, component_xmpp_element_size_in, byte_size]` | histogram | A size (in bytes) of a received XML element after decryption. | -| `[global, component_xmpp_element_size_out, byte_size]` | histogram | A size (in bytes) of a sent XML element before encryption. | -| `[global, component_tcp_data_in, byte_size]` | spiral | A size (in bytes) of unencrypted data in from a client via TCP channel. | -| `[global, component_tcp_data_out, byte_size]` | spiral | A size (in bytes) of unencrypted data out to a client via TCP channel. | -| `[global, component_tls_data_in, byte_size]` | spiral | A size (in bytes) of a data in from a client via TLS channel after decryption. | -| `[global, component_tls_data_out, byte_size]` | spiral | A size (in bytes) of a data sent to a client via TLS channel before encryption. | -| `[global, data, dist]` | proplist | Network stats for an Erlang distributed communication. A proplist with values: `recv_oct`, `recv_cnt`, `recv_max`, `send_oct`, `send_max`, `send_cnt`, `send_pend`, `connections`. | +| Metric name | Type | Description | +| ----------- | ---- | ----------- | +| `[global, c2s_xmpp_element_size_in, byte_size]` | histogram | A size (in bytes) of a received stanza after decryption. | +| `[global, c2s_xmpp_element_size_out, byte_size]` | histogram | A size (in bytes) of a sent stanza before encryption. | +| `[global, c2s_tcp_data_in, byte_size]` | spiral | A size (in bytes) of unencrypted data received from a client via TCP channel. | +| `[global, c2s_tcp_data_out, byte_size]` | spiral | A size (in bytes) of unencrypted data sent to a client via TCP channel. | +| `[global, c2s_tls_data_in, byte_size]` | spiral | A size (in bytes) of a data received from a client via TLS channel after decryption. | +| `[global, c2s_tls_data_out, byte_size]` | spiral | A size (in bytes) of a data sent to a client via TLS channel before encryption. | +| `[global, mod_bosh_data_received, byte_size]` | spiral | A size (in bytes) of a data received from a client via BOSH connection. | +| `[global, mod_bosh_data_sent, byte_size]` | spiral | A size (in bytes) of a data sent to a client via BOSH connection. | +| `[global, mod_websocket_data_received, byte_size]` | spiral | A size (in bytes) of a data received from a client via WebSocket connection. | +| `[global, mod_websocket_data_sent, byte_size]` | spiral | A size (in bytes) of a data sent to a client via WebSocket connection. | +| `[global, s2s_xmpp_element_size_in, byte_size]` | histogram | A size (in bytes) of a received XML element after decryption. | +| `[global, s2s_xmpp_element_size_out, byte_size]` | histogram | A size (in bytes) of a sent XML element before encryption. | +| `[global, s2s_tcp_data_in, byte_size]` | spiral | A size (in bytes) of unencrypted data in from a client via TCP channel. | +| `[global, s2s_tcp_data_out, byte_size]` | spiral | A size (in bytes) of unencrypted data out to a client via TCP channel. | +| `[global, s2s_tls_data_in, byte_size]` | spiral | A size (in bytes) of a data in from a client via TLS channel after decryption. | +| `[global, s2s_tls_data_out, byte_size]` | spiral | A size (in bytes) of a data out to a client via TLS channel before encryption. | +| `[global, component_xmpp_element_size_in, byte_size]` | histogram | A size (in bytes) of a received XML element after decryption. | +| `[global, component_xmpp_element_size_out, byte_size]` | histogram | A size (in bytes) of a sent XML element before encryption. | +| `[global, component_tcp_data_in, byte_size]` | spiral | A size (in bytes) of unencrypted data in from a client via TCP channel. | +| `[global, component_tcp_data_out, byte_size]` | spiral | A size (in bytes) of unencrypted data out to a client via TCP channel. | +| `[global, component_tls_data_in, byte_size]` | spiral | A size (in bytes) of a data in from a client via TLS channel after decryption. | +| `[global, component_tls_data_out, byte_size]` | spiral | A size (in bytes) of a data sent to a client via TLS channel before encryption. | +| `[global, data, dist]` | proplist | Network stats for an Erlang distributed communication. A proplist with values: `recv_oct`, `recv_cnt`, `recv_max`, `send_oct`, `send_max`, `send_cnt`, `send_pend`, `connections`. | ### CETS system metrics diff --git a/src/c2s/mongoose_c2s.erl b/src/c2s/mongoose_c2s.erl index f6e9e345155..630934c6d53 100644 --- a/src/c2s/mongoose_c2s.erl +++ b/src/c2s/mongoose_c2s.erl @@ -81,9 +81,9 @@ instrumentation() -> -spec instrumentation(mongooseim:host_type_or_global()) -> [mongoose_instrument:spec()]. instrumentation(global) -> - [{c2s_xmpp_stanza_size_sent, #{}, + [{c2s_xmpp_element_size_out, #{}, #{metrics => #{byte_size => histogram}}}, - {c2s_xmpp_stanza_size_received, #{}, + {c2s_xmpp_element_size_in, #{}, #{metrics => #{byte_size => histogram}}}]; instrumentation(HostType) -> [{c2s_message_processing_time, #{host_type => HostType}, @@ -283,7 +283,7 @@ handle_socket_packet(StateData = #c2s_data{parser = Parser}, Packet) -> -spec handle_socket_elements(data(), [exml:element()], non_neg_integer()) -> fsm_res(). handle_socket_elements(StateData = #c2s_data{shaper = Shaper}, Elements, Size) -> {NewShaper, Pause} = mongoose_shaper:update(Shaper, Size), - [mongoose_instrument:execute(c2s_xmpp_stanza_size_received, #{}, + [mongoose_instrument:execute(c2s_xmpp_element_size_in, #{}, #{byte_size => elem_size(El)}) || El <- Elements], NewStateData = StateData#c2s_data{shaper = NewShaper}, @@ -1076,7 +1076,7 @@ do_send_element(StateData = #c2s_data{host_type = HostType}, Acc, #xmlel{} = El) send_xml(Data, XmlElement) when is_tuple(XmlElement) -> send_xml(Data, [XmlElement]); send_xml(#c2s_data{socket = Socket}, XmlElements) when is_list(XmlElements) -> - [mongoose_instrument:execute(c2s_xmpp_stanza_size_sent, #{}, #{byte_size => exml:xml_size(El)}) + [mongoose_instrument:execute(c2s_xmpp_element_size_out, #{}, #{byte_size => exml:xml_size(El)}) || El <- XmlElements], mongoose_c2s_socket:send_xml(Socket, XmlElements). diff --git a/src/c2s/mongoose_c2s_listener.erl b/src/c2s/mongoose_c2s_listener.erl index 447ddd427fc..f8cbcbc1936 100644 --- a/src/c2s/mongoose_c2s_listener.erl +++ b/src/c2s/mongoose_c2s_listener.erl @@ -21,13 +21,13 @@ -spec instrumentation(options()) -> [mongoose_instrument:spec()]. instrumentation(_Opts) -> - [{c2s_tcp_data_sent, #{}, + [{c2s_tcp_data_out, #{}, #{metrics => #{byte_size => spiral}}}, - {c2s_tls_data_sent, #{}, + {c2s_tls_data_out, #{}, #{metrics => #{byte_size => spiral}}}, - {c2s_tcp_data_received, #{}, + {c2s_tcp_data_in, #{}, #{metrics => #{byte_size => spiral}}}, - {c2s_tls_data_received, #{}, + {c2s_tls_data_in, #{}, #{metrics => #{byte_size => spiral}}}]. %% mongoose_listener diff --git a/src/c2s/mongoose_c2s_ranch.erl b/src/c2s/mongoose_c2s_ranch.erl index 6238105c570..cceba5b7c18 100644 --- a/src/c2s/mongoose_c2s_ranch.erl +++ b/src/c2s/mongoose_c2s_ranch.erl @@ -77,16 +77,16 @@ socket_handle_data(#state{transport = fast_tls, socket = TlsSocket}, {tcp, _, Da case fast_tls:recv_data(TlsSocket, Data) of {ok, DecryptedData} -> DataSize = byte_size(DecryptedData), - mongoose_instrument:execute(c2s_tls_data_received, #{}, #{byte_size => DataSize}), + mongoose_instrument:execute(c2s_tls_data_in, #{}, #{byte_size => DataSize}), DecryptedData; {error, Reason} -> {error, Reason} end; socket_handle_data(#state{transport = just_tls}, {ssl, _, Data}) -> - mongoose_instrument:execute(c2s_tls_data_received, #{}, #{byte_size => byte_size(Data)}), + mongoose_instrument:execute(c2s_tls_data_in, #{}, #{byte_size => byte_size(Data)}), Data; socket_handle_data(#state{transport = ranch_tcp, socket = Socket}, {tcp, Socket, Data}) -> - mongoose_instrument:execute(c2s_tcp_data_received, #{}, #{byte_size => byte_size(Data)}), + mongoose_instrument:execute(c2s_tcp_data_in, #{}, #{byte_size => byte_size(Data)}), Data. -spec socket_activate(state()) -> ok. @@ -118,13 +118,13 @@ socket_send_xml(#state{transport = Transport, socket = Socket}, XML) -> -spec send(transport(), ranch_transport:socket(), iodata()) -> ok | {error, term()}. send(fast_tls, Socket, Data) -> - mongoose_instrument:execute(c2s_tls_data_sent, #{}, #{byte_size => iolist_size(Data)}), + mongoose_instrument:execute(c2s_tls_data_out, #{}, #{byte_size => iolist_size(Data)}), fast_tls:send(Socket, Data); send(just_tls, Socket, Data) -> - mongoose_instrument:execute(c2s_tls_data_sent, #{}, #{byte_size => iolist_size(Data)}), + mongoose_instrument:execute(c2s_tls_data_out, #{}, #{byte_size => iolist_size(Data)}), just_tls:send(Socket, Data); send(ranch_tcp, Socket, Data) -> - mongoose_instrument:execute(c2s_tcp_data_sent, #{}, #{byte_size => iolist_size(Data)}), + mongoose_instrument:execute(c2s_tcp_data_out, #{}, #{byte_size => iolist_size(Data)}), ranch_tcp:send(Socket, Data). -spec get_peer_certificate(state(), mongoose_listener:options()) ->