# Tail-based sampling

**URL:** <https://discuss.elastic.co/t/tail-based-sampling/339701>\
**Category:** APM\
**Tags:** dotnet, server\
**Created:** [July 31, 2023, 2:13pm UTC](https://discuss.elastic.co/t/tail-based-sampling/339701 "2023-07-31T14:13:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bertrand67](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bertrand67/32/124123_2.png) [@Bertrand67](https://discuss.elastic.co/u/Bertrand67)\
**Post date:** [July 31, 2023, 2:13pm UTC](https://discuss.elastic.co/t/tail-based-sampling/339701/1 "2023-07-31T14:13:41Z")

</div>

**Kibana version** : 8.7.0

**Elasticsearch version** : 8.7.0

**APM Agent language and version** : .NET

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:  
Hello, I've configured tail-based sampling on server using this configuration :

```auto
- sample_rate: 1 
  trace.outcome: "failure"
- sample_rate: .01

```

But when I look in Kibana, I always see all traces including transactions and spans data for succesful traces.  
What is a proper configuration client/server side to have only 1% of sampled traces ?  
I use the .NET Elastic API to start and close transactions. I hope sampling is not based on "IsSampled" property because it's always "true" and it cannot be determined client side if sampling is configured in tail-based mode on server side.

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![simitt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simitt/32/106406_2.png) [@simitt](https://discuss.elastic.co/u/simitt)\
**Post date:** [August 1, 2023, 5:54am UTC](https://discuss.elastic.co/t/tail-based-sampling/339701/2 "2023-08-01T05:54:49Z")

</div>

With tail based sampling, whether a trace is sampled or not, is decided based on the _root transaction_. The root transaction is the very first transaction in a distributed trace. You can identify root transactions as transactions who do not have a `parent.id` set.  
The sampling rate is defined for `trace.outcome` , which means `event.outcome` of the root transaction. With the configuration that you shared, all traces (transactions+spans) where the root transaction has a `event.outcome: failure` are going to be 100% sampled, independent of the `event.outcome` of the other transactions in this trace. And traces (transactions+spans) where the root transaction has any other value for `event.outcome`, are sampled with 1%.

Can you please verify the sampling again with looking at the `root` transactions?

---

<div class="post-metadata">

**Author:** ![Bertrand67](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bertrand67/32/124123_2.png) [@Bertrand67](https://discuss.elastic.co/u/Bertrand67)\
**Post date:** [August 1, 2023, 12:25pm UTC](https://discuss.elastic.co/t/tail-based-sampling/339701/3 "2023-08-01T12:25:56Z")

</div>

Hello,

I've made more than 20 calls where root transactions has `event.outcome` equal to `success` and all traces are visible in Kibana including transactions and spans data.  
We are using an old version of NuGet Package **Elastic.Apm** : version **1.8.1** , maybe this version doesn't support tail-based sampling ?

Thank you for your help,

---

<div class="post-metadata">

**Author:** ![Bertrand67](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bertrand67/32/124123_2.png) [@Bertrand67](https://discuss.elastic.co/u/Bertrand67)\
**Post date:** [August 1, 2023, 12:40pm UTC](https://discuss.elastic.co/t/tail-based-sampling/339701/4 "2023-08-01T12:40:30Z")

</div>

I've got news. It's eventually working today ! I don't know why the situation changed. Maybe applications rebooting solved the problem.  
Sorry for the disturbance.

Thank you for your time,

---

<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 29, 2023, 12:40pm UTC](https://discuss.elastic.co/t/tail-based-sampling/339701/5 "2023-08-29T12:40:33Z")

</div>

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