This documentation contains work-in-progress information for future Elastic Stack and Cloud releases. Use the version selector to view supported release docs. It also contains some Elastic Cloud serverless information. Check out our serverless docs for more details.
Adding additional context
editAdding additional context
editAdding custom context
editYou can add your own custom, nested JSON-compatible data to the current
transaction using ElasticAPM.set_custom_context(hash)
eg.:
class ThingsController < ApplicationController before_action do ElasticAPM.set_custom_context(company: current_user.company) end # ... end
Adding labels
editLabels are special in that they are indexed in your Elasticsearch database and therefore queryable.
ElasticAPM.set_label(:company_name, 'Acme, Inc.')
Note that .
, *
and "
in keys are converted to _
.
Providing info about the user
editYou can provide ElasticAPM with info about the current user.
class ApplicationController < ActionController::Base before_action do current_user && ElasticAPM.set_user(current_user) end end