Collector (collector v0.1.1)

Copy Markdown

Reports your app's errors to Collector.

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

{:collector, ">= 0.1.0"}

# In the deployed app's environment
COLLECTOR_DSN=https://clt_…@app.clt.chrom.ar

See Collector.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.

Functions

capture_exception(exception, opts \\ [])

Reports an exception you rescued.

try do
  charge!(order)
rescue
  e ->
    Collector.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.

Collector.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.

Collector.set_user(current_user.id)