# Head based sampling for OTEL Agents

**URL:** <https://discuss.elastic.co/t/head-based-sampling-for-otel-agents/371498>\
**Category:** APM\
**Tags:** otel\
**Created:** [December 5, 2024, 3:23am UTC](https://discuss.elastic.co/t/head-based-sampling-for-otel-agents/371498 "2024-12-05T03:23:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pinsworker](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@pinsworker](https://discuss.elastic.co/u/pinsworker)\
**Post date:** [December 5, 2024, 3:23am UTC](https://discuss.elastic.co/t/head-based-sampling-for-otel-agents/371498/1 "2024-12-05T03:23:58Z")

</div>

Hi,

I have a OTEL based custom instrumentation for a http server and Elastic Cloud as collector/backend and I want to do head based sampling.  
These are my config env config for the same:

```auto
ENV OTEL_TRACES_SAMPLER_ARG="0.1"
ENV OTEL_LOG_LEVEL="warn"
ENV OTEL_BSP_MAX_QUEUE_SIZE="75000"
ENV OTEL_BSP_MAX_EXPORT_BATCH_SIZE="75000"
ENV OTEL_BSP_SCHEDULE_DELAY="2500"
ENV OTEL_EXPORTER_OTLP_TRACES_TIMEOUT="30000"
ENV OTEL_EXPORTER_OTLP_TIMEOUT="30000"
ENV OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
ENV OTEL_EXPORTER_OTLP_TRACES_PROTOCOL="http/protobuf"

```

This works fine and samples the traces on the application/OTEL agent level, **but the calculated metrics in kibana are also sampled**. As per Elastic documentation, central configuration for OTEL agents is not supported.

So is there a way I can send sampled traces but still get complete calculated transaction metrics?

Doing tail based sampling is hard because this service is high throughput and when 100% sampled traces are enabled, the agents end up dropping 50% of the traces, and also decreases throughput by 30-50%.

 ![Screenshot 2024-12-05 at 8.51.32 AM](https://us1.discourse-cdn.com/elastic/original/3X/7/2/72de041d6784febf9724e8833fdd5c304b4c74a2.png)
