z_stats (zotonic_core v1.0.0-rc.11)

Module for handling request statistics.

Link to this section Summary

Functions

Setup stats for each site.
Initialize the statistics collection machinery.

Collect log data from cowmachine and update cowmachine metrics

Count some amount, like data transfers
Start the log buffer consumer.

Link to this section Functions

Link to this function

handle_call(Cmd, From, State)

Link to this function

handle_cast(Cmd, State)

Link to this function

handle_info(_, State)

Link to this function

init_site(Site)

Setup stats for each site.
Initialize the statistics collection machinery.
Link to this function

log_access(MetricsData)

Collect log data from cowmachine and update cowmachine metrics

The log entry from zotonic_listen_http_metrics is:
  Log = #{
      site => Site,
      reason => Reason,
      req_start => ReqStart,
      duration_total_usec => DurationTotalUsec,
      duration_process_usec => DurationProcessUsec,
      resp_status => RespStatus,
      resp_status_category => StatusCategory,
      req_bytes => ReqBodyLength,
      resp_bytes => RespBodyLength,
      http_version => cowboy_req:version(Req),
      method => cowboy_req:method(Req),
      path => cowboy_req:path(Req),
      user_agent => cowboy_req:header(<<"user-agent">>, Req),
      referer => cowboy_req:header(<<"referer">>, Req),
      metrics => UserData#{ peer_ip => PeerIP }
  }
Link to this function

record_count(System, What, Count, Context)

Count some amount, like data transfers
Link to this function

record_duration(System, What, Duration, Context)

Record a duration
Link to this function

record_event(System, What, Context)

Count a event
Link to this function

start_link(Buffers)

Start the log buffer consumer.
Link to this function

system_usage(_)