# Elastic APM java agent ignore specific gRPC function

**URL:** <https://discuss.elastic.co/t/elastic-apm-java-agent-ignore-specific-grpc-function/294024>\
**Category:** APM\
**Tags:** java\
**Created:** [January 11, 2022, 11:29am UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-ignore-specific-grpc-function/294024 "2022-01-11T11:29:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![duclm2609](https://avatars.discourse-cdn.com/v4/letter/d/90ced4/32.png) [@duclm2609](https://discuss.elastic.co/u/duclm2609)\
**Post date:** [January 11, 2022, 11:29am UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-ignore-specific-grpc-function/294024/1 "2022-01-11T11:29:32Z")

</div>

Hello guys,  
I'm using Elastic APM Java agent to instrument my application, which is a gRPC server. My server implement gRPC healthcheck protocol and the healthcheck function is called every 10 seconds. I don't want to record this transaction. How to exclude specific gRPC function from being instrumented by APM agent? I know an option is ELASTIC\_APM\_TRANSACTION\_IGNORE\_URLS but it's for HTTP server only.  
Any help is appreciate. Thank you.

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [January 11, 2022, 11:50am UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-ignore-specific-grpc-function/294024/2 "2022-01-11T11:50:49Z")

</div>

You could try [excluding the health check class](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-classes-excluded-from-instrumentation) from the instrumentation

---

<div class="post-metadata">

**Author:** ![duclm2609](https://avatars.discourse-cdn.com/v4/letter/d/90ced4/32.png) [@duclm2609](https://discuss.elastic.co/u/duclm2609)\
**Post date:** [January 11, 2022, 2:58pm UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-ignore-specific-grpc-function/294024/3 "2022-01-11T14:58:44Z")

</div>

Thank you for your reply.  
I've tried the options (through setting environment variable ELASTIC\_APM\_CLASSES\_EXCLUDED\_FROM\_INSTRUMENTATION and restart service) but not luck.  
For this specific case, I've used [gRPC Health Checking Protocol](https://github.com/grpc/grpc/blob/master/doc/health-checking.md), which has already implemented by the gRPC library. I've tried set the env with following values:

> ELASTIC\_APM\_CLASSES\_EXCLUDED\_FROM\_INSTRUMENTATION = io.grpc.health.v1.HealthGrpc

The request still reported by APM agent:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/8/7894539e3d41df90dbddb51f1f393e65dd149e0f.png)

---

<div class="post-metadata">

**Author:** ![riferrei](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/riferrei/32/104867_2.png) [@riferrei](https://discuss.elastic.co/u/riferrei)\
**Post date:** [January 11, 2022, 5:11pm UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-ignore-specific-grpc-function/294024/4 "2022-01-11T17:11:14Z")

</div>

@Eyal_Koren, do you know what can be done here? @duclm2609 tried to use the `classes_excluded_from_instrumentation ` property using a fully qualified class, but maybe the property expects a matching wildcard?

— @riferrei

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [January 14, 2022, 4:04pm UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-ignore-specific-grpc-function/294024/5 "2022-01-14T16:04:30Z")

</div>

It looks to me like there is no simple way to do this. I'd say it's a feature request similar to [HTTP configuration options | APM Java Agent Reference [1.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/java/current/config-http.html#config-transaction-ignore-urls) . Looks like it wouldn't be hard to add (make an exclude requests method in the GrpcHelper class similar to the HttpHandlerAdvice.isExcluded() method, and apply that the helper methods to not activate the transaction if the request matches. I'd use the transaction.getNameAsString() to match against whatever set of regexes are excluded. We don't have time to do this right now, but feel free to raise the feature request

---

<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:** [February 4, 2022, 12:05pm UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-ignore-specific-grpc-function/294024/6 "2022-02-04T12:05:08Z")

</div>

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