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

Use mongoose_instrument for roster hook metrics #4295

Merged
merged 9 commits into from
Jun 10, 2024

Conversation

chrzaszcz
Copy link
Member

@chrzaszcz chrzaszcz commented Jun 5, 2024

The main goal is to replace the roster-related hook handlers in mongoose_metrics_hooks with instrumentation in the code executing the hooks.

Instrumentation is placed in mod_roster, mod_roster_api and mod_disco to cover the same cases as before. Big tests are added for all the new instrumentation events.

The modRosterGets metric was renamed to mod_roster_get.count. This metric was checked in metrics_api_SUITE, and the issue was, that the REST API for metrics didn't support metrics with multi-part names. As we are going to rename all metrics, we would have to remove the tests, decreasing coverage. As we aren't planning to remove the REST API yet, I decided to add support for multi-part metric names in the REST API. The API was also working only for selected metric types (gauge, counter, spiral), which was the case for the metrics with single-part names, so the tests were succeeding. Now, as we are returning all metrics, I needed to add explicit filtering of metrics by type to make the tests pass.

Notes:

  • Remove test repeat for disco_and_caps_SUITE
  • Replacing metrics with events in metrics_roster_SUITE allowed parallelizing tests.
  • The instrumentation for listing contacts in mod_roster_api fails if mod_roster is not running, but it has to be running for other operations, and it only affects the legacy REST API, so I didn't add extra error handling for this particular operation.
  • Use all_metrics_are_global consistently - on mim2, it should be enabled for instrumentation as well as for metrics.

@chrzaszcz chrzaszcz changed the title Use mongoose_instrument for roster hook metrics Use mongoose_instrument for hook metrics Jun 5, 2024
@mongoose-im

This comment was marked as outdated.

Copy link

codecov bot commented Jun 5, 2024

Codecov Report

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

Project coverage is 84.73%. Comparing base (1991bca) to head (4c8e4b5).

Files Patch % Lines
src/metrics/mongoose_metrics.erl 75.00% 1 Missing ⚠️
.../mongoose_admin_api/mongoose_admin_api_metrics.erl 88.88% 1 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##           feature/instrument    #4295      +/-   ##
======================================================
- Coverage               84.76%   84.73%   -0.04%     
======================================================
  Files                     557      557              
  Lines                   33897    33901       +4     
======================================================
- Hits                    28734    28726       -8     
- Misses                   5163     5175      +12     

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

@mongoose-im

This comment was marked as outdated.

@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers branch from 24fd770 to b8731ed Compare June 7, 2024 15:38
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers branch from 7e01820 to f4a6556 Compare June 10, 2024 07:11
@mongoose-im
Copy link
Collaborator

mongoose-im commented Jun 10, 2024

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


small_tests_25 / small_tests / f4a6556
Reports root / small


small_tests_26 / small_tests / f4a6556
Reports root / small


small_tests_26_arm64 / small_tests / f4a6556
Reports root / small


ldap_mnesia_25 / ldap_mnesia / f4a6556
Reports root/ big
OK: 2290 / Failed: 0 / User-skipped: 905 / Auto-skipped: 0


ldap_mnesia_26 / ldap_mnesia / f4a6556
Reports root/ big
OK: 2290 / Failed: 0 / User-skipped: 905 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / f4a6556
Reports root/ big
OK: 4622 / Failed: 0 / User-skipped: 105 / Auto-skipped: 0


dynamic_domains_mysql_redis_26 / mysql_redis / f4a6556
Reports root/ big
OK: 4589 / Failed: 0 / User-skipped: 138 / Auto-skipped: 0


internal_mnesia_26 / internal_mnesia / f4a6556
Reports root/ big
OK: 2430 / Failed: 0 / User-skipped: 765 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_26 / pgsql_mnesia / f4a6556
Reports root/ big
OK: 4622 / Failed: 0 / User-skipped: 105 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_26 / odbc_mssql_mnesia / f4a6556
Reports root/ big
OK: 4619 / Failed: 0 / User-skipped: 108 / Auto-skipped: 0


pgsql_cets_26 / pgsql_cets / f4a6556
Reports root/ big
OK: 4519 / Failed: 0 / User-skipped: 174 / Auto-skipped: 0


mysql_redis_26 / mysql_redis / f4a6556
Reports root/ big
OK: 4992 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / f4a6556
Reports root/ big
OK: 5012 / Failed: 0 / User-skipped: 112 / Auto-skipped: 1

