BCUtils.Telemetry (bc_utils v0.14.0)
Telemetry integration for BCUtils modules.
This module provides helper functions to set up telemetry events for monitoring and performance analysis within the BCUtils library.
Usage
Event Setup
:telemetry.attach(
  "my-event-handler",
  [:bc_utils, :module, :function, :start],
  &MyModule.handle_event/4,
  %{some: "metadata"}
)Event Emission
def my_function(arg1, arg2) do
  start_time = System.monotonic_time()
  :telemetry.execute(
    [:bc_utils, :my_module, :my_function, :start],
    %{system_time: System.system_time(), arg1: arg1, arg2: arg2},
    %{start_time: start_time}
  )
  
  # Perform operation...
  
  :telemetry.execute(
    [:bc_utils, :my_module, :my_function, :stop],
    %{duration: System.monotonic_time() - start_time},
    %{arg1: arg1, arg2: arg2}
  )
endBest Practices
- Use descriptive event names
 - Tag events with function/module names
 - Include relevant metadata and measurements
 - Consider performance impact of telemetry hooks
 
Summary
Functions
Attaches a telemetry handler.
Detaches a telemetry handler.
Publishes a start event for telemetry.
Publishes a stop event for telemetry.
Functions
Attaches a telemetry handler.
Parameters
handler_id- Unique identifier for the event handlerevent_name- The name (list) of the telemetry event to handlehandler_fn- The function to call when the event occurshandler_config- Additional handler configuration
Detaches a telemetry handler.
Parameters
handler_id- Unique identifier for the event handler
Publishes a start event for telemetry.
Parameters
name- The name (list) identifying the telemetry eventmetadata- Metadata map for additional context
Publishes a stop event for telemetry.
Parameters
name- The name (list) identifying the telemetry eventmetadata- Metadata map for additional contextstart_time- The start time of the operation for duration calculation