# How to trace call from one Grpc service to the other Grpc service?

**URL:** <https://discuss.elastic.co/t/how-to-trace-call-from-one-grpc-service-to-the-other-grpc-service/207667>\
**Category:** APM\
**Tags:** python\
**Created:** [November 13, 2019, 9:44am UTC](https://discuss.elastic.co/t/how-to-trace-call-from-one-grpc-service-to-the-other-grpc-service/207667 "2019-11-13T09:44:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicoplus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicoplus/32/57589_2.png) [@nicoplus](https://discuss.elastic.co/u/nicoplus)\
**Post date:** [November 13, 2019, 9:44am UTC](https://discuss.elastic.co/t/how-to-trace-call-from-one-grpc-service-to-the-other-grpc-service/207667/1 "2019-11-13T09:44:29Z")

</div>

**APM Agent language and version** : python 3.6

Our apm can trace Mysql queries and Redis queries. But it can not trace call between service and service. Like the pic below:

 ![20191113173506](https://us1.discourse-cdn.com/elastic/original/3X/8/7/878284f5604ee7bdc53fdcf4899057780a72c3b9.jpeg)

The red rectangle is the call to other Grpc service. But apm lost the information.

The guy form infrastructure team told me that elastic-apm do not support tracing between Grpc services. Is it True?

---

<div class="post-metadata">

**Author:** ![basepi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/basepi/32/53056_2.png) [@basepi](https://discuss.elastic.co/u/basepi)\
**Post date:** [November 14, 2019, 1:25am UTC](https://discuss.elastic.co/t/how-to-trace-call-from-one-grpc-service-to-the-other-grpc-service/207667/2 "2019-11-14T01:25:37Z")

</div>

Hello @nicoplus! Welcome to the forum.

Unfortunately we don't yet support gRPC in the python agent. It's possible we support it in other languages, but since you tagged this `python` I assume that's what you're using?

We've thought about adding support via [python interceptors](https://github.com/grpc/proposal/blob/master/L13-python-interceptors.md) but it hasn't been high on our priority list. If this is something you'd like to see happen, can you please [open an issue](https://github.com/elastic/apm-agent-python/issues) with the request?

---

<div class="post-metadata">

**Author:** ![nicoplus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicoplus/32/57589_2.png) [@nicoplus](https://discuss.elastic.co/u/nicoplus)\
**Post date:** [November 14, 2019, 2:42am UTC](https://discuss.elastic.co/t/how-to-trace-call-from-one-grpc-service-to-the-other-grpc-service/207667/3 "2019-11-14T02:42:07Z")

</div>

Thanks for your reply!

You're right. I am using python. And I will add an issue.

I've found another question, the timeline can't trace code computing.

Recently, I'd like to optimize some algorithm that there are not any network IO. My request is that monitoring the algorithm timeline. Unfortunately elastic-apm lost the information, like the gRPC trace.

Is it a request not added?

---

<div class="post-metadata">

**Author:** ![basepi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/basepi/32/53056_2.png) [@basepi](https://discuss.elastic.co/u/basepi)\
**Post date:** [November 14, 2019, 4:59pm UTC](https://discuss.elastic.co/t/how-to-trace-call-from-one-grpc-service-to-the-other-grpc-service/207667/4 "2019-11-14T16:59:43Z")

</div>

You may be able to use [our API](https://www.elastic.co/guide/en/apm/agent/python/current/api.html) to begin and end custom transactions around the pieces of code that you want to instrument.

Our Java agent supports tracing methods, though it is turned off by default because of performance concerns. We've considered adding something similar for Python but it's not on our immediate roadmap.

---

<div class="post-metadata">

**Author:** ![beniwohli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/beniwohli/32/21256_2.png) [@beniwohli](https://discuss.elastic.co/u/beniwohli)\
**Post date:** [November 15, 2019, 1:10pm UTC](https://discuss.elastic.co/t/how-to-trace-call-from-one-grpc-service-to-the-other-grpc-service/207667/5 "2019-11-15T13:10:55Z")

</div>

There's also the [`capture_span`](https://www.elastic.co/guide/en/apm/agent/python/current/instrumenting-custom-code.html) decorator / context manager to manually instrument functions or blocks of code. These will then appear as a span if they are called during a transaction (e.g. a web request).

It is well suited to trace a certain function call which then executes your algorithm, but it's not a great fit for instrumenting hot paths inside your implementation (e.g. in a for loop that will be executed many times). For optimizing an algorithm that you know to be slow, a profiler like [pyinstrument](https://github.com/joerick/pyinstrument), [py-spy](https://github.com/benfred/py-spy) or [pyflame](https://github.com/uber/pyflame) is usually the better fit.

---

<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:** [December 6, 2019, 9:11am UTC](https://discuss.elastic.co/t/how-to-trace-call-from-one-grpc-service-to-the-other-grpc-service/207667/6 "2019-12-06T09:11:03Z")

</div>

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