# Capture all traces & spans and custom configuration doubt

**URL:** <https://discuss.elastic.co/t/capture-all-traces-spans-and-custom-configuration-doubt/204362>\
**Category:** APM\
**Tags:** java\
**Created:** [October 20, 2019, 3:45pm UTC](https://discuss.elastic.co/t/capture-all-traces-spans-and-custom-configuration-doubt/204362 "2019-10-20T15:45:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gopikrishnan](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gopikrishnan](https://discuss.elastic.co/u/gopikrishnan)\
**Post date:** [October 20, 2019, 3:45pm UTC](https://discuss.elastic.co/t/capture-all-traces-spans-and-custom-configuration-doubt/204362/1 "2019-10-20T15:45:09Z")

</div>

Hi All,

Am totally new to elastic apm and elastic search as well and am trying to evaluate elastic apm and its capabilities. Can someone please help to answer below queries

1. how to capture trace and spans for all the request coming to server. By far I got to know that spans are captured if the span is greater or equal to **span\_frames\_min\_duration** which is default 5ms. But can we make the agent to capture all spans and traces? and if we can how to do it and where?

2. If i want to do some manual configuration like change the name for the transactions captured then how to do it and where to change the configuration. I saw documentation on public API but am since am so naive 😅 i dont understand how to use those configuration and where to put it.

Regards,  
Gopikrishnan

---

<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:** [October 21, 2019, 1:20am UTC](https://discuss.elastic.co/t/capture-all-traces-spans-and-custom-configuration-doubt/204362/2 "2019-10-21T01:20:06Z")

</div>

> how to capture trace and spans for all the request coming to server. By far I got to know that spans are captured if the span is greater or equal to **span\_frames\_min\_duration** which is default 5ms. But can we make the agent to capture all spans and traces? and if we can how to do it and where?

`span_frames_min_duration` is not related to capturing spans, but rather is related to capturing stack traces when starting spans. See the docs here: [Stacktrace configuration options | APM Java Agent Reference [1.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/java/current/config-stacktrace.html#config-span-frames-min-duration)

By default the agents will sample all traces. You can control the sampling rate ([transaction\_sample\_rate](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-transaction-sample-rate)). Non-sampled traces will suppress spans. Sampled traces will include all spans, up to a maximum number of spans per transaction ([transaction\_max\_spans](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-transaction-max-spans), defaults to 500).

> If i want to do some manual configuration like change the name for the transactions captured then how to do it and where to change the configuration. I saw documentation on public API but am since am so naive 😅 i dont understand how to use those configuration and where to put it.

You will need to modify your application code to use the public API, so to answer this fully we would need to know what language, what frameworks, etc. If for example you were using a Java servlet, you could modify your servlet to use the Java agent's public API, calling [ElasticApm.currentTransaction](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-current-transaction), followed by [Transaction.setName](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-set-name).

---

<div class="post-metadata">

**Author:** ![gopikrishnan](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gopikrishnan](https://discuss.elastic.co/u/gopikrishnan)\
**Post date:** [October 21, 2019, 9:53am UTC](https://discuss.elastic.co/t/capture-all-traces-spans-and-custom-configuration-doubt/204362/3 "2019-10-21T09:53:36Z")

</div>

Thanks for the reply @axw.

> By default the agents will sample all traces.

the remaining statements surrounding this statement I understood but except this. If and all agent samples all traces then as per below image for 10 requests why there is only one trace sample where it should have been 10 samples for each I guess. Sorry if am mixing things up 🥴

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/4/846593e9046ff6f4216a94acc66582e02962c4a1.png)

> You will need to modify your application code to use the public API, so to answer this fully we would need to know what language, what frameworks, etc. If for example you were using a Java servlet, you could modify your servlet to use the Java agent's public API, calling [ElasticApm.currentTransaction](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-current-transaction), followed by [Transaction.setName](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-set-name).

so for the above statement it means that we have to modify the application code to include the public API correct ? is there any other way to do it from the elastic UI (Kibana) or through the agent properties ?

I can see there are alot of options available [here](https://www.elastic.co/guide/en/apm/agent/java/current/configuration.html) to configure agent properties.

---

<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:** [October 22, 2019, 3:46am UTC](https://discuss.elastic.co/t/capture-all-traces-spans-and-custom-configuration-doubt/204362/4 "2019-10-22T03:46:26Z")

</div>

> [@gopikrishnan](#):
>
> the remaining statements surrounding this statement I understood but except this. If and all agent samples all traces then as per below image for 10 requests why there is only one trace sample where it should have been 10 samples for each I guess. Sorry if am mixing things up 🥴

In the "Transactions duration distribution" histogram, hover over the buckets (latency ranges) and you will see how many transactions were captured for that latency range.

When you click on a bucket, you'll be presented with a single sample trace/transaction which falls into that bucket. There is another ongoing Discuss thread regarding being able to look at multiple trace samples: [Look at more than one sampled trace](https://discuss.elastic.co/t/look-at-more-than-one-sampled-trace/203920)

> so for the above statement it means that we have to modify the application code to include the public API correct ?

Correct.

> is there any other way to do it from the elastic UI (Kibana) or through the agent properties ?

For the Java agent specifically, there are a couple of agent properties that may be relevant to your use case:

- [use\_path\_as\_transaction\_name](https://www.elastic.co/guide/en/apm/agent/java/current/config-http.html#config-use-path-as-transaction-name)
- [url\_groups](https://www.elastic.co/guide/en/apm/agent/java/current/config-http.html#config-url-groups)

If these don't help, you could alternatively configure [Ingest Node](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/ingest.html) to rewrite the transaction name field values. You would have to take care to rewrite associated metrics documents as well.

---

<div class="post-metadata">

**Author:** ![gopikrishnan](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gopikrishnan](https://discuss.elastic.co/u/gopikrishnan)\
**Post date:** [October 22, 2019, 10:48am UTC](https://discuss.elastic.co/t/capture-all-traces-spans-and-custom-configuration-doubt/204362/5 "2019-10-22T10:48:41Z")

</div>

Thanks @axw.

It was very helpful. Lastly I saw the basic plan for elastic apm pricing and am able to get APM feature for free. So is it like elastic APM is free for lifetime? for any amount of data?

---

<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:** [October 22, 2019, 12:31pm UTC](https://discuss.elastic.co/t/capture-all-traces-spans-and-custom-configuration-doubt/204362/6 "2019-10-22T12:31:18Z")

</div>

> [@gopikrishnan](#):
>
> It was very helpful. Lastly I saw the basic plan for elastic apm pricing and am able to get APM feature for free. So is it like elastic APM is free for lifetime? for any amount of data?

Yes, assuming you're self-managing the stack on your own hardware (i.e. "Standalone" on [Subscriptions | Elastic Stack Products & Support | Elastic](https://www.elastic.co/subscriptions)). The amount of data you store does not affect this.

---

<div class="post-metadata">

**Author:** ![gopikrishnan](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gopikrishnan](https://discuss.elastic.co/u/gopikrishnan)\
**Post date:** [October 23, 2019, 7:19am UTC](https://discuss.elastic.co/t/capture-all-traces-spans-and-custom-configuration-doubt/204362/7 "2019-10-23T07:19:12Z")

</div>

So does basic have the alerting feature by any chance. What is the difference between Basic and Gold subscriptions? what i understand is basic doesn't have alerting and Gold has it.

---

<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:** [October 23, 2019, 7:52am UTC](https://discuss.elastic.co/t/capture-all-traces-spans-and-custom-configuration-doubt/204362/8 "2019-10-23T07:52:31Z")

</div>

You understand correctly -- the Alerting feature is Gold+.

To get a full comparison between the different subscription levels (Basic, Gold, Platinum), on the [subscriptions page](https://www.elastic.co/subscriptions) click "Expand all features".

---

<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:** [November 13, 2019, 3:52am UTC](https://discuss.elastic.co/t/capture-all-traces-spans-and-custom-configuration-doubt/204362/9 "2019-11-13T03:52:31Z")

</div>

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