> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cekura.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Metric Sampling

> Reduce metric evaluation costs by evaluating only a percentage of calls

export const CopyPageButton = () => {
  if (typeof window !== 'undefined') {
    setTimeout(function () {
      if (document.getElementById('ck-tools')) return;
      var anchor = document.getElementById('content-area') || document.querySelector('.mdx-content');
      if (!anchor) return;
      if (!document.getElementById('ck-style')) {
        var s = document.createElement('style');
        s.id = 'ck-style';
        s.textContent = '#ck-tools{position:absolute;top:6px;right:0;z-index:100;font-family:inherit;}' + '.ck-row{display:inline-flex;align-items:stretch;border:1px solid rgba(0,0,0,0.15);border-radius:8px;overflow:hidden;background:#fff;}' + ':root.dark .ck-row{background:rgba(255,255,255,0.06);border-color:rgba(255,255,255,0.12);}' + '.ck-btn{padding:5px 12px;border:none;background:none;cursor:pointer;font-size:13px;font-weight:500;font-family:inherit;color:#374151;}' + ':root.dark .ck-btn{color:#d1d5db;}' + '.ck-btn:hover{background:rgba(0,0,0,0.04);}' + ':root.dark .ck-btn:hover{background:rgba(255,255,255,0.06);}' + '.ck-chevron{padding:5px 8px;border:none;background:none;cursor:pointer;font-size:14px;font-family:inherit;color:#374151;}' + ':root.dark .ck-chevron{color:#d1d5db;}' + '.ck-chevron:hover{background:rgba(0,0,0,0.04);}' + ':root.dark .ck-chevron:hover{background:rgba(255,255,255,0.06);}' + '.ck-divider{width:1px;background:rgba(0,0,0,0.12);flex-shrink:0;}' + ':root.dark .ck-divider{background:rgba(255,255,255,0.12);}' + '.ck-dd{position:absolute;top:calc(100% + 4px);right:0;min-width:180px;background:#fff;border:1px solid rgba(0,0,0,0.12);border-radius:8px;box-shadow:0 4px 12px rgba(0,0,0,0.1);padding:4px;display:none;z-index:200;}' + ':root.dark .ck-dd{background:#1f2937;border-color:rgba(255,255,255,0.1);box-shadow:0 4px 16px rgba(0,0,0,0.35);}' + '.ck-item{display:block;width:100%;padding:7px 12px;border:none;background:none;border-radius:6px;cursor:pointer;font-size:13px;font-family:inherit;text-align:left;color:#374151;}' + ':root.dark .ck-item{color:#d1d5db;}' + '.ck-item:hover{background:rgba(0,0,0,0.05);}' + ':root.dark .ck-item:hover{background:rgba(255,255,255,0.07);}';
        document.head.appendChild(s);
      }
      var wrap = document.createElement('div');
      wrap.id = 'ck-tools';
      var row = document.createElement('div');
      row.className = 'ck-row';
      var mainBtn = document.createElement('button');
      mainBtn.className = 'ck-btn';
      mainBtn.textContent = 'Copy page';
      var divider = document.createElement('span');
      divider.className = 'ck-divider';
      var chevron = document.createElement('button');
      chevron.className = 'ck-chevron';
      chevron.textContent = '▾';
      var dd = document.createElement('div');
      dd.className = 'ck-dd';
      function closeDD() {
        dd.style.display = 'none';
      }
      function openDD() {
        dd.style.display = 'block';
      }
      chevron.onclick = function (e) {
        e.stopPropagation();
        if (dd.style.display === 'block') {
          closeDD();
        } else {
          openDD();
        }
      };
      document.addEventListener('click', function (e) {
        if (!e.target.closest('#ck-tools')) {
          closeDD();
        }
      });
      document.addEventListener('keydown', function (e) {
        if (e.key === 'Escape') {
          closeDD();
        }
      });
      function makeItem(label, fn) {
        var b = document.createElement('button');
        b.className = 'ck-item';
        b.textContent = label;
        b.onclick = function () {
          fn();
          closeDD();
        };
        return b;
      }
      function getMarkdown() {
        var walk = function (node) {
          if (!node) return '';
          if (node.nodeType === 3) return node.textContent || '';
          if (node.nodeType !== 1) return '';
          var tag = node.tagName.toLowerCase();
          var skip = ['script', 'style', 'svg', 'noscript', 'button', 'iframe'];
          if (skip.indexOf(tag) !== -1) return '';
          if (node.id === 'ck-tools') return '';
          var ch = Array.from(node.childNodes).map(walk).join('');
          if (tag === 'h1') return '\n# ' + ch.trim() + '\n\n';
          if (tag === 'h2') return '\n## ' + ch.trim() + '\n\n';
          if (tag === 'h3') return '\n### ' + ch.trim() + '\n\n';
          if (tag === 'p') return '\n' + ch.trim() + '\n\n';
          if (tag === 'pre') return '\n```\n' + node.textContent.trim() + '\n```\n\n';
          if (tag === 'li') return '- ' + ch.trim() + '\n';
          if (tag === 'code') return '`' + ch.trim() + '`';
          return ch;
        };
        var content = document.querySelector('.mdx-content') || document.getElementById('content-area') || document.body;
        return walk(content).replace(/\n\n\n+/g, '\n\n').trim();
      }
      function copyMd() {
        var md = getMarkdown();
        navigator.clipboard.writeText(md).then(function () {
          mainBtn.textContent = 'Copied!';
          setTimeout(function () {
            mainBtn.textContent = 'Copy page';
          }, 2000);
        });
      }
      function viewMd() {
        var md = getMarkdown();
        var safe = md.split('&').join('&amp;').split('<').join('&lt;').split('>').join('&gt;');
        var html = '<!DOCTYPE html><html><head><meta charset="utf-8"><style>body{font-family:monospace;max-width:860px;margin:40px auto;padding:0 24px;line-height:1.7;white-space:pre-wrap;word-wrap:break-word}</style></head><body>' + safe + '</body></html>';
        window.open(URL.createObjectURL(new Blob([html], {
          type: 'text/html'
        })), '_blank');
      }
      function openClaude() {
        var prompt = 'Can you read this Cekura docs page ' + window.location.href + ' so I can ask you questions?';
        window.open('https://claude.ai/new?q=' + encodeURIComponent(prompt), '_blank');
      }
      mainBtn.onclick = copyMd;
      dd.appendChild(makeItem('Copy page', copyMd));
      dd.appendChild(makeItem('View as Markdown', viewMd));
      dd.appendChild(makeItem('Open in Claude', openClaude));
      row.appendChild(mainBtn);
      row.appendChild(divider);
      row.appendChild(chevron);
      wrap.appendChild(row);
      wrap.appendChild(dd);
      anchor.style.position = 'relative';
      anchor.insertBefore(wrap, anchor.firstChild);
    }, 50);
  }
  return null;
};

