Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrument/hook handlers: c2s #4310

Merged
merged 16 commits into from
Jun 26, 2024

Conversation

chrzaszcz
Copy link
Member

@chrzaszcz chrzaszcz commented Jun 21, 2024

The goal is to replace all the remaining hook-based metrics in mongoose_metrics_hooks with instrumentation.

Most of the reworked metrics are for sent and received XML elements. The naming was confusing, e.g.:

  • xmppIqSent, xmppMessageSent, ... metrics were actually for incoming messages, i.e. received by the server.
  • xmppIqReceived, xmppMessageReceived, ... metrics were actually for outgoing messages, i.e. sent by server. Even in the docs they were described like this:

    [HostType, xmppMessageReceived] | spiral | A message is sent to a client.

  • xmppErrorIq, xmppErrorMessage, ... metrics were only for outgoing errors, while clients can send errors as well.

Moreover, the metrics were not triggered for all incoming/outgoing elements because of the placement of the hooks in mongoose_c2s and additional processing/filtering.

The c2s metrics are now replaced with two events:

  • c2s_element_in - emitted as soon as an XML element is received from a client.
  • c2s_element_out- emitted as soon as an XML element is sent to a client.

Both events contain measurements (counters) for various stanza types. The in/out naming should be also used for s2s and components in the future - this is why there are no names like element_from_client.

There are two more events reworked in this PR:

  • router_stanza_dropped replaces the xmpp_stanza_dropped hook and the xmppStanzaDropped metric.
  • sm_message_bounced replaces the xmpp_bounce_message hook and the xmppMessageBounced metric.

Their placement is a bit arbitrary - there was no need to move message_bounced (it was triggered in one module), while stanza_dropped needed to be placed in a new module, because it was called from two places (mongoose_local_delivery, mod_amp). This is why I added a helper function for the latter. Alternatively, we could have two separate events (e.g. router_stanza_dropped and amp_stanza_dropped), but I decided to keep it simple for now.


System metrics (Analytics) are still using the old stanza event naming, because I didn't want to rename external events to avoid issues with aggregation. We could rework them in a separate story if needed. The translation of event names to metrics was easy.

@chrzaszcz chrzaszcz changed the base branch from master to feature/instrument June 21, 2024 13:14
@mongoose-im

This comment was marked as outdated.

Copy link

codecov bot commented Jun 21, 2024

Codecov Report

Attention: Patch coverage is 96.36364% with 2 lines in your changes missing coverage. Please review.

Project coverage is 84.65%. Comparing base (14280cf) to head (3855cd4).

Files Patch % Lines
src/c2s/mongoose_c2s.erl 95.83% 1 Missing ⚠️
src/mod_amp.erl 75.00% 1 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##           feature/instrument    #4310      +/-   ##
======================================================
+ Coverage               84.64%   84.65%   +0.01%     
======================================================
  Files                     557      556       -1     
  Lines                   33889    33881       -8     
======================================================
- Hits                    28685    28682       -3     
+ Misses                   5204     5199       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers-c2s branch from 7223590 to 27ea344 Compare June 21, 2024 13:26
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers-c2s branch from e31cd35 to 7af893e Compare June 24, 2024 07:20
@mongoose-im

This comment was marked as outdated.

@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers-c2s branch 4 times, most recently from 61b3cea to 56a0b81 Compare June 24, 2024 10:35
@mongoose-im

This comment was marked as outdated.

@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers-c2s branch from 56a0b81 to 8872fa9 Compare June 24, 2024 10:41
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers-c2s branch from 8872fa9 to 0be83c3 Compare June 24, 2024 10:55
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers-c2s branch from 8bc3652 to 209a526 Compare June 25, 2024 06:05
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

- Report incoming elements (received by the server) as soon as they
  arrive, i.e. before any filtering or custom handling.
- Report outgoing elements (sent by the server) when they are sent,
  i.e. after any filtering or custom handling.

This way, the reported events should not miss any elements from the
network traffic.
The system metric names are kept unchanged, because changing them
would make it more difficult to analyse statistics from different
MIM versions.
@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers-c2s branch from 9294f87 to 729c5a3 Compare June 25, 2024 12:21
@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers-c2s branch from 729c5a3 to c54f2b4 Compare June 25, 2024 12:27
@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers-c2s branch from c54f2b4 to 912ab5c Compare June 25, 2024 12:29
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Jun 25, 2024

elasticsearch_and_cassandra_26 / elasticsearch_and_cassandra_mnesia / 912ab5c
Reports root/ big
OK: 457 / Failed: 0 / User-skipped: 41 / Auto-skipped: 0


small_tests_25 / small_tests / 912ab5c
Reports root / small


small_tests_26_arm64 / small_tests / 912ab5c
Reports root / small


small_tests_26 / small_tests / 912ab5c
Reports root / small


ldap_mnesia_25 / ldap_mnesia / 912ab5c
Reports root/ big
OK: 2285 / Failed: 0 / User-skipped: 906 / Auto-skipped: 0


dynamic_domains_mysql_redis_26 / mysql_redis / 912ab5c
Reports root/ big
OK: 4583 / Failed: 0 / User-skipped: 139 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 912ab5c
Reports root/ big
OK: 4616 / Failed: 0 / User-skipped: 106 / Auto-skipped: 0


