Hog (Hog v0.1.0)

View Source

This process will routinely scans all of the running processes and emit a telemetry event any time a process surpasses a certain memory threshold. The memory threshold along with how often Hog scans all of your running processes is configurable. Once a memory hungry process is found, a telemetry event is emitted. You can hook into this telemetry event your self to deal with the misbehaving process, or you can use the provided Hog.Logger module log process information. Below is a listing of all of the configuration options available to you.

Supported options:

  • :scan_interval (tuple of pos_integer/0, values) - The interval for how often the running processes are scanned. The default value is {1, :minutes}.

  • :memory_threshold (tuple of pos_integer/0, values) - The memory threshold that determines whether a telemetry event is emitted. The default value is {100, :megabytes}.

  • :max_report_frequency (tuple of pos_integer/0, values) - As not to create too many telemetry events about the same process over and over again, you can specify how often a particular process has a telemetry event emitted for it. The check for the process is based on the PID. So if the process crashes and is restarted, it will be reported again since it is running under a new PID. The default value is {1, :minutes}.

  • :event_handler - The handler function that is called when a process surpasses the configured memory_threshold The default value is &Hog.Logger.default_logger/2.

  • :additional_pid_info_fields (list of atom/0) - The process info fields that are collected on the running process before emitting the telemetry event that memory usage has exceed configure threshold. The fields that are captured by default are: [:memory, :reductions, :message_queue_len, :current_stacktrace, :registered_name]. Any additional fields provided will be included in the telemetry event metadata. The default value is [].

Coming soon:

  • ETS table scanning

Summary

Functions

Returns a specification to start this module under a supervisor.

Types

option()

@type option() ::
  {:scan_interval, {pos_integer(), term()}}
  | {:memory_threshold, {pos_integer(), term()}}
  | {:max_report_frequency, {pos_integer(), term()}}
  | {:event_handler, nil | (term(), term() -> term())}
  | {:additional_pid_info_fields, [atom()]}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)