# OpenTelemetry Collector Performance Tuning: 7 Optimizations for Production

> Fine-tune your OpenTelemetry Collector for production: exporter-native batching, tail sampling, cardinality control, processor ordering, Go runtime tuning, and a two-tier architecture. Includes YAML configs and PromQL queries.

Source: https://openobserve.ai/blog/opentelemetry-collector-performance-tuning/
Published: 2026-12-01
Authors: Manas Sharma
Category: How To
Tags: OpenTelemetry, Tracing, Kubernetes, Observability, DevOps

---

Teams that started with a handful of instrumented services are now running full OpenTelemetry pipelines, with spans, metrics, and logs from dozens of microservices flowing through a central Collector fleet. That fleet is now production infrastructure, and it has a cost. Every span created, every attribute attached, and every batch serialized and exported consumes CPU, memory, and network.

The bottlenecks show up in the same places: batching that produces too many small export requests, trace pipelines exporting 100% of traffic when a fraction would cover every meaningful signal, attributes nobody queries riding on every span, and processor chains spending CPU on data they are about to discard.

This guide covers seven tuning areas for production Collector deployments, with working YAML and the PromQL to confirm each change helped. If you are new to the config file itself, start with the [OpenTelemetry Collector configuration guide](/blog/opentelemetry-collector-configuration-guide/).

## TL;DR

- Scrape the Collector's internal metrics first and track CPU seconds per accepted span, because that single ratio tells you whether a change helped.
- Move batching from the deprecated `batch` processor into each exporter's `sending_queue.batch` block and re-check queue sizing, because the queue now holds unbatched requests.
- Tail-based sampling that keeps every error and slow trace plus a small percentage of the rest cuts trace volume sharply, but it needs memory sized to the decision window and all spans of a trace on the same Collector.
- Place `memory_limiter` first in every pipeline and set `GOMEMLIMIT` as a soft ceiling, so the Collector sheds load before the kernel OOM killer steps in.
- At scale, a two-tier setup with edge agents and a gateway tier, connected by the `loadbalancing` exporter routing on trace ID, keeps tail sampling correct and moves expensive work off application nodes.

## What Causes High CPU and Memory Usage in the OpenTelemetry Collector?

Most Collector overhead comes from five sources:

