Bazaar.Telemetry.Logger (Bazaar v0.3.0)

Copy Markdown View Source

Ready-to-use telemetry logger for Bazaar events.

Logs all Bazaar operations with timing information to help identify performance bottlenecks.

Usage

Add to your application's start/2 function:

def start(_type, _args) do
  Bazaar.Telemetry.Logger.attach()

  children = [
    # ...
  ]

  Supervisor.start_link(children, strategy: :one_for_one)
end

Example Output

[info] [Bazaar] checkout.create completed in 42ms (chk_123, incomplete)
[info] [Bazaar] checkout.update completed in 15ms (chk_123, ready_for_complete)
[info] [Bazaar] order.get completed in 8ms (ord_456, completed)
[info] [Bazaar] webhook.handle completed in 23ms (order.shipped)
[info] [Bazaar] discovery.profile completed in 2ms

Options

You can customize the logger by passing options to attach/1:

Bazaar.Telemetry.Logger.attach(
  level: :debug,           # Log level (default: :info)
  handler_id: "my-logger"  # Custom handler ID (default: "bazaar-telemetry-logger")
)

Detaching

To stop logging, call:

Bazaar.Telemetry.Logger.detach()

Summary

Functions

Attaches telemetry handlers for logging Bazaar events.

Detaches the telemetry handlers.

Functions

attach(opts \\ [])

Attaches telemetry handlers for logging Bazaar events.

Options

  • :level - The log level to use (default: :info)
  • :handler_id - Custom handler ID (default: "bazaar-telemetry-logger")

detach(opts \\ [])

Detaches the telemetry handlers.

Options

  • :handler_id - The handler ID to detach (default: "bazaar-telemetry-logger")