# Reduce the amount of data for spans and transactions

**URL:** <https://discuss.elastic.co/t/reduce-the-amount-of-data-for-spans-and-transactions/204287>\
**Category:** APM\
**Tags:** ruby\
**Created:** [October 18, 2019, 10:16pm UTC](https://discuss.elastic.co/t/reduce-the-amount-of-data-for-spans-and-transactions/204287 "2019-10-18T22:16:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dnorth98](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dnorth98/32/54823_2.png) [@dnorth98](https://discuss.elastic.co/u/dnorth98)\
**Post date:** [October 18, 2019, 10:16pm UTC](https://discuss.elastic.co/t/reduce-the-amount-of-data-for-spans-and-transactions/204287/1 "2019-10-18T22:16:58Z")

</div>

Hi folks,  
ES APM on Ruby v3.0.0. Wondering if it's possible to set the ELASTIC\_APM\_TRANSACTION\_SAMPLE\_RATE parameter to a lower value than 0.1 (say 0.05)? Reason is, our services generate a LOT of transactions (looks like around 100GB of index data per day) and while I've setup Elastic Cloud to handle this no problem, we're being killed by AWS on data transfer cross-zone costs.

I'm already at 0.1 for the key heavy volume services so trying to see how I can keep some APM value but reduce the volume of data sent for transactions and spans.

Cheers

Dave

---

<div class="post-metadata">

**Author:** ![mikker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikker/32/22118_2.png) [@mikker](https://discuss.elastic.co/u/mikker)\
**Post date:** [October 21, 2019, 7:43am UTC](https://discuss.elastic.co/t/reduce-the-amount-of-data-for-spans-and-transactions/204287/2 "2019-10-21T07:43:55Z")

</div>

Hi again Dave! Putting Elastic APM to the test – I love it 🙂

Setting it to `0.05` will work just as expected. The check looks like this, so anything that converts into a float will work:

```auto
rand <= config.transaction_sample_rate

```

You might be able to decrease the individual event size a bit too:

If you don't care (or don't care _enough_) about seeing source code in kibana, there's perhaps a lot of bytes to be saved by skipping those with the options `source_lines_error_app_frames` and `source_lines_span_app_frames`. They are both `5` lines by default, meaning the line in question and the 2 immediately before and after. Set them to `0` to disable source code lines entirely.

You could also disable `capture_headers` or `capture_env` but that's probably not many bytes after gzip.

And of course if there's entire libraries' spans that you don't care about, you can disable their auto-instrumentation with `disabled_instrumentations`.

These are all slightly worsening the overall APM experience but if it's between _slightly worse_ and _nothing at all_ they could be worth it.

Let me know how it goes!

---

<div class="post-metadata">

**Author:** ![mikker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikker/32/22118_2.png) [@mikker](https://discuss.elastic.co/u/mikker)\
**Post date:** [October 21, 2019, 7:55am UTC](https://discuss.elastic.co/t/reduce-the-amount-of-data-for-spans-and-transactions/204287/3 "2019-10-21T07:55:54Z")

</div>

A colleague suggested looking at `span_frames_min_duration` too. It lets you set the minimum duration of a span for it to have its stacktrace included. Or, you can disable stacktraces altogether by setting it to `0`.

---

<div class="post-metadata">

**Author:** ![dnorth98](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dnorth98/32/54823_2.png) [@dnorth98](https://discuss.elastic.co/u/dnorth98)\
**Post date:** [October 21, 2019, 12:16pm UTC](https://discuss.elastic.co/t/reduce-the-amount-of-data-for-spans-and-transactions/204287/4 "2019-10-21T12:16:19Z")

</div>

All of this is GOLD @mikker, thanks so much! I'll try tweaking these today starting with lowering the transaction rate on the services that have a high throughput. They are between 20 - 80,000 transactions per minute and almost all are "the same" transaction (or very close to it) so I feel there is a good data saving to be had here.

If we need more, I'll move onto pruning out the stack traces.

Thanks again!

Dave

---

<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 11, 2019, 8:16am UTC](https://discuss.elastic.co/t/reduce-the-amount-of-data-for-spans-and-transactions/204287/5 "2019-11-11T08:16:26Z")

</div>

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