| Cause | What it costs | Fix in this guide |
|---|---|---|
| Many small export requests | CPU for serialization, network round trips | [Exporter batching](#1-replace-the-batch-processor-with-exporter-batching-sending_queue) |
| Exporting every trace | Bandwidth, backend ingest, Collector CPU | [Tail-based sampling](#2-reduce-trace-volume-with-tail-based-sampling) |
| Unused or high-cardinality attributes | Payload size, backend indexing and storage | [Cardinality control](#3-reduce-attribute-cardinality-in-the-otel-collector) |
| Scraping too often or scraping unused metrics | Constant receiver CPU | [Scrape intervals](#4-right-size-receiver-scrape-intervals-and-scrapers) |
| Expensive processors running on data that gets dropped | Wasted CPU and memory | [Processor order](#5-recommended-otel-collector-processor-order) |

Memory pressure is mostly about buffers: the exporter queue, the tail sampler's trace buffer, and Go's garbage collector letting the heap grow between collections.

## How to Monitor OpenTelemetry Collector Performance

Tuning without measurement is guesswork. The Collector emits its own Prometheus metrics, but many teams never scrape them.

### Enable Collector Internal Metrics

Expose the internal metrics endpoint in the `service.telemetry` block:

```yaml
service:
  telemetry:
    metrics:
      level: normal          # use "detailed" only while debugging; it adds more series
      readers:
        - pull:
            exporter:
              prometheus:
                host: 0.0.0.0
                port: 8888
```

### Key Collector Metrics and PromQL Queries

Establish a baseline before you change anything. Depending on your Collector version, counters may or may not carry the `_total` suffix, so check `:8888/metrics` for the exact names.

```promql
# CPU consumption (cores)
rate(otelcol_process_cpu_seconds_total{job="otel-collector"}[5m])

# Memory (RSS)
otelcol_process_memory_rss{job="otel-collector"}

# Spans accepted per second
sum(rate(otelcol_receiver_accepted_spans_total[5m]))

# Spans refused by receivers (memory_limiter back-pressure); should be zero
sum(rate(otelcol_receiver_refused_spans_total[5m]))

# Queue saturation: 1.0 means the exporter queue is full
otelcol_exporter_queue_size / otelcol_exporter_queue_capacity

# Export failures and spans that could not be queued; non-zero means data loss
sum(rate(otelcol_exporter_send_failed_spans_total[5m]))
sum(rate(otelcol_exporter_enqueue_failed_spans_total[5m]))

# Efficiency ratio: CPU seconds per accepted span
sum(rate(otelcol_process_cpu_seconds_total{job="otel-collector"}[5m])) /
  sum(rate(otelcol_receiver_accepted_spans_total[5m]))
```

The efficiency ratio is the number to track through this guide. Each optimization below should move it down. The refused, send-failed, and enqueue-failed series should stay at zero; anything above that is telemetry you are losing. For a complete pipeline health dashboard built on these metrics, see the [pipeline health section of our Kubernetes logging at scale guide](/blog/monitor-kubernetes-logs-at-scale/).

---

## 1. Replace the Batch Processor with Exporter Batching (sending_queue)

Sending small amounts of telemetry often means more serialization work, more export requests, and more network overhead. Batching groups telemetry before it is sent, spreading that fixed cost across larger payloads.

### Batch Processor vs Exporter Batching

The standalone `batch` processor was the standard way to do this. The OpenTelemetry project has [deprecated the batch processor](https://opentelemetry.io/blog/2026/collector-batching-migration/) and moved batching into each exporter's `sending_queue.batch` block, so buffering, batching, and retries live together and can be tuned per destination. The `sending_queue` configuration has been stable since around v0.126.0; the project plans to enable exporter batching by default in v0.171.0 and to remove the batch processor from the core distributions in v0.177.0.

```yaml
exporters:
  otlp:
    endpoint: "collector-gateway.observability:4317"
    compression: gzip
    sending_queue:
      enabled: true
      sizer: items          # size the queue in spans/points/records, not requests
      queue_size: 100000
      num_consumers: 10
      batch:
        enabled: true
        min_size: 8192       # flush when 8192 items are ready
        flush_timeout: 5s    # or after 5 seconds, whichever comes first

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter]   # no batch processor
      exporters: [otlp]
```

### Sizing queue_size After Migration

This is the part of the migration that catches teams out. With the old setup, the `batch` processor sat in front of the exporter queue, so each queue slot held an already-batched request. With exporter batching, the queue sits in front of the batcher and holds raw incoming requests. The default `sizer` counts requests, so a burst of 1,000 single-span requests fills 1,000 slots. Switching to `sizer: items` makes `queue_size` track actual data volume, which is far easier to reason about.

`flush_timeout` keeps low-traffic services exporting promptly instead of waiting for `min_size` to fill. Larger batches are not automatically better: they raise buffering memory and can add export latency. Treat these values as a starting point and compare the efficiency ratio before and after.

---

## 2. Reduce Trace Volume with Tail-Based Sampling

Not every successful request needs a stored trace. Exporting all of them costs bandwidth, Collector resources, and backend capacity, especially at high throughput.

### Head-Based vs Tail-Based Sampling

Head-based sampling decides when the trace starts, cheaply, but without knowing whether the request will fail or be slow. Tail-based sampling buffers spans until a decision window expires, so it can keep errors and slow requests while discarding routine traffic. Our [head-based vs tail-based sampling guide](/blog/head-and-tail-based-sampling/) compares the two in depth.

### Tail Sampling Policy Configuration

```yaml
processors:
  tail_sampling:
    decision_wait: 10s
    num_traces: 50000
    expected_new_traces_per_sec: 1000
    policies:
      - name: errors
        type: status_code
        status_code:
          status_codes: [ERROR]

      - name: slow-requests
        type: latency
        latency:
          threshold_ms: 2000

      - name: critical-services
        type: string_attribute
        string_attribute:
          key: service.name
          values:
            - payment-service
            - auth-service

      - name: default
        type: probabilistic
        probabilistic:
          sampling_percentage: 5

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, tail_sampling]
      exporters: [otlp]
```

Policies are combined with OR: a trace is kept if any policy matches. This config keeps every errored trace, every trace slower than 2 seconds, every trace from the payment and auth services, and 5% of the rest. At 1,000 traces per second, the probabilistic policy alone passes about 50 traces per second, and the error, latency, and critical-service policies add to that. If payment and auth carry a large share of your traffic, the kept volume will be much higher, so check `otelcol_exporter_sent_spans` after rollout.

### Tail Sampling Memory Sizing

Tail sampling is not free. The sampler holds spans in memory until `decision_wait` expires. At 1,000 traces per second, a 10 second window, and a 5 KB average trace, that is about 50 MB of buffer (1,000 × 10 × 5,000 bytes). Plan for 3 to 4 times that for spikes, and keep `num_traces` above traces per second × `decision_wait` (here 10,000) so traces are not evicted before a decision.

There is also a deployment constraint: all spans of a trace must reach the same Collector instance. If spans from one trace are spread across several Collectors, each one sees a partial trace and makes the wrong decision. The two-tier architecture in section 7 solves this.

---

## 3. Reduce Attribute Cardinality in the OTel Collector

Attributes add context such as hostname, OS, cloud region, and Kubernetes metadata. Each one also adds bytes to every span, metric point, or log record, and attributes with many unique values can be expensive to index and store. Our [high cardinality guide](/blog/high-cardinality/) explains why this matters for metrics, logs, and traces.

### Trim Resource Attributes

Two processors add most resource attributes. Keep both explicit:

```yaml
processors:
  resourcedetection:
    detectors: [env, system]   # only detectors that apply to this environment
    timeout: 2s
    override: false
    system:
      resource_attributes:
        host.name:
          enabled: true
        os.type:
          enabled: true
        # host.cpu.* attributes are disabled by default; leave them off

  k8sattributes:
    extract:
      metadata:
        - k8s.namespace.name
        - k8s.deployment.name
        - k8s.pod.name
        - k8s.node.name
      # avoid extracting every pod label and annotation
```

Two things to check. First, list only the detectors that match where the Collector runs: running cloud detectors (`ec2`, `gcp`, `azure`) in the wrong environment adds startup delay and no useful data. Second, review what is enabled beyond the defaults. Many attributes, such as the `system` detector's CPU details and EC2 instance tags, are opt-in, and they tend to get switched on during debugging and never switched off. In `k8sattributes`, extracting all pod labels and annotations is the most common source of payload bloat.

### Normalize High-Cardinality Span Attributes

URL paths with IDs, like `/users/83947` and `/users/19204`, create a unique attribute value per request. That matters when spans are turned into metrics (for example with the `spanmetrics` connector), where each value becomes its own time series, and it increases index size in most backends. Prefer the low-cardinality `http.route` attribute set by instrumentation. When an SDK does not set it, normalize the path in the Collector:

```yaml
processors:
  transform/normalize:
    error_mode: ignore
    trace_statements:
      - context: span
        statements:
          - replace_pattern(attributes["url.path"], "/users/\\d+", "/users/{id}")
          - replace_pattern(attributes["url.path"], "/orders/[a-f0-9-]{36}", "/orders/{uuid}")
          - truncate_all(attributes, 2048)
```

`url.path` is the current semantic convention name; older instrumentation may still emit `http.target`, so check what your SDKs send. `truncate_all` caps oversized attribute values, such as long SQL text in `db.query.text` (formerly `db.statement`), without deleting attributes you may need for debugging. If query text can contain sensitive literals, sanitize or drop it here. For filtering whole records rather than attributes, see [filtering logs at source in the OTel Collector](/blog/filter-logs-at-source-in-otel-collector/).

---

## 4. Right-Size Receiver Scrape Intervals and Scrapers

Scraping receivers such as `hostmetrics` poll on a fixed timer whether or not anything changed. The default `collection_interval` for `hostmetrics` is 1 minute, but teams often lower it to 10 or 15 seconds for everything to make dashboards look smoother, and the cost goes up across every node.

### Use a Fast Interval Only for Alerting Metrics

Keep the 1 minute default for most scrapers and run a second, faster instance only for the metrics that drive alerts. Make sure the two instances use different scrapers, so nothing is collected twice:

```yaml
receivers:
  hostmetrics:
    collection_interval: 60s
    scrapers:
      disk: {}
      filesystem: {}
      network: {}
      load: {}
  hostmetrics/fast:
    collection_interval: 15s
    scrapers:
      cpu: {}
      memory: {}

service:
  pipelines:
    metrics:
      receivers: [hostmetrics, hostmetrics/fast]
      processors: [memory_limiter]
      exporters: [otlp]
```

Running two named instances of the same receiver type is a useful Collector pattern. Here CPU and memory, which usually back alerts, refresh every 15 seconds, and slower-moving disk, filesystem, and network stats stay at 60 seconds.

### Exclude Filesystems and Metrics You Do Not Use

On Kubernetes nodes the `filesystem` scraper can report dozens of overlay, tmpfs, and kubelet volume mounts. Exclude them:

```yaml
receivers:
  hostmetrics:
    scrapers:
      filesystem:
        exclude_fs_types:
          fs_types: [tmpfs, overlay, squashfs, nsfs, autofs]
          match_type: strict
        exclude_mount_points:
          mount_points: ["/var/lib/kubelet/.*", "/run/.*"]
          match_type: regexp
```

Lower polling frequency means less temporal resolution. Pick each interval based on how quickly the metric changes and whether an alert depends on it.

---

## 5. Recommended OTel Collector Processor Order

The `memory_limiter` processor checks Go heap usage and refuses new data when it crosses its limit. If it is placed last, every other processor has already done its work (attribute enrichment, regex transforms, trace buffering) on data that is then refused. That CPU is wasted. The upstream recommendation is to put `memory_limiter` first in every pipeline.

![Processor pipeline order: memory_limiter last wastes work on refused data; memory_limiter first and tail_sampling before enrichment means enrichment only runs on kept spans](/assets/blog/opentelemetry-collector-performance-tuning/pipeline-processor-order.svg)

### Example Processor Chain for a Single-Tier Collector

Put `memory_limiter` first and `tail_sampling` before the transforms, so expensive processing only runs on spans the pipeline keeps:

```yaml
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors:
        - memory_limiter         # refuse early under pressure
        - tail_sampling          # drop most traces before transforms
        - resourcedetection      # resource attributes on kept spans
        - transform/normalize    # regex work only on kept spans
      exporters: [otlp]

processors:
  memory_limiter:
    check_interval: 1s
    limit_percentage: 80
    spike_limit_percentage: 20
```

This ordering is for a single Collector that runs on the same host as the workloads. In a two-tier setup, resource detection belongs on the edge agents (section 7), because a gateway would detect its own host instead of the host that produced the data.

### How memory_limiter Calculates Its Limit

`limit_percentage` is a share of the total memory available to the Collector. On Linux the processor reads the container's cgroup memory limit, and it falls back to the machine's total memory only when no cgroup limit is set. So on Kubernetes, always set `resources.limits.memory` on the Collector pod, or use `limit_mib` for a fixed value.

The `memory_limiter` is a protective mechanism, not a performance optimization. When it refuses data, receivers return errors and senders retry or drop, and you will see `otelcol_receiver_refused_spans` rise. If that happens regularly, add memory, reduce the tail sampler buffer, or scale out. Do not rely on the limiter as a steady-state control.

---

## 6. Tune GOGC, GOMEMLIMIT, and GOMAXPROCS for the Collector

The OpenTelemetry Collector is a Go application, and its memory behavior is governed by Go's garbage collector. With the default `GOGC=100`, a collection is triggered when the heap has grown 100% since the last one, so live data of 800 MB can let the heap reach about 1.6 GB before the next collection. If the container limit is 2 GiB, one traffic spike can be enough for an OOM kill.

### Recommended Go Runtime Environment Variables

```yaml
env:
  - name: GOMEMLIMIT
    value: "1638MiB"  # about 80% of a 2Gi container limit
  - name: GOGC
    value: "100"      # default; lower it only if memory, not CPU, is the bottleneck
  - name: GOMAXPROCS
    value: "2"        # match the CPU limit (not needed on Go 1.25+ builds)
```

| Variable | Value | Why |
|---|---|---|
| `GOMEMLIMIT` | ~80% of container limit | A soft limit: the GC runs more aggressively as the heap approaches it, so memory stays below the container limit during bursts |
| `GOGC` | `100` (default) | Lowering it (for example to `80`) keeps the heap smaller at the cost of more GC CPU |
| `GOMAXPROCS` | CPU limit | Caps how many threads run Go code at once, which avoids CFS throttling when the container has fewer CPUs than the node. Go 1.25 and later derive this from the container CPU limit automatically |

### Why GOMEMLIMIT Matters Most

`GOMEMLIMIT` is the most important of the three. It is a soft limit, not a hard ceiling: the Go runtime collects more often as the heap nears it, but it can still be exceeded if live data really needs more memory. Together with `memory_limiter`, it gives you two layers before the kernel OOM killer: `memory_limiter` starts refusing new data at its threshold, and the GC works harder to keep the heap under `GOMEMLIMIT`. The OOM killer becomes the last resort instead of the first.

---

## 7. Scale the Collector with a Two-Tier Agent-Gateway Architecture

A single tier of Collectors works well for smaller deployments. At scale, two problems appear that one tier cannot solve cleanly.

The first is tail sampling correctness. All spans of a trace must reach the same Collector instance for the decision to be accurate. With one Collector per node (a DaemonSet), a request that crosses services on different nodes produces spans on several Collectors, each with a partial view, so the sampler drops traces it should keep.

The second is resource efficiency. Running tail sampling, transforms, and persistent queues on every node is expensive, and application nodes are where you least want that overhead.

![OpenTelemetry Collector two-tier architecture: edge DaemonSet collectors add resource attributes and route by trace ID to a horizontally scaled gateway that runs tail sampling and a persistent queue before exporting to OpenObserve](/assets/blog/opentelemetry-collector-performance-tuning/two-tier-architecture.svg)

The edge tier (DaemonSet, one pod per node) receives spans, adds host and Kubernetes resource attributes while it still knows which node produced them, and forwards. The gateway tier (Deployment, horizontally scaled) does the stateful and expensive work: tail sampling, transforms, compression, and queuing to the backend. The edge uses the `loadbalancing` exporter, which routes by trace ID by default, so all spans of a trace reach the same gateway pod.

### Edge (Agent) Collector Configuration

```yaml
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
processors:
  memory_limiter:
    check_interval: 1s
    limit_percentage: 80
    spike_limit_percentage: 20
  resourcedetection:
    detectors: [env, system]
    timeout: 2s
    override: false
  k8sattributes:
    filter:
      node_from_env_var: K8S_NODE_NAME   # only watch pods on this node
    extract:
      metadata: [k8s.namespace.name, k8s.deployment.name, k8s.pod.name, k8s.node.name]
exporters:
  loadbalancing:
    routing_key: traceID
    protocol:
      otlp:
        tls:
          insecure: true     # use TLS between tiers in production
    resolver:
      k8s:
        service: otel-gateway.observability   # <service>.<namespace>
        ports:
          - 4317
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, resourcedetection, k8sattributes]
      exporters: [loadbalancing]
```

The `k8s` resolver watches the gateway Service's endpoints, so the edge service account needs RBAC permission to list and watch EndpointSlices in that namespace.

### Gateway Collector Configuration

```yaml
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
processors:
  memory_limiter:
    check_interval: 1s
    limit_percentage: 80
    spike_limit_percentage: 20
  tail_sampling:
    decision_wait: 15s
    num_traces: 100000
    expected_new_traces_per_sec: 2000
    policies:
      - name: errors
        type: status_code
        status_code:
          status_codes: [ERROR]
      - name: slow
        type: latency
        latency:
          threshold_ms: 3000
      - name: default
        type: probabilistic
        probabilistic:
          sampling_percentage: 5
  transform/normalize:
    error_mode: ignore
    trace_statements:
      - context: span
        statements:
          - replace_pattern(attributes["url.path"], "/users/\\d+", "/users/{id}")
exporters:
  otlphttp/openobserve:
    endpoint: "https://api.openobserve.ai/api/<your_org_id>"
    headers:
      Authorization: "Basic ${env:OPENOBSERVE_AUTH_TOKEN}"
      stream-name: default
    compression: gzip
    sending_queue:
      enabled: true
      sizer: items
      queue_size: 200000
      num_consumers: 20
      storage: file_storage
      batch:
        enabled: true
        min_size: 8192
        flush_timeout: 10s
extensions:
  file_storage:
    directory: /var/lib/otelcol/queue
service:
  extensions: [file_storage]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, tail_sampling, transform/normalize]
      exporters: [otlphttp/openobserve]
```

There is no `resourcedetection` on the gateway on purpose: a detector there would stamp the gateway's own host and node onto spans from every node.

### Persistent Queues with file_storage

The `file_storage` extension gives the gateway a persistent queue. Queued data written to disk survives a Collector process restart and a short backend outage: during an OpenObserve upgrade or a network blip, telemetry queues to disk and flushes when the backend is reachable again. To survive the pod being rescheduled to another node, mount `/var/lib/otelcol/queue` on a persistent volume, for example by running the gateway as a StatefulSet with a volume claim template. An `emptyDir` volume is lost with the pod.

### Autoscaling the Gateway on Queue Depth

Scale the gateway on queue saturation (`otelcol_exporter_queue_size / otelcol_exporter_queue_capacity`), not CPU alone. Queue depth is a leading indicator of back-pressure, while CPU tends to lag. Exposing it to a HorizontalPodAutoscaler needs a custom or external metrics adapter, such as KEDA or the Prometheus adapter.

Keep scaling events infrequent with a stabilization window. Every time the gateway scales, the `loadbalancing` exporter re-maps trace IDs to pods, so traces in flight during the change can be split across two gateways and sampled incorrectly.

The two-tier setup adds operational overhead: two Collector fleets to configure, upgrade, and monitor. If a single tier is working and you are not using tail sampling, it may not be worth it yet.

---

## OpenTelemetry Collector Performance Tuning Checklist

None of these changes require touching application code. Each one is a config change and a rolling restart.

| Area | Change | Expected effect |
|---|---|---|
| Exporter batching | Move from `batch` processor to `sending_queue.batch` with `sizer: items` | Fewer, larger export requests; predictable queue sizing |
| Trace volume | Tail sampling with error, latency, and probabilistic policies | Large cut in spans sent to the backend while keeping every error |
| Attribute cardinality | Explicit detectors and Kubernetes metadata, path normalization, truncation | Smaller payloads and fewer unique values to index |
| Receiver scraping | 1 minute default, fast instance only for alerting metrics, filesystem exclusions | Less receiver CPU per node |
| Processor ordering | `memory_limiter` first, sampling before transforms | No CPU spent on data that is refused or dropped |
| Go runtime | `GOMEMLIMIT` at ~80% of the container limit, `GOMAXPROCS` matched to CPU | Fewer OOM kills under bursts, less CPU throttling |
| Architecture | Edge agents plus gateway tier with trace ID routing | Correct tail sampling, persistent queuing off application nodes |

The size of each improvement depends on your workload: span size, attribute volume, processor complexity, and backend throughput. The efficiency ratio (CPU seconds per span) and the data loss metrics from the first section are your ground truth.

## Troubleshooting Common OTel Collector Performance Issues

| Symptom | Metric to check | Likely fix |
|---|---|---|
| Collector pod is OOMKilled | `otelcol_process_memory_rss` near the container limit | Set `GOMEMLIMIT`, put `memory_limiter` first, reduce `num_traces` or `decision_wait` |
| Senders get errors or retries | `otelcol_receiver_refused_spans` rising | Memory limiter is refusing data: add memory or scale out |
| Data loss during backend slowdowns | `otelcol_exporter_enqueue_failed_spans` non-zero, queue saturation at 1.0 | Raise `queue_size`, add `num_consumers`, add a persistent queue |
| High CPU with modest traffic | CPU seconds per span rising | Check batching, regex transforms, and scrape intervals |
| Error traces missing after sampling | Spans of one trace on several Collectors | Route by trace ID with the `loadbalancing` exporter |

## How to Send Tuned Collector Output to OpenObserve

[OpenObserve](https://openobserve.ai/opentelemetry/) ingests OTLP traces, metrics, and logs natively. Use `https://api.openobserve.ai/api/<your_org_id>` for OpenObserve Cloud, or `http://<host>:5080/api/default` for a self-hosted instance (OTLP over gRPC is served on port 5081). The [OpenTelemetry ingestion docs](https://openobserve.ai/docs/ingestion/traces/opentelemetry/) cover authentication and stream routing. For a gateway Collector, OTLP over HTTP with gzip passes through most corporate proxies and load balancers without special gRPC configuration:

```yaml
exporters:
  otlphttp/openobserve:
    endpoint: "https://api.openobserve.ai/api/<your_org_id>"
    headers:
      Authorization: "Basic ${env:OPENOBSERVE_AUTH_TOKEN}"
      stream-name: default
    compression: gzip
    timeout: 30s
    retry_on_failure:
      enabled: true
      initial_interval: 5s
      max_interval: 30s
      max_elapsed_time: 300s
    sending_queue:
      enabled: true
      sizer: items
      queue_size: 100000
      batch:
        enabled: true
        min_size: 4096
        flush_timeout: 5s
```

`retry_on_failure` handles transient errors such as a backend restart or a brief network issue. It backs off exponentially from 5 seconds, caps each wait at 30 seconds, and gives up on a batch after 300 seconds in total. Combined with the persistent queue from section 7, short outages no longer turn into data gaps.

Performance tuning the Collector is not a one-time exercise. As traffic patterns change, revisit the efficiency ratio regularly and adjust batch sizes, sampling rates, and replica counts. For more on the components used here, see the [OpenTelemetry Collector Contrib guide](/blog/opentelemetry-collector-contrib/).

## Frequently Asked Questions

### What is the OpenTelemetry Collector and why does it affect performance?

The OpenTelemetry Collector is a vendor-neutral service that receives, processes, and exports telemetry data (traces, metrics, and logs). It sits in the data path between your applications and your observability backend. When it is misconfigured it can consume excessive CPU and memory, add export latency, and drop telemetry under load, which affects both reliability and your infrastructure bill.

### How much CPU and memory does the OpenTelemetry Collector need?

It depends on span volume, processor chain complexity, and export settings, so there is no single number. Measure it with the Collector's own internal metrics (otelcol_process_cpu_seconds and otelcol_process_memory_rss) and track CPU seconds per accepted span. Batching, sampling, trimming attributes, and ordering processors correctly all lower that ratio.

### What is the difference between head-based and tail-based sampling in OTel?

Head-based sampling makes a keep or drop decision when a trace starts, so it is cheap but cannot consider what happens later in the trace. Tail-based sampling buffers spans until a decision window expires (decision_wait, often 10 to 30 seconds), then applies policies such as keeping every error trace and 5% of everything else. Tail sampling is more accurate but costs memory proportional to the traces it buffers.

### Is the OTel batch processor deprecated?

Yes. The OpenTelemetry project has deprecated the batch processor in favour of batching inside each exporter's sending_queue (sending_queue.batch). The processor still works during the deprecation period, but new deployments should configure batching on the exporter. Because the queue now sits in front of batching, it holds unbatched requests, so review queue_size and the sizer when you migrate.

### How do I monitor the OpenTelemetry Collector's own performance?

The Collector exposes internal Prometheus metrics, on port 8888 by default. Track otelcol_process_cpu_seconds (CPU), otelcol_process_memory_rss (memory), otelcol_receiver_accepted_spans (throughput), otelcol_receiver_refused_spans (back-pressure from the memory limiter), otelcol_exporter_queue_size against otelcol_exporter_queue_capacity (queue saturation), and otelcol_exporter_send_failed_spans (export failures). Scrape them into OpenObserve or any Prometheus-compatible backend.

### What GOGC and GOMEMLIMIT settings should I use for the OpenTelemetry Collector?

Set GOMEMLIMIT to roughly 80 to 90% of the container memory limit. It is a soft limit that makes Go's garbage collector work harder as the heap approaches it, which helps avoid OOM kills during bursts. Lowering GOGC below the default 100 trades extra CPU for a smaller heap; leave it at the default unless memory, not CPU, is your constraint. On Go 1.25 and later, GOMAXPROCS follows the container CPU limit automatically; on older builds, set it to match the CPU limit.

### How do I size memory for tail-based sampling in the OTel Collector?

Tail sampling holds spans in memory until the decision window expires. A rough estimate is memory ≈ new traces per second × decision_wait in seconds × average trace size. For 1,000 traces per second, a 10 second window, and 5 KB average traces, that is about 50 MB (48 MiB) for the buffer alone. Plan for 3 to 4 times that for spikes, and set num_traces above traces per second × decision_wait.
