Adding additional contextedit

Adding custom contextedit

You 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 labelsedit

Labels 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 useredit

You 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