Skip to content

Commit

Permalink
Rename sent/received to out/in
Browse files Browse the repository at this point in the history
  • Loading branch information
gustawlippa committed Jul 15, 2024
1 parent 87ee12e commit d85d90a
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 57 deletions.
8 changes: 4 additions & 4 deletions big_tests/tests/bosh_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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].
6 changes: 3 additions & 3 deletions big_tests/tests/graphql_metric_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ 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) ->
%% Empty name
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
Expand Down Expand Up @@ -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) ->
Expand Down
12 changes: 6 additions & 6 deletions big_tests/tests/mim_c2s_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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, #{}}].
8 changes: 4 additions & 4 deletions big_tests/tests/websockets_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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].
51 changes: 25 additions & 26 deletions doc/operation-and-maintenance/MongooseIM-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/c2s/mongoose_c2s.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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).

Expand Down
8 changes: 4 additions & 4 deletions src/c2s/mongoose_c2s_listener.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/c2s/mongoose_c2s_ranch.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()) ->
Expand Down

0 comments on commit d85d90a

Please sign in to comment.