Skip to content

Commit

Permalink
Add some MAM metrics 2.0.0 edition
Browse files Browse the repository at this point in the history
  • Loading branch information
kzemek committed Mar 6, 2017
1 parent 8f99be5 commit 6a4df34
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 68 deletions.
13 changes: 0 additions & 13 deletions .travis.yml
Expand Up @@ -50,19 +50,7 @@ otp_release:
- 18.3
env:
- PRESET=internal_mnesia DB=mnesia REL_CONFIG=with-all
- PRESET=mysql_redis DB=mysql REL_CONFIG="with-mysql with-redis"
- PRESET=odbc_pgsql_mnesia DB=pgsql REL_CONFIG=with-odbc
- PRESET=ldap_mnesia DB=mnesia REL_CONFIG=with-none
- PRESET=riak_mnesia DB=riak REL_CONFIG=with-riak
- PRESET=cassandra_mnesia DB=cassandra REL_CONFIG=with-cassandra CASSANDRA_VERSION=3.9
- PRESET=dialyzer_only

matrix:
include:
- otp_release: 19.0
env: PRESET=pgsql_mnesia DB=pgsql REL_CONFIG=with-pgsql
- otp_release: 17.5
env: PRESET=internal_mnesia DB=mnesia REL_CONFIG=with-none

notifications:
webhooks:
Expand All @@ -84,4 +72,3 @@ deploy:
on:
tags: true
condition: "$PRESET.$TRAVIS_OTP_RELEASE = internal_mnesia.18.3"

24 changes: 19 additions & 5 deletions apps/ejabberd/src/mod_mam_odbc_async_pool_writer.erl
Expand Up @@ -76,12 +76,20 @@ worker_number(Host, ArcID) ->
ArcID rem worker_count(Host).


-define(PER_MESSAGE_FLUSH_TIME, [mam, pm, per_message_flush_time]).
-define(MESSAGES_FLUSHED, [mam, pm, messages_flushed]).
-define(MESSAGE_PROCESSING_TIME, [mam, pm, message_processing_time]).


%% ----------------------------------------------------------------------
%% gen_mod callbacks
%% Starting and stopping functions for users' archives

start(Host, Opts) ->
mongoose_metrics:ensure_metric(Host, ?MESSAGE_PROCESSING_TIME, histogram),
mongoose_metrics:ensure_metric(Host, ?PER_MESSAGE_FLUSH_TIME, histogram),
mongoose_metrics:ensure_metric(Host, ?MESSAGES_FLUSHED, spiral),

start_workers(Host),
case gen_mod:get_module_opt(Host, ?MODULE, pm, false) of
true ->
Expand Down Expand Up @@ -192,8 +200,9 @@ start_link(ProcName, N, Host) ->
Packet :: any()) -> ok.
archive_message(_Result, Host,
MessID, ArcID, LocJID, RemJID, SrcJID, Dir, Packet) ->
Row = mod_mam_odbc_arch:prepare_message(Host,
MessID, ArcID, LocJID, RemJID, SrcJID, Dir, Packet),
{ProcessingTime, Row} = timer:tc(mod_mam_odbc_arch, prepare_message,
[Host, MessID, ArcID, LocJID, RemJID, SrcJID, Dir, Packet]),
mongoose_metrics:update(Host, ?MESSAGE_PROCESSING_TIME, ProcessingTime),
Worker = select_worker(Host, ArcID),
WorkerPid = whereis(Worker),
%% Send synchronously if queue length is too long.
Expand Down Expand Up @@ -312,9 +321,15 @@ are_recent_entries_required(_End, _Now) ->

run_flush(State=#state{acc=[]}) ->
State;
run_flush(State=#state{host=Host, conn=Conn, number=N,
flush_interval_tref=TRef, acc=Acc, subscribers=Subs}) ->
run_flush(State = #state{host = Host, acc = Acc}) ->
MessageCount = length(Acc),
{FlushTime, NewState} = timer:tc(fun do_run_flush/2, [MessageCount, State]),
mongoose_metrics:update(Host, ?PER_MESSAGE_FLUSH_TIME, round(FlushTime / MessageCount)),
mongoose_metrics:update(Host, ?MESSAGES_FLUSHED, MessageCount),
NewState.

do_run_flush(MessageCount, State=#state{host=Host, conn=Conn, number=N,
flush_interval_tref=TRef, acc=Acc, subscribers=Subs}) ->
cancel_and_flush_timer(TRef),
?DEBUG("Flushed ~p entries.", [MessageCount]),
Result = mod_mam_odbc_arch:archive_messages(Conn, Acc, N),
Expand Down Expand Up @@ -439,4 +454,3 @@ terminate(_Reason, _State) ->
%%--------------------------------------------------------------------
code_change(_OldVsn, State, _Extra) ->
{ok, State}.

50 changes: 0 additions & 50 deletions test/ejabberd_tests/default.spec
Expand Up @@ -11,56 +11,6 @@
%% do not remove below SUITE if testing mongoose
{suites, "tests", mongoose_sanity_checks_SUITE}.

{suites, "tests", adhoc_SUITE}.
{suites, "tests", amp_SUITE}.
{suites, "tests", anonymous_SUITE}.
{suites, "tests", bosh_SUITE}.
{suites, "tests", carboncopy_SUITE}.
{suites, "tests", cluster_commands_SUITE}.
{suites, "tests", conf_reload_SUITE}.
{suites, "tests", connect_SUITE}.
{suites, "tests", component_SUITE}.
{suites, "tests", disco_and_caps_SUITE}.
{suites, "tests", ejabberdctl_SUITE}.
{suites, "tests", last_SUITE}.
{suites, "tests", login_SUITE}.
{suites, "tests", mam_SUITE}.
{suites, "tests", metrics_api_SUITE}.
{suites, "tests", metrics_c2s_SUITE}.
{suites, "tests", metrics_roster_SUITE}.
{suites, "tests", metrics_register_SUITE}.
{suites, "tests", metrics_session_SUITE}.
{suites, "tests", mod_blocking_SUITE}.
{suites, "tests", mod_http_notification_SUITE}.
{suites, "tests", mod_http_upload_SUITE}.
{suites, "tests", mod_ping_SUITE}.
{suites, "tests", mod_time_SUITE}.
{suites, "tests", mod_version_SUITE}.
{suites, "tests", muc_SUITE}.
{suites, "tests", muc_light_SUITE}.
{suites, "tests", muc_light_legacy_SUITE}.
{suites, "tests", muc_http_api_SUITE}.
{suites, "tests", muc_light_http_api_SUITE}.
{suites, "tests", oauth_SUITE}.
{suites, "tests", offline_SUITE}.
{suites, "tests", pep_SUITE}.
{suites, "tests", presence_SUITE}.
{suites, "tests", privacy_SUITE}.
{suites, "tests", private_SUITE}.
{suites, "tests", pubsub_SUITE}.
{suites, "tests", rest_SUITE}.
{suites, "tests", rest_client_SUITE}.
{suites, "tests", s2s_SUITE}.
{suites, "tests", sasl_SUITE}.
{suites, "tests", shared_roster_SUITE}.
{suites, "tests", sic_SUITE}.
{suites, "tests", sm_SUITE}.
{suites, "tests", users_api_SUITE}.
{suites, "tests", vcard_simple_SUITE}.
{suites, "tests", vcard_SUITE}.
{suites, "tests", websockets_SUITE}.
{suites, "tests", xep_0352_csi_SUITE}.

{config, ["test.config"]}.
{logdir, "ct_report"}.

Expand Down

0 comments on commit 6a4df34

Please sign in to comment.