<p><ahref="POAAgent.html"><codeclass="inline">POAAgent</code></a> app reads the Collectors configuration from the <codeclass="inline">config.exs</code> file when bootstrap and will create a
<p><codeclass="inline">name</code>, <codeclass="inline">module</code>, <codeclass="inline">frequency</code>, <codeclass="inline">label</code> and <codeclass="inline">args</code> must be defined in the configuration file.</p>
<ul>
<li><codeclass="inline">name</code>: Name for the new created process. Must be unique
</li>
<li><codeclass="inline">module</code>: Module which implements the Collector behaviour
</li>
<li><codeclass="inline">frequency</code>: time in milliseconds after which the function <codeclass="inline">collect/1</code> will be called
</li>
<li><codeclass="inline">label</code>: The data collected will be prefixed with this label. ie <codeclass="inline">{:eth_metrics, "data"}</code>
</li>
<li><codeclass="inline">args</code>: Initial args which will be passed to the <codeclass="inline">init_collector/1</code> function
</li>
</ul>
<p>In order to work properly we have to define in the configuration file also the mapping between the Collector
and the Transfers related with it. A <codeclass="inline">Transfer</code> is a Plugin process which transfers the data to outside the agent node
<li><codeclass="inline">init_collector/1</code>: Called only once when the process starts
</li>
<li><codeclass="inline">collect/1</code>: This function is called periodically after <codeclass="inline">frequency</code> milliseconds. It is responsible
<li><codeclass="inline">metric_type/0</code>: This function must return the metric type in <codeclass="inline">string</code> format (i.e “ethereum_metric”)
<divclass="summary-synopsis"><p>A callback executed when the Collector Plugin starts.
The argument is retrieved from the configuration file when the Collector is defined
It can return <codeclass="inline">{:ok, state}</code>, that <codeclass="inline">state</code> will be keept as in <ahref="https://hexdocs.pm/elixir/GenServer.html"><codeclass="inline">GenServer</code></a> and can be
retrieved in the <codeclass="inline">collect/1</code> function.
There are some cases where we want to send data to the transfer after initialize the
Collector, if that is the case you must return <codeclass="inline">{:transfer, data, state}</code> where the data is the
<divclass="summary-synopsis"><p>This callback must return the metric type in <codeclass="inline">string</code> format. For example, if your collector is gathering metrics about
{:transfer, data :: <ahref="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>(), state :: <ahref="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()} | {:notransfer, state :: <ahref="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()}</pre>
</div>
</div>
<sectionclass="docstring">
<p> In this callback is where the metrics collection logic must be placed.
It must return <codeclass="inline">{:transfer, data, state}</code> where <codeclass="inline">data</code> is the retrieved metrics or
<codeclass="inline">{:notransfer, state}</code> when for some reason we don’t want to send data to the transfer int
that moment</p>
</section>
</div>
<divclass="detail"id="c:init_collector/1">
<divclass="detail-header">
<ahref="#c:init_collector/1"class="detail-link"title="Link to this callback">
{:ok, state :: <ahref="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()} | {:transfer, data :: <ahref="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>(), state :: <ahref="https://hexdocs.pm/elixir/typespecs.html#basic-types">any</a>()}</pre>
</div>
</div>
<sectionclass="docstring">
<p> A callback executed when the Collector Plugin starts.
The argument is retrieved from the configuration file when the Collector is defined
It can return <codeclass="inline">{:ok, state}</code>, that <codeclass="inline">state</code> will be keept as in <ahref="https://hexdocs.pm/elixir/GenServer.html"><codeclass="inline">GenServer</code></a> and can be
retrieved in the <codeclass="inline">collect/1</code> function.
There are some cases where we want to send data to the transfer after initialize the
Collector, if that is the case you must return <codeclass="inline">{:transfer, data, state}</code> where the data is the