Jido.Telemetry.Config (Jido v2.0.0-rc.4)

View Source

Configuration for Jido's telemetry logging system.

This module provides functions to check log levels, interestingness thresholds, and privacy settings for telemetry events.

Configuration

All configuration is read from application environment under :jido, :telemetry:

config :jido, :telemetry,
  log_level: :debug,  # :trace | :debug | :info | :warning | :error
  slow_signal_threshold_ms: 10,
  slow_directive_threshold_ms: 5,
  interesting_signal_types: ["jido.strategy.init", "jido.strategy.complete"],
  log_args: :keys_only  # :keys_only | :full | :none

Log Levels

The telemetry system supports five log levels in order of verbosity:

  • :trace - Very verbose, logs every signal and directive
  • :debug - Logs interesting events and slow operations
  • :info - Logs significant lifecycle events
  • :warning - Logs potential issues
  • :error - Logs only errors

Examples

# Check if trace logging is enabled
if Jido.Telemetry.Config.trace_enabled?() do
  # Log detailed per-signal information
end

# Check if an operation is slow
if duration_ms > Jido.Telemetry.Config.slow_signal_threshold_ms() do
  # Log as interesting even at higher log levels
end

# Check argument logging settings
case Jido.Telemetry.Config.log_args?() do
  :full -> log_full_args(args)
  :keys_only -> log_keys(args)
  :none -> :skip
end

Summary

Functions

Returns true if debug-level logging is enabled.

Returns true if the given signal type is considered "interesting".

Returns the list of signal types that are always considered "interesting".

Returns true if the given log level is enabled based on current configuration.

Returns the action/directive arguments logging mode.

Returns the current log level.

Returns the slow directive threshold in milliseconds.

Returns the slow signal threshold in milliseconds.

Returns true if trace-level logging is enabled.

Functions

debug_enabled?()

@spec debug_enabled?() :: boolean()

Returns true if debug-level logging is enabled.

Examples

iex> Jido.Telemetry.Config.debug_enabled?()
true

interesting_signal_type?(signal_type)

@spec interesting_signal_type?(String.t()) :: boolean()

Returns true if the given signal type is considered "interesting".

Examples

iex> Jido.Telemetry.Config.interesting_signal_type?("jido.strategy.init")
true

iex> Jido.Telemetry.Config.interesting_signal_type?("jido.some.random.signal")
false

interesting_signal_types()

@spec interesting_signal_types() :: [String.t()]

Returns the list of signal types that are always considered "interesting".

These signals are logged at debug level regardless of duration.

Default: ["jido.strategy.init", "jido.strategy.complete"]

Examples

iex> "jido.strategy.init" in Jido.Telemetry.Config.interesting_signal_types()
true

level_enabled?(level)

@spec level_enabled?(:trace | :debug | :info | :warning | :error) :: boolean()

Returns true if the given log level is enabled based on current configuration.

Examples

iex> Jido.Telemetry.Config.level_enabled?(:debug)
true

iex> Jido.Telemetry.Config.level_enabled?(:trace)
false

log_args?()

@spec log_args?() :: :keys_only | :full | :none

Returns the action/directive arguments logging mode.

  • :full - Log complete arguments
  • :keys_only - Log only the keys of arguments (default)
  • :none - Do not log arguments

Default: :keys_only

Examples

iex> Jido.Telemetry.Config.log_args?()
:keys_only

log_level()

@spec log_level() :: :trace | :debug | :info | :warning | :error

Returns the current log level.

Examples

iex> Jido.Telemetry.Config.log_level()
:debug

slow_directive_threshold_ms()

@spec slow_directive_threshold_ms() :: non_neg_integer()

Returns the slow directive threshold in milliseconds.

Directives taking longer than this are considered "interesting" and logged at debug level.

Default: 5ms

Examples

iex> Jido.Telemetry.Config.slow_directive_threshold_ms()
5

slow_signal_threshold_ms()

@spec slow_signal_threshold_ms() :: non_neg_integer()

Returns the slow signal threshold in milliseconds.

Signals taking longer than this are considered "interesting" and logged at debug level.

Default: 10ms

Examples

iex> Jido.Telemetry.Config.slow_signal_threshold_ms()
10

trace_enabled?()

@spec trace_enabled?() :: boolean()

Returns true if trace-level logging is enabled.

Trace level is the most verbose, logging every signal and directive.

Examples

iex> Jido.Telemetry.Config.trace_enabled?()
false