internal_mnesia_26 / internal_mnesia / 912ab5c
Reports root/ big
OK: 2425 / Failed: 0 / User-skipped: 766 / Auto-skipped: 0


ldap_mnesia_26 / ldap_mnesia / 912ab5c
Reports root/ big
OK: 2285 / Failed: 0 / User-skipped: 906 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_26 / pgsql_mnesia / 912ab5c
Reports root/ big
OK: 4616 / Failed: 0 / User-skipped: 106 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_26 / odbc_mssql_mnesia / 912ab5c
Reports root/ big
OK: 4613 / Failed: 0 / User-skipped: 109 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 912ab5c
Reports root/ big
OK: 5008 / Failed: 0 / User-skipped: 113 / Auto-skipped: 0


pgsql_cets_26 / pgsql_cets / 912ab5c
Reports root/ big
OK: 4515 / Failed: 0 / User-skipped: 174 / Auto-skipped: 0


mysql_redis_26 / mysql_redis / 912ab5c
Reports root/ big
OK: 4987 / Failed: 0 / User-skipped: 134 / Auto-skipped: 0


pgsql_mnesia_26 / pgsql_mnesia / 912ab5c
Reports root/ big
OK: 5008 / Failed: 0 / User-skipped: 113 / Auto-skipped: 0


mssql_mnesia_26 / odbc_mssql_mnesia / 912ab5c
Reports root/ big
OK: 5005 / Failed: 0 / User-skipped: 116 / Auto-skipped: 0

@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers-c2s branch from 912ab5c to 3855cd4 Compare June 25, 2024 13:23
@mongoose-im
Copy link
Collaborator

mongoose-im commented Jun 25, 2024

elasticsearch_and_cassandra_26 / elasticsearch_and_cassandra_mnesia / 3855cd4
Reports root/ big
OK: 457 / Failed: 0 / User-skipped: 41 / Auto-skipped: 0


small_tests_25 / small_tests / 3855cd4
Reports root / small


small_tests_26 / small_tests / 3855cd4
Reports root / small


small_tests_26_arm64 / small_tests / 3855cd4
Reports root / small


ldap_mnesia_25 / ldap_mnesia / 3855cd4
Reports root/ big
OK: 2285 / Failed: 0 / User-skipped: 906 / Auto-skipped: 0


ldap_mnesia_26 / ldap_mnesia / 3855cd4
Reports root/ big
OK: 2285 / Failed: 0 / User-skipped: 906 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 3855cd4
Reports root/ big
OK: 4616 / Failed: 0 / User-skipped: 106 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_26 / pgsql_mnesia / 3855cd4
Reports root/ big
OK: 4616 / Failed: 0 / User-skipped: 106 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_26 / odbc_mssql_mnesia / 3855cd4
Reports root/ big
OK: 4613 / Failed: 0 / User-skipped: 109 / Auto-skipped: 0


internal_mnesia_26 / internal_mnesia / 3855cd4
Reports root/ big
OK: 2425 / Failed: 0 / User-skipped: 766 / Auto-skipped: 0


dynamic_domains_mysql_redis_26 / mysql_redis / 3855cd4
Reports root/ big
OK: 4583 / Failed: 0 / User-skipped: 139 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 3855cd4
Reports root/ big
OK: 5008 / Failed: 0 / User-skipped: 113 / Auto-skipped: 0


pgsql_cets_26 / pgsql_cets / 3855cd4
Reports root/ big
OK: 4515 / Failed: 0 / User-skipped: 174 / Auto-skipped: 0


mysql_redis_26 / mysql_redis / 3855cd4
Reports root/ big
OK: 4987 / Failed: 0 / User-skipped: 134 / Auto-skipped: 0


pgsql_mnesia_26 / pgsql_mnesia / 3855cd4
Reports root/ big
OK: 5008 / Failed: 0 / User-skipped: 113 / Auto-skipped: 0


mssql_mnesia_26 / odbc_mssql_mnesia / 3855cd4
Reports root/ big
OK: 5005 / Failed: 0 / User-skipped: 116 / Auto-skipped: 0


small_tests_26 / small_tests / 3855cd4
Reports root / small

@chrzaszcz chrzaszcz marked this pull request as ready for review June 25, 2024 14:16
Copy link
Contributor

@gustawlippa gustawlippa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR - it is very thorough. I've only left one small comment. Apart from that all of my concerns have been addressed in the description, so I feel like I don't have anything to add 👍

@@ -35,10 +35,12 @@ host_types() ->
%%--------------------------------------------------------------------

init_per_suite(Config) ->
instrument_helper:start([{router_stanza_dropped, #{host_type => host_type()}}]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but maybe use the declared events helper for consistency with other test suites?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am declaring the event explicitly to avoid the case when adding a new event to the module would cause tests to fail.

@gustawlippa gustawlippa merged commit 7f14efe into feature/instrument Jun 26, 2024
4 checks passed
@gustawlippa gustawlippa deleted the instrument/hook-handlers-c2s branch June 26, 2024 08:44
@jacekwegr jacekwegr added this to the 6.3.0 milestone Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants