Skip to content

Breadcrumbs

View Markdown

Breadcrumbs are a useful debugging tool that give you the ability to record contextual data as an event called a breadcrumb. When your Project reports an Error (Notice), we send along the breadcrumbs recorded during the execution (request, job, task, etc…).

Context is another way to store extra data to help with debugging. Context is still a great way to attach global data to an error, however, there are scenarios where Breadcrumbs might be a better choice:

  • You want to record metadata that contains duplicate keys
  • You want to group related data
  • You care about when an event happened in relation to an error

Honeybadger.add_breadcrumb/2 appends a breadcrumb to the notice. Use this when you want to add some custom data to your breadcrumb trace in effort to help debugging. If a notice is reported to Honeybadger, all breadcrumbs within the execution path will be appended to the notice. You will be able to view the breadcrumb trace in the Honeybadger interface to see what events led up to the notice.

Honeybadger.add_breadcrumb("Email sent", metadata: %{
user: user.id,
message: message
})

Breadcrumbs are stored per process. If you send messages between processes, breadcrumbs do not transfer automatically. Each breadcrumb uses memory, so be conservative when you add them in systems with many processes.

Honeybadger uses telemetry to create breadcrumbs from these events automatically:

  • Phoenix: A breadcrumb for each router dispatch (Phoenix >= 1.4.7).
  • Ecto: A breadcrumb for each SQL query (ecto_sql >= 3.1.0). List the repos to instrument in your config:
config :honeybadger,
ecto_repos: [MyApp.Repo]

Breadcrumbs are enabled by default. To turn them off:

config :honeybadger,
breadcrumbs_enabled: false