<commit_before>-module(aec_metrics).
-behaviour(exometer_report).
-behavior(exometer_report_logger).

-export([update/2,
         try_update/2]).

%% exometer_report_logger callbacks
-export([logger_init_input/1,
         logger_init_output/1,
         logger_handle_data/2]).

%% exometer_report logging callbacks
-export([exometer_init/1,
         exometer_report/5,
         exometer_subscribe/5,
         exometer_unsubscribe/4,
         exometer_info/2,
         exometer_call/3,
         exometer_cast/2,
         exometer_terminate/2,
         exometer_setopts/4,
         exometer_newentry/2]).

%% start phase API
-export([create_metrics_probes/0]).
-export([start_reporters/0]).

-include_lib("kernel/include/inet.hrl").
-define(DEFAULT_PORT, 8125).  % default (dog-)statsd port
-define(DEFAULT_RECONNECT_INTERVAL, 10000).


-record(st, {type_map = [] :: list(),
             prefix = []   :: string()}).

-record(statsd, {
          socket        :: inet:socket() | undefined,
          tref          :: reference() | undefined,
          addr_type     :: 'inet' | 'inet6',
          address       :: inet:ip_address(),
          port          :: inet:port_number(),
          reconnect_interval = ?DEFAULT_RECONNECT_INTERVAL :: pos_integer()
         }).

%% Hard-coded default
default_dests() ->
    [log, send].

%%===================================================================
%% Metrics API
%%===================================================================

update(Metric, Value) ->
    exometer:update(Metric, Value).

-spec try_update([atom(), ...], number()) -> ok | {error, not_found}.
try_update(Metric, Value) ->
    try update(Metric, Value)
    catch
        error:_ ->
            ok
    end.

%%===================================================================
%% PROBE INITIALIZATION
%%===================================================================

create_metrics_probes() ->
    Probes = aeu_env:get_env(aecore, metrics_probes, []),<commit_msg>Reuse exometer type for metric name<commit_after>-module(aec_metrics).
-behaviour(exometer_report).
-behavior(exometer_report_logger).

-export([update/2,
         try_update/2]).

%% exometer_report_logger callbacks
-export([logger_init_input/1,
         logger_init_output/1,
         logger_handle_data/2]).

%% exometer_report logging callbacks
-export([exometer_init/1,
         exometer_report/5,
         exometer_subscribe/5,
         exometer_unsubscribe/4,
         exometer_info/2,
         exometer_call/3,
         exometer_cast/2,
         exometer_terminate/2,
         exometer_setopts/4,
         exometer_newentry/2]).

%% start phase API
-export([create_metrics_probes/0]).
-export([start_reporters/0]).

-include_lib("kernel/include/inet.hrl").
-define(DEFAULT_PORT, 8125).  % default (dog-)statsd port
-define(DEFAULT_RECONNECT_INTERVAL, 10000).


-record(st, {type_map = [] :: list(),
             prefix = []   :: string()}).

-record(statsd, {
          socket        :: inet:socket() | undefined,
          tref          :: reference() | undefined,
          addr_type     :: 'inet' | 'inet6',
          address       :: inet:ip_address(),
          port          :: inet:port_number(),
          reconnect_interval = ?DEFAULT_RECONNECT_INTERVAL :: pos_integer()
         }).

%% Hard-coded default
default_dests() ->
    [log, send].

%%===================================================================
%% Metrics API
%%===================================================================

update(Metric, Value) ->
    exometer:update(Metric, Value).

-spec try_update(exometer:name(), number()) -> ok | {error, not_found}.
try_update(Metric, Value) ->
    try update(Metric, Value)
    catch
        error:_ ->
            ok
    end.

%%===================================================================
%% PROBE INITIALIZATION
%%===================================================================

create_metrics_probes() ->
    Probes = aeu_env:get_env(aecore, metrics_probes, []),
{'fraction_non_alphanumeric': 0.2576211894052973, 'fraction_numerical': 0.013493253373313344, 'mean_word_length': 3.1960167714884697, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '101612', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1150, 'n_words': 185}