Tlm (tlm v0.1.0)

Copy Markdown

Reports your app's errors to Tlm.

Add the dependency and the DSN, and crashes are reported on their own:

{:tlm, ">= 0.1.0"}

# In the deployed app's environment
TLM_DSN=https://tlm_…@tlm.hullop.com

See Tlm.Config for the other options. Without a DSN, nothing is sent.

To report something yourself, use capture_exception/2 or capture_message/2.

Summary

Functions

Reports an exception you rescued.

Reports something that isn't an exception.

Attaches the current user's id to errors reported from this process (the request, in a web app). An id, not personal data.

Sends a test event right away, and waits for Tlm's answer, to check the setup end to end: the DSN, the network, and that the event shows up in Tlm with this app's environment and release.

Functions

capture_exception(exception, opts \\ [])

Reports an exception you rescued.

try do
  charge!(order)
rescue
  e ->
    Tlm.capture_exception(e, stacktrace: __STACKTRACE__)
    {:error, :payment_failed}
end

Options: :stacktrace, :level, :fingerprint, :tags, :user.

capture_message(message, opts \\ [])

Reports something that isn't an exception.

Tlm.capture_message("Payment gateway slow", level: :warning)

Options: :level (default :error), :fingerprint, :tags, :user.

set_user(id)

Attaches the current user's id to errors reported from this process (the request, in a web app). An id, not personal data.

Tlm.set_user(current_user.id)

test_event(opts \\ [])

Sends a test event right away, and waits for Tlm's answer, to check the setup end to end: the DSN, the network, and that the event shows up in Tlm with this app's environment and release.

Tlm.test_event()
#=> {:ok, "4f1c…"}

In a release, where mix tlm.test isn't available:

bin/my_app rpc 'IO.inspect(Tlm.test_event())'

The event is an info-level Tlm.TestError with a real stacktrace, tagged tlm.test: true.

Returns {:ok, uuid} when Tlm accepted it, or {:error, reason}: :no_dsn, :invalid_dsn, {:http, status, body} for any other answer, or the exception when Tlm couldn't be reached.