Closed pouriya closed 2 days ago
I will fix dialyzer etc after review.
I'm going to change subscriber API and leave run
and run_fold
untouched.
I think you could even not need any changes in ejabberd_hooks, you will need to add two hooks with low and high priority, to get notified at start and of hook, ejabberd_hooks:add/remove accept closures, so you could generate required function on demand. Your function can return 'EXIT' atom to make output from it be ignored. Only issue will be arrity of those function, as you will not receive hook arguments as list, but as multiple arguments in those functions.
you will need to add two hooks with low and high priority, to get notified at start and of hook.
@prefiks Yes. But what if we disable the module (M:F
) we're monitoring? There is no way to know that ejabberd_hooks
called or did not call specific module M:F
. With these changes, If a hook has subscriber(s) they will know exactly what M:F
ejabberd_hooks
runs.
I force pushed changes and left original run
and run_fold
untouched.
We could also have a configuration parameter to set module parameters as labels. for example:
modules:
# ...
mod_prometheus:
hooks:
# Histogram for a hook:
- hook: user_send_packet
type: histogram
help: "Handling of sent messages duration in millisecond"
collect: modules # HERE
Output:
...
user_send_packet_duration_milliseconds_bucket{module="mod_mam",le="10"} 43
user_send_packet_duration_milliseconds_bucket{module="mod_carboncopy",le="10"} 43
user_send_packet_duration_milliseconds_bucket{module="mod_foo",le="10"} 43
user_send_packet_duration_milliseconds_bucket{module="mod_bar",le="10"} 43
...
Any idea?
Seems like don't have Dialyzer issue anymore :-)
@pouriya: Nice PR, good job with ejabberd team!
I think this should be added to ejabberd-contribs repository: https://github.com/processone/ejabberd-contrib
@mremond
I think this should be added to ejabberd-contribs
Yes :) I have almost ready the fixes in ejabberd that will allow this:
I'll complete testing tomorrow and show how to accomplish it.
@badlop @mremond So we're ready to merge hook subscriber commit here. Am I right?
So we're ready to merge hook subscriber commit here. Am I right?
Mostly yes :) Do you still have some improvement or fix planned for ejabberd_hooks.erl ?
@badlop I don't think so... I'll see what can be done before force push. on it.
@badlop force pushed just ejabberd_hooks changes. When we're ready to accept Prometheus in ejabberd-contrib?
I've merged this PR with the "hooks subscription" feature.
And I've added a new directory in ejabberd-contrib with everything prepared for your mod_prometheus: https://github.com/processone/ejabberd-contrib/tree/master/mod_prometheus
Now you can create a directory src/
there, copy your *.erl files, fix anything you want in the documentation, example files... and submit a PR
@badlop Thanks!
Example config
Output example (After sending some messages)
Prometheus screenshot