Skip to content

Latest commit

 

History

History
156 lines (98 loc) · 4.44 KB

exometer_proc.md

File metadata and controls

156 lines (98 loc) · 4.44 KB

Module exometer_proc

Utility functions for the exometer_proc probe type.

Description

The exometer_proc probe type is a vanilla Erlang process. All messages must be handled explicitly.

The functions in this module can be used by custom types (see e.g. exometer_spiral). When the exometer_proc type is specified explicitly, the process is started automatically, and the following messages:

      lang="erlang"
  {exometer_proc, {update, Value}}
  {exometer_proc, sample}
  {exometer_proc, reset}
  {exometer_proc, {Pid,Ref}, {get_value, Datapoints}} -> {Ref, Reply}
  {exometer_proc, {Pid,Ref}, {setopts, Opts}} -> {Ref, Reply}
  {exometer_proc, stop}

Function Index

call/2Make a synchronous call to an exometer_proc process.
cast/2Send an asynchronous message to an exometer_proc process.
format_status/2
handle_system_msg/4
process_options/1Apply process_flag-specific options.
spawn_process/2Spawn an exometer_proc process.
spawn_process/3
stop/0Terminate probe process in an orderly way.
system_code_change/4
system_continue/3
system_terminate/4

Function Details

call/2


call(Pid::pid() | atom(), Req::any()) -> any()

Make a synchronous call to an exometer_proc process.

Note that the receiving process must explicitly handle the message in a receive clause and respond properly. The protocol is:

      lang="erlang"
  call(Pid, Req) ->
      MRef = erlang:monitor(process, Pid),
      Pid ! {exometer_proc, {self(), MRef}, Req},
      receive
          {MRef, Reply} -> Reply
      after 5000 -> error(timeout)
      end.

cast/2


cast(Pid::pid() | atom(), Msg::any()) -> ok

Send an asynchronous message to an exometer_proc process.

This function sends a message on the form {exometer_proc, Msg} to the given process.

format_status/2

format_status(Opt, StatusData) -> any()

handle_system_msg/4

handle_system_msg(Req, From, State, Cont) -> any()

process_options/1


process_options(Opts::[{atom(), any()}]) -> ok

Apply process_flag-specific options.

spawn_process/2


spawn_process(Name::exometer:name(), F::fun(() -> no_return())) -> pid()

Spawn an exometer_proc process.

This function sets up appropriate monitoring, and calls the function F which needs to initialize the probe and enter an event loop. (Note: exometer_proc processes are responsible for their own event loop).

spawn_process/3

spawn_process(Name, F, Opts) -> any()

stop/0


stop() -> no_return()

Terminate probe process in an orderly way.

This function doesn't return.

system_code_change/4

system_code_change(IntState, Module, OldVsn, Extra) -> any()

system_continue/3

system_continue(Parent, Debug, IntState) -> any()

system_terminate/4

system_terminate(Reason, Parent, Debug, State) -> any()