Module z_stats

Module for handling request statistics.

Copyright © 2013-2021 Maas-Maarten Zeeman

Behaviours: gen_server.

Authors: Maas-Maarten Zeeman (mmzeeman@xs4all.nl).

Description

Module for handling request statistics.

Function Index

handle_call/3
handle_cast/2
handle_info/2
init/1
init_site/1Setup stats for each site.
init_system/0Initialize the statistics collection machinery.
log_access/1Collect log data from cowmachine and update cowmachine metrics.
record_count/4Count some amount, like data transfers.
record_duration/4Record a duration.
record_event/3Count a event.
start_link/1Start the log buffer consumer.
system_usage/1

Function Details

handle_call/3

handle_call(Cmd, From, State) -> any()

handle_cast/2

handle_cast(Cmd, State) -> any()

handle_info/2

handle_info(X1, State) -> any()

init/1

init(Buffers) -> any()

init_site/1

init_site(Site) -> any()

Setup stats for each site.

init_system/0

init_system() -> any()

Initialize the statistics collection machinery.

log_access/1

log_access(MetricsData) -> any()

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 }
  }

record_count/4

record_count(System, What, Count, Context) -> any()

Count some amount, like data transfers

record_duration/4

record_duration(System, What, Duration, Context) -> any()

Record a duration

record_event/3

record_event(System, What, Context) -> any()

Count a event

start_link/1

start_link(Buffers) -> any()

Start the log buffer consumer.

system_usage/1

system_usage(X1) -> any()


Generated by EDoc