ExInsights v0.5.1 ExInsights View Source

Exposes methods for POST events & metrics to Azure Application Insights. For more information on initialization and usage consult the README.md

Link to this section Summary

Types

A map of [name -> number] to add measurement data to a tracking request

Measurement name. Will be used extensively in the app insights UI

A map of [name -> string] to add metadata to a tracking request

Defines the level of severity for the event.

Represents the exception's stack trace.

Link to this section Types

Link to this type

instrumentation_key()

View Source
instrumentation_key() :: String.t() | nil
Link to this type

measurements()

View Source
measurements() :: %{optional(name()) => number()}

A map of [name -> number] to add measurement data to a tracking request

Measurement name. Will be used extensively in the app insights UI

Link to this type

properties()

View Source
properties() :: %{optional(name()) => String.t()}

A map of [name -> string] to add metadata to a tracking request

Link to this type

severity_level()

View Source
severity_level() :: :verbose | :info | :warning | :error | :critical

Defines the level of severity for the event.

Link to this type

stack_trace()

View Source
stack_trace() :: [stack_trace_entry()]

Represents the exception's stack trace.

Link to this type

stack_trace_entry()

View Source
stack_trace_entry() ::
  {module(), atom(), arity_or_args(), location()}
  | {(... -> any()), arity_or_args(), location()}

Link to this section Functions

Link to this function

read_instrumentation_key(key)

View Source
Link to this function

track_dependency(name, command_name, elapsed_time_ms, success, dependency_type_name \\ "", target \\ nil, properties \\ %{}, instrumentation_key \\ nil)

View Source
track_dependency(
  name :: name(),
  String.t(),
  number(),
  boolean(),
  String.t(),
  String.t() | nil,
  properties :: properties(),
  instrumentation_key :: instrumentation_key()
) :: :ok

Log a dependency, for example requests to an external service or SQL calls.

Parameters:

name: String that identifies the dependency.
command_name: String of the name of the command made against the dependency (eg. full URL with querystring or SQL command text).
elapsed_time_ms: Number for elapsed time in milliseconds of the command made against the dependency.
success: Boolean which indicates success.
dependency_type_name: String which denotes dependency type. Defaults to nil.
target: String of the target host of the dependency.
properties (optional): map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
instrumentation_key (optional): Azure application insights API key. If not set it will be read from the configuration (see README.md)
Link to this function

track_event(name, properties \\ %{}, measurements \\ %{}, instrumentation_key \\ nil)

View Source
track_event(
  name :: name(),
  properties :: properties(),
  measurements :: measurements(),
  instrumentation_key :: instrumentation_key()
) :: :ok

Log a user action or other occurrence.

Parameters:

name: name of the event (string)
properties (optional): a map of [string -> string] pairs for adding extra properties to this event
measurements (optional): a map of [string -> number] values associated with this event that can be aggregated/sumed/etc. on the UI
instrumentation_key (optional): Azure application insights API key. If not set it will be read from the configuration (see README.md)
Link to this function

track_exception(exception, stack_trace, handle_at \\ nil, properties \\ %{}, measurements \\ %{}, instrumentation_key \\ nil)

View Source
track_exception(
  String.t(),
  stack_trace :: stack_trace(),
  String.t() | nil,
  properties :: properties(),
  measurements :: measurements(),
  instrumentation_key :: instrumentation_key()
) :: :ok

Log an exception you have caught.

Parameters:

exception: An Error from a catch clause, or the string error message.
stack_trace: An erlang stacktrace.
properties: map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
measurements: map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
instrumentation_key (optional): Azure application insights API key. If not set it will be read from the configuration (see README.md)
Link to this function

track_metric(name, value, properties \\ %{}, instrumentation_key \\ nil)

View Source
track_metric(
  name :: name(),
  number(),
  properties :: properties(),
  instrumentation_key :: instrumentation_key()
) :: :ok

Log a numeric value that is not associated with a specific event.

Typically used to send regular reports of performance indicators.

Parameters:

name: name of the metric
value: the value of the metric (number)
properties (optional): a map of [string -> string] pairs for adding extra properties to this event
instrumentation_key (optional): Azure application insights API key. If not set it will be read from the configuration (see README.md)
Link to this function

track_request(name, url, source, elapsed_time_ms, result_code, success, properties \\ %{}, measurements \\ %{}, instrumentation_key \\ nil)

View Source
track_request(
  name :: name(),
  String.t(),
  String.t() | nil,
  number(),
  String.t() | number(),
  boolean(),
  properties :: properties(),
  measurements :: measurements(),
  instrumentation_key :: instrumentation_key()
) :: :ok

Log a request, for example incoming HTTP requests

Parameters:

name: String that identifies the request
url: Request URL
source: Request Source. Encapsulates info about the component that initiated the request (can be nil)
elapsed_time_ms: Number for elapsed time in milliseconds
result_code: Result code reported by the application
success: whether the request was successfull
properties (optional): map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
measurements (optional): a map of [string -> number] values associated with this event that can be aggregated/sumed/etc. on the UI
instrumentation_key (optional): Azure application insights API key. If not set it will be read from the configuration (see README.md)
Link to this function

track_trace(message, severity_level \\ :info, properties \\ %{}, instrumentation_key \\ nil)

View Source
track_trace(
  String.t(),
  severity_level :: severity_level(),
  properties :: properties(),
  instrumentation_key :: instrumentation_key()
) :: :ok

Log a trace message.

Parameters:

message: A string to identify this event in the portal.
severity_level: The level of severity for the event.
properties: map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
instrumentation_key (optional): Azure application insights API key. If not set it will be read from the configuration (see README.md)