Jido.BehaviorTree.Telemetry (Jido Behavior Tree v1.0.0)

View Source

Telemetry handler for Jido BehaviorTree events.

This module provides optional telemetry integration for behavior tree execution. When started, it attaches handlers for [:jido, :bt, ...] events and logs execution details.

Usage

Add to your application's supervision tree:

children = [
  {Jido.BehaviorTree.Telemetry, []}
]

Or start manually:

Jido.BehaviorTree.Telemetry.start_link([])

Events

This handler processes the following telemetry events:

Node Events

  • [:jido, :bt, :node, :tick, :start] - Node tick started
  • [:jido, :bt, :node, :tick, :stop] - Node tick completed
  • [:jido, :bt, :node, :tick, :exception] - Node tick raised an exception
  • [:jido, :bt, :node, :halt, :start] - Node halt started
  • [:jido, :bt, :node, :halt, :stop] - Node halt completed
  • [:jido, :bt, :node, :halt, :exception] - Node halt raised an exception

Configuration

Configure log level via application config:

config :jido_behaviortree, :telemetry,
  log_level: :debug  # :debug, :info, :warning, :error, or false to disable

Default log level is :debug.

Metrics

This module defines the following Telemetry.Metrics compatible metrics:

  • jido.bt.node.tick.count - Total node ticks executed
  • jido.bt.node.tick.duration - Duration of node ticks (nanoseconds)
  • jido.bt.node.tick.exception.count - Node tick failures
  • jido.bt.node.halt.count - Total node halts executed
  • jido.bt.node.halt.duration - Duration of node halts (nanoseconds)

Summary

Functions

Returns the child spec for supervision trees.

Returns the list of telemetry events this module handles.

Returns a list of Telemetry.Metrics compatible metric definitions.

Starts the telemetry handler.

Functions

child_spec(init_arg)

Returns the child spec for supervision trees.

events()

@spec events() :: [[atom()]]

Returns the list of telemetry events this module handles.

Useful for attaching your own handlers or for testing.

metrics()

@spec metrics() :: [Telemetry.Metrics.t()]

Returns a list of Telemetry.Metrics compatible metric definitions.

Use this with your metrics reporter (e.g., Telemetry.Metrics.ConsoleReporter):

metrics = Jido.BehaviorTree.Telemetry.metrics()
Telemetry.Metrics.ConsoleReporter.start_link(metrics: metrics)

start_link(opts \\ [])

Starts the telemetry handler.