Advanced Topicsedit

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 tagsedit

Tags are special in that they are indexed in your Elasticsearch database and therefore searchable.

ElasticAPM.set_tag(:company_name, 'Acme, Inc.')

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