# Distributed Tracing with Elastic APM

**URL:** <https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642>\
**Category:** APM\
**Tags:** java\
**Created:** [July 16, 2019, 5:07am UTC](https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642 "2019-07-16T05:07:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahulnama](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rahulnama](https://discuss.elastic.co/u/rahulnama)\
**Post date:** [July 16, 2019, 5:07am UTC](https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642/1 "2019-07-16T05:07:12Z")

</div>

Hello Team

We have a use case of monitoring micro-services(written in java and python) with elastic APM. Can you suggest me few pointers for below questions

1. Is distributed tracing part of X-pack ?
2. To monitor databases for which these services are connecting to, Do I've to install beats ?

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [July 16, 2019, 5:57am UTC](https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642/2 "2019-07-16T05:57:09Z")

</div>

Hi @rahulnama

> [@rahulnama](#):
>
> 1. Is distributed tracing part of X-pack ?

The agents are all OSS: mostly Apache2 licensed, a couple are BSD licensed. APM Server comes under a mixed Apache2/Elastic license ([https://github.com/elastic/apm-server/blob/master/LICENSE.txt](https://github.com/elastic/apm-server/blob/master/LICENSE.txt)), but you don't need to use any proprietary features for the purpose of distributed tracing.

The APM UI, which is how distributed traces can be visualised, comes under the Basic license. It's free to use.

> [@rahulnama](#):
>
> 1. To monitor databases for which these services are connecting to, Do I've to install beats ?

If you're only interested in seeing the database query latency in your distributed traces, then you do not need to install any Beats. The Java agent will capture JDBC query timings, and the Python agent will do the same for DB-API 2.0 clients.

If you want additional insight into the database itself, then you can use Metricbeat (e.g. [Metricbeat MySQL module](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-mysql.html)) and Filebeat (e.g. [Filebeat MySQL module](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-module-mysql.html)).

---

<div class="post-metadata">

**Author:** ![rahulnama](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rahulnama](https://discuss.elastic.co/u/rahulnama)\
**Post date:** [July 16, 2019, 6:24am UTC](https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642/3 "2019-07-16T06:24:40Z")

</div>

Thanks @axw that helps 🙂

Please let me know if any tutorials for monitoring java and python apps with Elastic APM are available.

Best  
Rahul

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [July 16, 2019, 8:27am UTC](https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642/4 "2019-07-16T08:27:28Z")

</div>

We don't really have tutorials. You can find documentation on how to set up the agents at [https://www.elastic.co/guide/en/apm/agent/index.html](https://www.elastic.co/guide/en/apm/agent/index.html), as well as some more information on [https://www.elastic.co/blog](https://www.elastic.co/blog), e.g.

- [https://www.elastic.co/blog/elastic-apm-java-agent-is-generally-available](https://www.elastic.co/blog/elastic-apm-java-agent-is-generally-available)
- [https://www.elastic.co/blog/creating-custom-framework-integrations-with-the-elastic-apm-python-agent](https://www.elastic.co/blog/creating-custom-framework-integrations-with-the-elastic-apm-python-agent)

There are tutorial-style walkthroughs around the web. I can't recommend any in particular, but this one looks like it might be a good place to start: [https://medium.com/@sece.cosmin/monitor-spring-boot-application-performance-with-elastic-apm-elasticsearch-and-kibana-8d4299cad2be](https://medium.com/@sece.cosmin/monitor-spring-boot-application-performance-with-elastic-apm-elasticsearch-and-kibana-8d4299cad2be).

---

<div class="post-metadata">

**Author:** ![rahulnama](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rahulnama](https://discuss.elastic.co/u/rahulnama)\
**Post date:** [July 18, 2019, 5:23am UTC](https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642/5 "2019-07-18T05:23:08Z")

</div>

hey @axw

I've integrated python with elastic apm. it works cool.

but suppose I've two scenarios

Scenario-1: I've hardcoded all the sql queries in my python code  
Scenario-2: I'm maintaining a config file for queries and i'm importing the queries to my code

in both cases will elastic apm maintain the query latency ? do we need to follow any best practices in terms of coding .

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [July 18, 2019, 7:33am UTC](https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642/6 "2019-07-18T07:33:42Z")

</div>

Glad to hear it's working well for you.

I'm not sure I understand your question. As long as you're using one of the database libraries mentioned in [https://www.elastic.co/guide/en/apm/agent/python/current/supported-technologies.html#automatic-instrumentation-db](https://www.elastic.co/guide/en/apm/agent/python/current/supported-technologies.html#automatic-instrumentation-db), then the agent will capture the database queries. It doesn't matter whether the queries are hard-coded or defined in a file, the agent instruments the database client.

---

<div class="post-metadata">

**Author:** ![rahulnama](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rahulnama](https://discuss.elastic.co/u/rahulnama)\
**Post date:** [July 18, 2019, 8:16am UTC](https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642/7 "2019-07-18T08:16:55Z")

</div>

got it. very good to know

Thanks again 🙂

---

<div class="post-metadata">

**Author:** ![rahulnama](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rahulnama](https://discuss.elastic.co/u/rahulnama)\
**Post date:** [July 19, 2019, 5:05am UTC](https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642/8 "2019-07-19T05:05:20Z")

</div>

Hey @axw

I'm also trying to integrate apm with java app.

Java App: [https://github.com/elastic/spring-petclinic](https://github.com/elastic/spring-petclinic)

Java app is up and running(on AWS EC-2):  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/6/76f5a9455b08f3ce637767254b726b967a71e693.png)

APM is running too  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/8/2842e1e9b81a0f338321ea671584edd9834b7672.png)

APM is configured in Java as a jar. you can see it here  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/f/ef8ad24b9de9e508c8aca7be04d4f3bf16876b33.png)

Now, How do I make sure the logs from java app are being sent to apm server and then to elasticsearch. I dont see any service related to java in kibana.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/c/3c8abd43e5e81ce8123ca68e825eee744d97db90.png)

Is there anything that I need to do while running java app.

Please suggest

Thanks for your time as always 🙂

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [July 19, 2019, 5:27am UTC](https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642/9 "2019-07-19T05:27:13Z")

</div>

I'm not personally familiar with the spring-petclinic app. It could be that it's using an older version of the Java agent, which does not work with your version of the stack. The README for spring-petclinic says:

> Other versions of the Elasticstack may work. Currently, only version 6.4.2 has been tested.

If that's still accurate, it implies an old version of the Java agent is being used, as the current version will not work with APM Server 6.4.2. In addition, APM Server 7.2.0 will not support those older (pre-GA) versions of the Java agent.

I don't know if that documentation is accurate though. I'd suggest opening new, more specific topic and perhaps someone else can chime in.

---

<div class="post-metadata">

**Author:** ![rahulnama](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rahulnama](https://discuss.elastic.co/u/rahulnama)\
**Post date:** [July 19, 2019, 5:33am UTC](https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642/10 "2019-07-19T05:33:00Z")

</div>

Sure. Will try changing the java agent version. Still, If not working, will open a new thread.

Thank you 🙂

---

<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 9, 2019, 1:33am UTC](https://discuss.elastic.co/t/distributed-tracing-with-elastic-apm/190642/11 "2019-08-09T01:33:04Z")

</div>

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