# \[APM Java agent\] Ignore Exception

**URL:** <https://discuss.elastic.co/t/apm-java-agent-ignore-exception/193005>\
**Category:** APM\
**Tags:** java\
**Created:** [July 30, 2019, 11:49pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-exception/193005 "2019-07-30T23:49:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hong\_Phuoc\_Cao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hong_phuoc_cao/32/51288_2.png) [@Hong\_Phuoc\_Cao](https://discuss.elastic.co/u/Hong_Phuoc_Cao)\
**Post date:** [July 30, 2019, 11:49pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-exception/193005/1 "2019-07-30T23:49:17Z")

</div>

Hi Elastic team,

Is there any way to ignore Exception catched in try catch block or ignore specific Exception ?

The latest apm (1.8.0) is collecting so many knowns errors, but I dont care about those exceptions.

Thanks,  
Phuoc

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [July 31, 2019, 1:48pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-exception/193005/2 "2019-07-31T13:48:15Z")

</div>

Hi 🙂

currently, there is no such option.

How would you want to filter those? Based on the exception class or also the message?

> [@Hong\_Phuoc\_Cao](#):
>
> The latest apm (1.8.0) is collecting so many knowns errors, but I dont care about those exceptions.

Is there a change in behavior from previous versions?

---

<div class="post-metadata">

**Author:** ![Hong\_Phuoc\_Cao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hong_phuoc_cao/32/51288_2.png) [@Hong\_Phuoc\_Cao](https://discuss.elastic.co/u/Hong_Phuoc_Cao)\
**Post date:** [July 31, 2019, 5:59pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-exception/193005/3 "2019-07-31T17:59:20Z")

</div>

Hi Felix,

Nothing changed from previous versions.

I think based on exception class is better.

And I got alot exceptions (Exception class) catched by try catch block from 3rd party, the index  
**apm-error** grows so big because of those exceptions. Its very good if you can ignore them.

Regards,

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [July 31, 2019, 6:38pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-exception/193005/4 "2019-07-31T18:38:51Z")

</div>

Which 3rd party project are you talking about? How does that create an apm error?

---

<div class="post-metadata">

**Author:** ![Hong\_Phuoc\_Cao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hong_phuoc_cao/32/51288_2.png) [@Hong\_Phuoc\_Cao](https://discuss.elastic.co/u/Hong_Phuoc_Cao)\
**Post date:** [July 31, 2019, 7:05pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-exception/193005/5 "2019-07-31T19:05:35Z")

</div>

this is an example in org.json.JSONObject

```
public long optLong(String var1, long var2) {
        try {
            return this.getLong(var1);
        } catch (Exception var5) {
            return var2;
        }
    }
```

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [July 31, 2019, 7:19pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-exception/193005/6 "2019-07-31T19:19:05Z")

</div>

But the agent is not automatically recording all exceptions in catch blocks. Are you using trace\_methods to also trace 3rd party methods?

---

<div class="post-metadata">

**Author:** ![Hong\_Phuoc\_Cao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hong_phuoc_cao/32/51288_2.png) [@Hong\_Phuoc\_Cao](https://discuss.elastic.co/u/Hong_Phuoc_Cao)\
**Post date:** [July 31, 2019, 8:30pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-exception/193005/7 "2019-07-31T20:30:54Z")

</div>

You are right, Im tracing JSONObject. Work fine after I removed it.

Thanks very much for your help.

---

<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:** [August 21, 2019, 4:30pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-exception/193005/8 "2019-08-21T16:30:56Z")

</div>

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