Lithic.Telemetry (Lithic v1.0.0)

Copy Markdown View Source

Telemetry integration for the Lithic client.

Events

All events are prefixed with the :telemetry_prefix config value (default [:lithic]).

EventWhenMeasurementsMetadata
[:lithic, :request_start]Before HTTP call%{}%{method, path, client}
[:lithic, :request_stop]After success%{duration: native_time}%{method, path, client, status: :ok}
[:lithic, :request_exception]After failure%{duration: native_time}%{method, path, client, error: %Lithic.Error{}}

Attaching a handler

Lithic.Telemetry.attach_default_logger()

Custom handler

:telemetry.attach(
  "my-lithic-handler",
  [:lithic, :request_stop],
  fn event, measurements, metadata, _config ->
    duration_ms = System.convert_time_unit(measurements.duration, :native, :millisecond)
    Logger.info("Lithic #{inspect(metadata.method)} #{metadata.path} completed in #{duration_ms}ms")
  end,
  nil
)

Summary

Functions

Attach a default structured logger for all Lithic telemetry events.

Returns a specification to start this module under a supervisor.

Returns the list of telemetry events emitted by this library.

Functions

attach_default_logger(opts \\ [])

@spec attach_default_logger(keyword()) :: :ok | {:error, :already_exists}

Attach a default structured logger for all Lithic telemetry events.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

events()

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

Returns the list of telemetry events emitted by this library.