<CopyPageButton />

## Overview

Metric Sampling allows you to reduce computational costs by evaluating metrics on only a subset of your calls. Instead of running every metric on every call, you can configure a sampling rate (e.g., 30%) to evaluate metrics on a representative sample while maintaining statistical accuracy.

<Warning>
  Metric sampling applies to **call logs (observability / live traffic) only**. It does **not** apply to simulation runs — all metrics enabled on an evaluator are always evaluated on every simulation run, regardless of the sampling rate configured in project settings.
</Warning>

## How It Works

The sampling feature uses a deterministic accumulator algorithm that ensures the exact percentage of calls are evaluated over time. For example, with a 30% sampling rate, exactly 30 out of every 100 calls will have the metric evaluated.

When a metric evaluation is skipped due to sampling, a placeholder record is created in your dashboard to maintain audit trails.

## Setting Up Sampling

<Steps>
  <Step title="Configure Project Sampling Rate">
    Navigate to **Settings** in your project and find the **Metric Sampling Rate (%)** field.

    Enter a value between 0-100:

    * `0` = No metrics evaluated (0%)
    * `100` = All metrics evaluated (100%, no sampling)
    * `30` = 30% of calls evaluated
    * `0.1` = 0.1% of calls evaluated

    <Frame caption="Configure the sampling rate in your project settings">
      <img src="https://mintcdn.com/vocera/ncuAR1fE-FpjjsfU/images/sampling/sampling-rate-project-setting.png?fit=max&auto=format&n=ncuAR1fE-FpjjsfU&q=85&s=192b6331628a99cfc7144ee0f1a61610" width="1440" height="1145" data-path="images/sampling/sampling-rate-project-setting.png" />
    </Frame>

    <Note>
      The sampling rate applies to all metrics that have sampling enabled. You can control which metrics use sampling in the next step.
    </Note>
  </Step>

  <Step title="Enable Sampling for Individual Metrics">
    Go to the **Metrics** section, find the metric you want to sample, and toggle the **Sampling** option to enable it.

    <Frame caption="Enable or disable sampling for individual metrics">
      <img src="https://mintcdn.com/vocera/ncuAR1fE-FpjjsfU/images/sampling/metric-config.png?fit=max&auto=format&n=ncuAR1fE-FpjjsfU&q=85&s=ffb1ae3bd066718c1f4be0c91ad647cc" width="2221" height="330" data-path="images/sampling/metric-config.png" />
    </Frame>

    <Tip>
      Not all metrics need sampling. Consider enabling sampling for:

      * Computationally expensive metrics (e.g., LLM-based evaluations)
      * Non-critical metrics used for trends rather than individual call analysis
      * Metrics evaluated on high-volume agents

      Keep sampling disabled for:

      * Critical workflow metrics (Boolean type)
      * Low-cost metrics (e.g., latency, duration)
      * Metrics where you need 100% coverage
    </Tip>
  </Step>
</Steps>

## Understanding Sampled Results

When a metric evaluation is skipped due to sampling:

* A placeholder record appears in your dashboard
* The explanation shows: `"Sampling skipped"`
* No score is computed for that specific call
* The audit trail is preserved

When a metric is evaluated (passes the sampling threshold):

* The metric runs normally
* Full scores and explanations are provided
* The call counts toward your sampling percentage

## Use Cases

**Cost Optimization**: Reduce evaluation costs on high-volume agents while maintaining statistical insights.

**Performance Testing**: Use 100% sampling during development and testing, then reduce to 10-30% in production.

**Trend Analysis**: For metrics used to track trends over time, sampling provides sufficient data without evaluating every call.

***
