diff --git a/README.md b/README.md index f467e0f..ce3d533 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Copyright (c) 2014 Basho Technologies, Inc. All Rights Reserved. -__Version:__ Mar 5 2014 11:56:38 +__Version:__ Mar 19 2014 23:14:26 __Authors:__ Ulf Wiger ([`ulf.wiger@feuerlabs.com`](mailto:ulf.wiger@feuerlabs.com)), Magnus Feuer ([`magnus.feuer@feuerlabs.com`](mailto:magnus.feuer@feuerlabs.com)). @@ -659,8 +659,8 @@ Below is an example, from `exometer/priv/app.config`: ```erlang {exometer, [ - {report, [ - {subscribers, [ + {report, [ + {subscribers, [ {exometer_report_collectd, [db, cache, hits], mean, 2000, true}, {exometer_report_collectd, [db, cache, hits], max, 5000, false} ]} @@ -674,36 +674,53 @@ how to configure individual plugins. The `subscribers` sub-section contains all static subscriptions to be setup att exometer applications start. Each tuple in the prop list -contains five elements: +should be of one of the following formats: + +`{Reporter, Metric, DataPoint, Interval}` +`{Reporter, Metric, DataPoint, Interval, RetryFailedMetrics}` +`{Reporter, Metric, DataPoint, Interval, RetryFailedMetrics, Extra}` +`{apply, {M, F, A}}` + +In the case of `{apply, M, F, A}`, the result of `apply(M, F, A)` must +be a list of `subscribers` tuples. + +The meaning of the above tuple elements is: -+ `receiver` (module name atom) ++ `Reporter :: module()`

Specifies the reporter plugin module, such as`exometer_report_collectd` that is to receive updated metric's data points. -+ `name` (list of atoms) ++ `Metric :: [atoms()]`

Specifies the path to a metric previously created with an`exometer:new()` call. -+ `datapoint` (atom) ++ `DataPoint` :: atom() | [atom()]'

Specifies the data point within the given metric to send to the receiver. The data point must match one of the data points returned by`exometer:info(Name, datapoints)` for the given metrics name. -+ `interval` (milliseconds) ++ `Interval` :: integer()' (milliseconds)

Specifies the interval, in milliseconds, between each update of the given metric's data point. At the given interval, the data point will be samples, and the result will be sent to the receiver. -+ `retry_failed_metrics (true | false)` ++ `RetryFailedMetrics :: boolean()`

Specifies if the metric should be continued to be reported -even if it is not found during a reporting cycle. This would be -the case if a metric is not created by the time it is reported for -the first time. If the metric will be created at a later time, -this value should be set to true. Set this value to false if all -attempts to report the metric should stop if when is not found. + even if it is not found during a reporting cycle. This would be + the case if a metric is not created by the time it is reported for + the first time. If the metric will be created at a later time, + this value should be set to true. Set this value to false if all + attempts to report the metric should stop if when is not found. + The default value is `true`. + ++ `Extra :: any()` +

+Provides a means to pass along extra information for a given + subscription. An example is the `syntax` option for the SNMP reporter, + in which case `Extra` needs to be a property list. #### Configuring reporter plugins #### diff --git a/doc/edoc-info b/doc/edoc-info index bec5bc4..620e5b8 100644 --- a/doc/edoc-info +++ b/doc/edoc-info @@ -1,4 +1,3 @@ -%% encoding: UTF-8 {application,exometer}. {packages,[]}. {modules,[exometer,exometer_admin,exometer_cache,exometer_cpu, diff --git a/doc/exometer_function.md b/doc/exometer_function.md index 5e20909..5930956 100644 --- a/doc/exometer_function.md +++ b/doc/exometer_function.md @@ -148,7 +148,7 @@ simple_fun() = {function, mod_name(), behaviour/0delete/3empty/0get_datapoints/3get_value/4new/3Callback for creating an exometer function entry.reset/3sample/3setopts/4test_mem_info/1update/4 +
behaviour/0
delete/3
empty/0
get_datapoints/3
get_value/4
new/3Callback for creating an exometer function entry.
preprocess_setopts/5
reset/3
sample/3
setopts/4
test_mem_info/1
update/4
@@ -193,7 +193,7 @@ behaviour() -> atom() ### get_value/4 ### -`get_value(X1, X2, X3, DataPoints) -> any()` +`get_value(X1, X2, X3, DataPoints0) -> any()` @@ -338,6 +338,13 @@ An entry that does pattern-matching on the return value match, {gcs,reclaimed,'_'} }, []). ``` + + +### preprocess_setopts/5 ### + +`preprocess_setopts(Name, Opts, Type, Ref, OldOpts) -> any()` + + ### reset/3 ### diff --git a/doc/exometer_report.md b/doc/exometer_report.md index f64c5be..35486cd 100644 --- a/doc/exometer_report.md +++ b/doc/exometer_report.md @@ -282,6 +282,8 @@ extra() = any() + Restart specification + ### interval() ### @@ -310,7 +312,7 @@ metric() = [atom(), ...] ## Function Index ## -
add_reporter/2
call_reporter/2
cast_reporter/2
list_metrics/0
list_metrics/1
list_reporters/0
list_subscriptions/1
new_entry/1
remove_reporter/1
setopts/3
start_link/0Starts the server +
add_reporter/2
call_reporter/2
cast_reporter/2
list_metrics/0
list_metrics/1
list_reporters/0
list_subscriptions/1
new_entry/1
remove_reporter/1
remove_reporter/2
setopts/3
start_link/0Starts the server --------------------------------------------------------------------.
subscribe/4Equivalent to subscribe(Reporter, Metric, DataPoint, Interval, []).
subscribe/5Add a subscription to an existing reporter.
terminate_reporter/1
unsubscribe/3Equivalent to unsubscribe(Reporter, Metric, DataPoint, []).
unsubscribe/4Removes a subscription.
unsubscribe_all/2Removes all subscriptions related to Metric in Reporter.
@@ -405,6 +407,13 @@ list_subscriptions(Reporter::module()) -> [{metric() any()` + + +### remove_reporter/2 ### + +`remove_reporter(Reporter, Reason) -> any()` + + ### setopts/3 ### diff --git a/doc/exometer_report_snmp.md b/doc/exometer_report_snmp.md index a1ee7cf..67b295e 100644 --- a/doc/exometer_report_snmp.md +++ b/doc/exometer_report_snmp.md @@ -100,7 +100,7 @@ Callback function used by the SNMP master agent upon operations performed by a m ### exometer_setopts/4 ### -`exometer_setopts(Metric, Options, X3, St0) -> any()` +`exometer_setopts(Exometer_entry, Options, X3, St0) -> any()` diff --git a/doc/overview.edoc b/doc/overview.edoc index 604733d..fa79c36 100644 --- a/doc/overview.edoc +++ b/doc/overview.edoc @@ -571,8 +571,8 @@ Below is an example, from `exometer/priv/app.config':
 {exometer, [
-    {report, [ 
-        {subscribers, [ 
+    {report, [
+        {subscribers, [
             {exometer_report_collectd, [db, cache, hits], mean, 2000, true},
             {exometer_report_collectd, [db, cache, hits], max, 5000, false}
         ]}
@@ -585,35 +585,50 @@ how to configure individual plugins.
 
 The `subscribers' sub-section contains all static subscriptions to be
 setup att exometer applications start. Each tuple in the prop list
-contains five elements:
+should be of one of the following formats:
+
+`{Reporter, Metric, DataPoint, Interval}'
+`{Reporter, Metric, DataPoint, Interval, RetryFailedMetrics}'
+`{Reporter, Metric, DataPoint, Interval, RetryFailedMetrics, Extra}'
+`{apply, {M, F, A}}'
+
+In the case of `{apply, M, F, A}', the result of `apply(M, F, A)' must
+be a list of `subscribers' tuples.
+
+The meaning of the above tuple elements is:
 
-+ `receiver' (module name atom)
++ `Reporter :: module()'
     
Specifies the reporter plugin module, such as `exometer_report_collectd' that is to receive updated metric's data points. -+ `name' (list of atoms) ++ `Metric :: [atoms()]'
Specifies the path to a metric previously created with an `exometer:new()' call. -+ `datapoint' (atom) ++ `DataPoint' :: atom() | [atom()]'
Specifies the data point within the given metric to send to the receiver. The data point must match one of the data points returned by `exometer:info(Name, datapoints)' for the given metrics name. -+ `interval' (milliseconds) ++ `Interval' :: integer()' (milliseconds)
Specifies the interval, in milliseconds, between each update of the given metric's data point. At the given interval, the data point will be samples, and the result will be sent to the receiver. -+ `retry_failed_metrics (true | false)' ++ `RetryFailedMetrics :: boolean()'
Specifies if the metric should be continued to be reported even if it is not found during a reporting cycle. This would be the case if a metric is not created by the time it is reported for the first time. If the metric will be created at a later time, this value should be set to true. Set this value to false if all attempts to report the metric should stop if when is not found. + The default value is `true'. ++ `Extra :: any()' +
Provides a means to pass along extra information for a given + subscription. An example is the `syntax' option for the SNMP reporter, + in which case `Extra' needs to be a property list. === Configuring reporter plugins === diff --git a/src/exometer_report.erl b/src/exometer_report.erl index 8c8fa2c..99910f6 100644 --- a/src/exometer_report.erl +++ b/src/exometer_report.erl @@ -918,6 +918,10 @@ init_subscriber({Reporter, Metric, DataPoint, Interval, RetryFailedMetrics, Extr init_subscriber({Reporter, Metric, DataPoint, Interval}, Acc) -> [subscribe_(Reporter, Metric, DataPoint, Interval, true, undefined) | Acc]; + +init_subscriber({apply, {M, F, A}}, Acc) -> + lists:foldr(fun init_subscriber/2, Acc, apply(M, F, A)); + init_subscriber(Other, Acc) -> ?warning("Incorrect static subscriber spec ~p. " "Use { Reporter, Metric, DataPoint, Interval [, Extra ]}~n", [ Other ]),