sentry v6.4.2 Sentry.Context
Provides functionality to store user, tags, extra, and breadcrumbs context when an event is reported. The contexts will be fetched and merged into the event when it is sent.
When calling Sentry.Context, the Process Dictionary is used to store this state. This imposes some limitations. The state will only exist within the current process, and the context will die with the process.
For example, if you add context inside your controller and an error happens in a Task, that context will not be included.
A common use-case is to set context within Plug or Phoenix applications, as each request is its own process, and so any stored context will be included should an error be reported within that request process. Example:
# post_controller.ex
def index(conn, _params) do
Sentry.Context.set_user_context(%{id: conn.assigns.user_id})
posts = Blog.list_posts()
render(conn, "index.html", posts: posts)
end
Link to this section Summary
Link to this section Functions
Link to this function
add_breadcrumb(list)
Link to this function
clear_all()
Link to this function
context_keys()
Link to this function
get_all()
Link to this function
set_extra_context(map)
Link to this function
set_http_context(map)
Link to this function
set_tags_context(map)
Link to this function
set_user_context(map)