# Controlling the eBPF sampling mechanism

{% hint style="info" %}
This page addresses the sampling of eBPF traces generated by the groundcover sensors.\
For sampling of traces generated by external libraries, see [OpenTelemetry](broken://pages/zj2qhGmf3BoJ3yOOPd4M#sampling-incoming-traces) & [DataDog](broken://pages/HYp4iENWF8Mcd05MAGGb#sampling-incoming-traces).\
\
Can't find what you're looking for? [Let us know over Slack!](https://www.groundcover.com/join-slack)
{% endhint %}

groundcover utilizes [smart sampling](/capabilities/application-performance-monitoring-apm/traces.md#sampling) in order to only store the traces which we believe are the most important for monitoring your environment. However, some more advanced use cases might require adjusting the sampling strategy, making sure you get the exact coverage you need.

This page details the way in which sampling can be configured.

### Force Sampling

Some cases might require 100% visibility into traces of specific services or APIs. groundcover allows forcing sampling of transactions by these methods:

#### By request header (HTTP/gRPC only)

HTTP/gRPC requests which include the header below will be force sampled.

```
x-groundcover-force-sample: true
```

#### By pod labels / annotations

Pods which have the following value as either a label and/or annotation will have all traces sampled:

```
groundcover/force-sample: "true"
```

### Rate Limiting

The sampling mechanism can be rate limited to reduce the total amount of traces produced. Note that traces marked as issues will not be affected by this configuration.

Rate is specified by number of traces allowed per 100 milliseconds, using the following values override:

```
agent:
  sensor:
    env:
      - name: GC_GLOBALLIMITER_MAXQUEUE
        value: 10 # will limit to a rate of 100 traces / second
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.groundcover.com/customization/customize-usage/controlling-the-ebpf-sampling-mechanism.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