mam_SUITE:rdbms_muc_all:muc_prefs_cases:muc_prefs_set_request_not_an_owner
{skip,
  {failed,
    {mam_SUITE,init_per_testcase,
      {{badrpc,
         {'EXIT',
           {#{host_type => <<"localhost">>,
            module => mod_mam_rdbms_prefs,
            text => <<"Module missing from mongoose_config">>,
            what => module_not_loaded},
            [{gen_mod,assert_loaded,2,
               [{file,"/home/circleci/project/src/gen_mod.erl"},
              {line,346}]},
             {gen_mod,start_module,3,
               [{file,"/home/circleci/project/src/gen_mod.erl"},
              {line,96}]},
             {mongoose_modules,start_module,4,
               [{file,
                "/home/circleci/project/src/mongoose_modules.erl"},
              {line,90}]},
             {mongoose_modules,ensure_started,3,
               [{file,
                "/home/circleci/project/src/mongoose_modules.erl"},
              {line,80}]},
             {mongoose_modules,'-replace_modules/3-lc$^1/1-1-',2,
               [{file,
                "/home/circleci/project/src/mongoose_modules.erl"},
              {line,50}]},
             {mongoose_modules,replace_modules,3,
               [{file,
                "/home/circleci/project/src/mongoose_modules.erl"},
              {line,51}]}]}}},
       [{distributed_helper,rpc,
          [#{node => mongooseim@localhost},
           mongoose_modules,replace_modules,
           [<<"localhost">>,[],
          #{mod_mam =>
              #{archive_chat_markers => false,
              async_writer =>
                #{ba...

Report log


pgsql_mnesia_26 / pgsql_mnesia / f4a6556
Reports root/ big
OK: 5013 / Failed: 0 / User-skipped: 112 / Auto-skipped: 0


mssql_mnesia_26 / odbc_mssql_mnesia / f4a6556
Reports root/ big
OK: 5010 / Failed: 0 / User-skipped: 115 / Auto-skipped: 0

Instead of adding hook handlers, instrument the hook caller.

- mod_disco and ejabberd_sm don't depend on mod_roster, so they have
  separate instrumentation.
- the call from mod_roster_api could be made from legacy REST API
  without mod_roster running, but it's the same situation as for other
  API calls - which fail in such situation
Legacy metrics are still needed, because sm is still using them.
By replacing metrics with instrumentation in assertions,
tests can be parallelized.
This event is trigered separately in mod_roster_api, hence and
additional test.
The main reason is that all metrics will become multi-segment soon,
and this would mean a significant decrease of test coverage.

Alternatively, we could just drop the support for the legacy metrics
API, but this would be a different task, and we haven't decided yet to
do so.

Details:
- Metric types are explicitly limited to the supported ones. This was
  implicit before, because metrics with one-segment names had simple
  types.
- Simplify prepare_name, because it took an extra argument only for
  logging, which made it more difficult to use with little benefit.
This is possible now, because multi-part names are supported.

An alternative would be to just delete metrics progressively, but that
would leave us with uncovered functionality.
So far, only the legacy metrics had this option enabled, leading to
inconsistency between old and new metrics for mim2.

When we convert all metrics to mongoose_instrument, we can remove the
legacy option.
Also: remove test repeat (we are doing this for all suites)
@chrzaszcz chrzaszcz force-pushed the instrument/hook-handlers branch from f4a6556 to 4c8e4b5 Compare June 10, 2024 07:57
@mongoose-im
Copy link
Collaborator

mongoose-im commented Jun 10, 2024

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


small_tests_25 / small_tests / 4c8e4b5
Reports root / small


small_tests_26 / small_tests / 4c8e4b5
Reports root / small


small_tests_26_arm64 / small_tests / 4c8e4b5
Reports root / small


ldap_mnesia_25 / ldap_mnesia / 4c8e4b5
Reports root/ big
OK: 2290 / Failed: 0 / User-skipped: 905 / Auto-skipped: 0


dynamic_domains_mysql_redis_26 / mysql_redis / 4c8e4b5
Reports root/ big
OK: 4589 / Failed: 0 / User-skipped: 138 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 4c8e4b5
Reports root/ big
OK: 4622 / Failed: 0 / User-skipped: 105 / Auto-skipped: 0


ldap_mnesia_26 / ldap_mnesia / 4c8e4b5
Reports root/ big
OK: 2290 / Failed: 0 / User-skipped: 905 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_26 / pgsql_mnesia / 4c8e4b5
Reports root/ big
OK: 4622 / Failed: 0 / User-skipped: 105 / Auto-skipped: 0


internal_mnesia_26 / internal_mnesia / 4c8e4b5
Reports root/ big
OK: 2430 / Failed: 0 / User-skipped: 765 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_26 / odbc_mssql_mnesia / 4c8e4b5
Reports root/ big
OK: 4619 / Failed: 0 / User-skipped: 108 / Auto-skipped: 0


pgsql_cets_26 / pgsql_cets / 4c8e4b5
Reports root/ big
OK: 4519 / Failed: 0 / User-skipped: 174 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 4c8e4b5
Reports root/ big
OK: 5013 / Failed: 0 / User-skipped: 112 / Auto-skipped: 0


mysql_redis_26 / mysql_redis / 4c8e4b5
Reports root/ big
OK: 4992 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


pgsql_mnesia_26 / pgsql_mnesia / 4c8e4b5
Reports root/ big
OK: 5013 / Failed: 0 / User-skipped: 112 / Auto-skipped: 0


mssql_mnesia_26 / odbc_mssql_mnesia / 4c8e4b5
Reports root/ big
OK: 5010 / Failed: 0 / User-skipped: 115 / Auto-skipped: 0

@chrzaszcz chrzaszcz marked this pull request as ready for review June 10, 2024 12:32
@chrzaszcz chrzaszcz changed the title Use mongoose_instrument for hook metrics Use mongoose_instrument for roster hook metrics Jun 10, 2024
Copy link
Contributor

@arcusfelis arcusfelis left a comment

Choose a reason for hiding this comment

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

Looks good

@arcusfelis arcusfelis merged commit 0646e43 into feature/instrument Jun 10, 2024
4 checks passed
@arcusfelis arcusfelis deleted the instrument/hook-handlers branch June 10, 2024 13:43
@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