# Doubts on Class exclusion

**URL:** <https://discuss.elastic.co/t/doubts-on-class-exclusion/246655>\
**Category:** APM\
**Tags:** java\
**Created:** [August 27, 2020, 3:26pm UTC](https://discuss.elastic.co/t/doubts-on-class-exclusion/246655 "2020-08-27T15:26:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![manohar\_deepu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manohar_deepu/32/72797_2.png) [@manohar\_deepu](https://discuss.elastic.co/u/manohar_deepu)\
**Post date:** [August 27, 2020, 3:26pm UTC](https://discuss.elastic.co/t/doubts-on-class-exclusion/246655/1 "2020-08-27T15:26:48Z")

</div>

Hey,  
In my application, I have specified to exclude a DAO class (extending hibernate dao) using classes\_excluded\_from\_instrumentation.

When I see the dashboard, I can still the db calls via that class instrumented. Am I missing something here.

Also, the dropwizard by default exposes its health check rest endpoint on adminport.  
I don't want to instrument any calls coming on this admin port. Is there a way for me to do this.

---

<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:** [August 31, 2020, 7:33am UTC](https://discuss.elastic.co/t/doubts-on-class-exclusion/246655/2 "2020-08-31T07:33:49Z")

</div>

How are the DAO spans created? If you're using profiler-inferred spans, you have to exclude the classes with this option: [https://www.elastic.co/guide/en/apm/agent/java/current/config-profiling.html#config-profiling-inferred-spans-excluded-classes](https://www.elastic.co/guide/en/apm/agent/java/current/config-profiling.html#config-profiling-inferred-spans-excluded-classes)

You can ignore certain paths like `/admin*`: [https://www.elastic.co/guide/en/apm/agent/java/current/config-http.html#config-ignore-urls](https://www.elastic.co/guide/en/apm/agent/java/current/config-http.html#config-ignore-urls)

---

<div class="post-metadata">

**Author:** ![manohar\_deepu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manohar_deepu/32/72797_2.png) [@manohar\_deepu](https://discuss.elastic.co/u/manohar_deepu)\
**Post date:** [September 5, 2020, 7:30am UTC](https://discuss.elastic.co/t/doubts-on-class-exclusion/246655/3 "2020-09-05T07:30:26Z")

</div>

> [@felixbarny](#):
>
> admin

This worked out well. Thank you

> [@felixbarny](#):
>
> How are the DAO spans created? If you're using profiler-inferred spans, you have to exclude the classes with this option: [Profiling configuration options | APM Java Agent Reference [1.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/java/current/config-profiling.html#config-profiling-inferred-spans-excluded-classes)

I am not using profiler-inferred spans. Its a simple span which is getting created as part of my API execution.

In my configuration, I have given the entry like this  
"classes\_excluded\_from\_instrumentation": "com.dao.\*"

But still, I am getting spans for all APIs which are executing the classes inside this dao.\* packages  
See the sample entity in the span, that is queried by the class inside this dao package.

 ![Screenshot 2020-09-05 at 1.48.07 PM](https://us1.discourse-cdn.com/elastic/original/3X/d/5/d5f65beb4d263f31cb13c77398b0a746e7dde923.png)  
 ![Screenshot 2020-09-05 at 1.48.14 PM](https://us1.discourse-cdn.com/elastic/original/3X/5/2/521c095878e99a51e4624997cd5dc49c33ce7b55.jpeg)

---

<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:** [September 7, 2020, 6:21am UTC](https://discuss.elastic.co/t/doubts-on-class-exclusion/246655/4 "2020-09-07T06:21:23Z")

</div>

If you want to disable JDBC query spans, you can set [`disable_instrumentations`](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-disable-instrumentations) to `experimental,jdbc`

---

<div class="post-metadata">

**Author:** ![manohar\_deepu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manohar_deepu/32/72797_2.png) [@manohar\_deepu](https://discuss.elastic.co/u/manohar_deepu)\
**Post date:** [September 7, 2020, 6:40am UTC](https://discuss.elastic.co/t/doubts-on-class-exclusion/246655/5 "2020-09-07T06:40:52Z")

</div>

T

> [@felixbarny](#):
>
> If you want to disable JDBC query spans, you can set [`disable_instrumentations`](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-disable-instrumentations) to `experimental,jdbc`

This will disable the jdbc instrumentation for all the classes. My requirement was that I wanted to disable the JDBC instrumentation / HTTP Instrumentation for the specific classes.

Seems like the behaviour of classes exclusion is it only disables the @Capturespan, @CaptureTransaction which are explicitly added to those classes and any inherent instrumentation like JDBC, HTTP will get instrumented irrespective of whether you exclude the class or not.

---

<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:** [September 7, 2020, 8:12am UTC](https://discuss.elastic.co/t/doubts-on-class-exclusion/246655/6 "2020-09-07T08:12:18Z")

</div>

We don't instrument your application dao classes, but the JDBC driver. That's why excluding your dao classes from instrumentation doesn't have any effect.

We don't have a feature to disable JDBC spans if the calls originate from a specific class. The closest thing we have is setting `ignore_urls`.

Could you explain your use case including why you want to exclude JDBC spans in certain cases?

---

<div class="post-metadata">

**Author:** ![manohar\_deepu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manohar_deepu/32/72797_2.png) [@manohar\_deepu](https://discuss.elastic.co/u/manohar_deepu)\
**Post date:** [September 7, 2020, 8:30am UTC](https://discuss.elastic.co/t/doubts-on-class-exclusion/246655/7 "2020-09-07T08:30:09Z")

</div>

My use case is, there are certain DAO in my app which query tables which are quite business-sensitive, hence I don't want its table internals to be exposed via the APM span instrumentation.

But there are other DAO classes in the same app, which query tables which are not so business-sensitive and hence capturing the spans are ok.

---

<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:** [September 7, 2020, 11:53am UTC](https://discuss.elastic.co/t/doubts-on-class-exclusion/246655/8 "2020-09-07T11:53:32Z")

</div>

You could define a [custom ingest node pipeline](https://www.elastic.co/guide/en/apm/server/current/configuring-ingest-node.html#custom-pipelines) and drop the query if the db query contains a certain sensitive table name.

If you don't want the information to leave the host, you could deploy APM Server on your host and use [processors](https://www.elastic.co/guide/en/beats/filebeat/current/drop-fields.html) to drop the field that stores the query.

---

<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:** [September 28, 2020, 7:53am UTC](https://discuss.elastic.co/t/doubts-on-class-exclusion/246655/9 "2020-09-28T07:53:38Z")

</div>

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