Skip to content

Commit

Permalink
[docs] Add example for payload filtering
Browse files Browse the repository at this point in the history
Added an example using a callback for filtering to showcase how to use a filter to ignore some payloads completely.

docs
  • Loading branch information
ammaar8 committed Mar 15, 2024
1 parent cb57272 commit d76dfae
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion docs/api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,9 @@ Return the altered payload.

If `nil` is returned all subsequent filters will be skipped and the post request cancelled.

Example:
Examples:

Altering payload
[source,ruby]
----
ElasticAPM.add_filter(:filter_pings) do |payload|
Expand All @@ -421,6 +422,17 @@ ElasticAPM.add_filter(:filter_pings) do |payload|
end
----

Filtering payload
[source,ruby]
----
ElasticAPM.add_filter(
:remove_redis_spans,
Proc.new do |payload|
payload.dig(:span, :type) == 'db.redis' ? nil : payload
end
)
----

[float]
[[api-transaction]]
=== Transaction
Expand Down

0 comments on commit d76dfae

Please sign in to comment.