Axn.Telemetry (Axn v0.2.0)
View SourceTelemetry integration for Axn actions.
This module handles automatic telemetry event emission for action execution, including custom metadata collection and safe error handling.
Summary
Functions
Builds telemetry metadata by merging default, module-level, and action-level metadata.
Extracts metadata from options.
Wraps step execution with telemetry events.
Functions
Builds telemetry metadata by merging default, module-level, and action-level metadata.
Metadata precedence (later metadata overwrites earlier on key conflicts):
- Default metadata:
%{module: ctx.module, action: ctx.action} - Module-level metadata: Configured via
use Axn, metadata: &function/1 - Action-level metadata: Configured via
action :name, metadata: &function/1
All custom metadata functions are called safely and return %{} on error.
Parameters
ctx- Context struct containing action informationaction_opts- Action-level options (may include:metadatafunction)module_opts- Module-level options (may include:metadatafunction)
Return Value
Returns a map of telemetry metadata.
Extracts metadata from options.
Looks for the :metadata key in options and safely calls the function
if present. Returns empty map if no metadata function or on error.
Wraps step execution with telemetry events.
Emits :telemetry.span/3 events with the following structure:
- Event name:
[:axn, :action] - Start metadata: Default + module + action metadata
- Stop metadata: Same as start, plus any context changes during execution
- Exception metadata: Same as start, plus exception details
Custom metadata functions are called safely and default to %{} on error.
Parameters
ctx- Initial Context structaction_opts- Action-level options (may include:metadatafunction)module_opts- Module-level options (may include:metadatafunction)runner- The function to run the action
Return Value
Returns a Context struct with the final execution state and result.