Sha256: 6fca8defe765316f1cf42a8fac621b0ff9d8d343e2cd59571efe44d20c701073

Contents?: true

Size: 919 Bytes

Versions: 2

Compression:

Stored size: 919 Bytes

Contents

[float]
[[context]]
=== Adding additional context

[float]
==== Adding custom context

You can add your own custom, nested JSON-compatible data to the current
transaction using `ElasticAPM.set_custom_context(hash)` eg.:

[source,ruby]
----
class ThingsController < ApplicationController
  before_action do
    ElasticAPM.set_custom_context(company: current_user.company)
  end

  # ...
end
----

[float]
==== Adding tags

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

[source,ruby]
----
ElasticAPM.set_tag(:company_name, 'Acme, Inc.')
----

Note that `.`, `*` and `"` in keys are converted to `_`.

[float]
==== Providing info about the user

You can provide ElasticAPM with info about the current user.

[source,ruby]
----
class ApplicationController < ActionController::Base
  before_action do
    current_user && ElasticAPM.set_user(current_user)
  end
end
----

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
elastic-apm-2.0.1 docs/context.asciidoc
elastic-apm-2.0.0 docs/context.asciidoc