# Exclude certain classes from being instrumented

**URL:** <https://discuss.elastic.co/t/exclude-certain-classes-from-being-instrumented/203027>\
**Category:** APM\
**Tags:** ruby\
**Created:** [October 10, 2019, 12:59pm UTC](https://discuss.elastic.co/t/exclude-certain-classes-from-being-instrumented/203027 "2019-10-10T12:59:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dnorth98](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dnorth98/32/54823_2.png) [@dnorth98](https://discuss.elastic.co/u/dnorth98)\
**Post date:** [October 10, 2019, 12:59pm UTC](https://discuss.elastic.co/t/exclude-certain-classes-from-being-instrumented/203027/1 "2019-10-10T12:59:57Z")

</div>

**Kibana version** : 7.4

**Elasticsearch version** : 7.4

**APM Server version** : 7.4

**APM Agent language and version** : Latest version, Ruby

**Browser version** : N/A

Using the Ruby agent, I know it's possible to exclude certain URL suffixes (ie. /healthcheck) from being reported (which we use with great success!) but in a few services we have we use Sidekiq which is background job processing. There's a bunch of repetative jobs that just send health information to AWS cloudwatch that I'd like to have the agent not instrument but I can't quite see a config option for classes.

In this example, I'd like to have the 2 boxed jobs not collected by the agent. Is this do'able?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/1/8128b84bf65eeb2fb7210eba37e7b0b785be0872.png)

---

<div class="post-metadata">

**Author:** ![mikker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikker/32/22118_2.png) [@mikker](https://discuss.elastic.co/u/mikker)\
**Post date:** [October 10, 2019, 1:26pm UTC](https://discuss.elastic.co/t/exclude-certain-classes-from-being-instrumented/203027/2 "2019-10-10T13:26:00Z")

</div>

Hi @dnorth98!

You can omit the payloads with a _filter_. It's not going to stop the events from being registered but it is going to stop them from being sent to APM Server.

Like so (untested):

```auto
ElasticAPM.add_filter(:omit_cloudwatch_workers) do |payload|
  if payload.dig(:transaction, :name) =~ /CloudWatchWorker/
    return ElasticAPM::Transport::Filters::SKIP # => :skip
  end

  payload
end
```

---

<div class="post-metadata">

**Author:** ![dnorth98](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dnorth98/32/54823_2.png) [@dnorth98](https://discuss.elastic.co/u/dnorth98)\
**Post date:** [October 10, 2019, 1:38pm UTC](https://discuss.elastic.co/t/exclude-certain-classes-from-being-instrumented/203027/3 "2019-10-10T13:38:05Z")

</div>

Brilliant! I love it. I will test this today and see how it goes.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 31, 2019, 9:49am UTC](https://discuss.elastic.co/t/exclude-certain-classes-from-being-instrumented/203027/4 "2019-10-31T09:49:05Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
