Cloud & infrastructure

Fixing OpenTelemetry metrics and measuring eBPF overhead in production

STCLab engineers corrected misleading OpenTelemetry metrics by adjusting collector pipelines and measured the CPU cost of three eBPF instrumentation layers on a C daemon.

Illustration of data flowing through observability pipelines with measurement points
Illustration generated for this article

Engineers at STCLab refined their observability platform to correct inaccurate metrics and quantify the performance impact of eBPF tools. Published in December 2026, the case study details how the team fixed data discrepancies in their OpenTelemetry gateway and evaluated three different eBPF instrumentation layers for a compiled C daemon.

What happened

The team previously built an observability stack using OpenTelemetry and an LGTM backend, later adding an AI agent called HolmesGPT to investigate alerts. They discovered two critical gaps: some dashboard numbers were incorrect, and certain workloads lacked request telemetry entirely. The first issue emerged when their gateway Collectors, scaling from 3 to 20 replicas behind a Kubernetes Service, produced conflicting data. The service graph reported one API handling 6,801 requests per second, while the application SDK reported only 26.2.

The discrepancy stemmed from multiple replicas writing to the same cumulative counter series without unique labels. This caused Prometheus-style rate functions to interpret interleaved writes as repeated resets. Additionally, span metrics were generated after tail sampling, meaning the RED metrics reflected only kept traces rather than all served traffic. To fix this, the team split the gateway into two stages within the same pods. Stage 1 adds Kubernetes metadata and routes spans by trace ID to a single pod. Stage 2 fans spans out to two pipelines: one builds the service graph before sampling, and the other handles tail sampling and export.

The second part of the work focused on instrumenting a traffic-control core written in C. Instead of modifying the source code, the team tested three eBPF-based tools to measure their CPU overhead and coverage. They evaluated Cilium Hubble for network flows, OpenTelemetry eBPF Instrumentation (OBI) for HTTP requests, and Inspektor Gadget for deep inspection. Each tool was measured against a development copy of the daemon under production CPU limits to determine viability for high-traffic paths.

How it works

To resolve the metric inaccuracies, the team implemented a two-stage trace path. Every multi-writer series now includes a stable writer label derived from the StatefulSet pod name, allowing queries to sum over writers correctly. Span metrics are generated using a load-balancing exporter keyed by service and span name before any sampling occurs. This ensures that metric rates match received spans within 1%. The team also addressed cardinality issues by replacing full object-storage URLs in span metrics with route identifiers, reducing active series by 35% after cleanup.

For eBPF instrumentation, the team measured overhead directly inside the application’s cgroup to capture the true cost to the daemon. OBI converts HTTP traffic into spans but increases CPU time per request by 25% at 2,400 requests per second, primarily due to header tracking for trace context. Sampling does not reduce this cost because probes execute on every request. The team also found that OBI and access logs miss kernel queue wait times, as they start timing on socket read. In contrast, Inspektor Gadget’s TCP tracer detected stalls that other tools missed, though it added 11% CPU overhead.

Key details

  • Multiple collector replicas writing to the same counter series without unique labels caused Prometheus rate calculations to fail.
  • Generating span metrics before tail sampling ensures RED metrics reflect all served traffic, not just sampled traces.
  • OpenTelemetry eBPF Instrumentation increased CPU time per request by 25% on a C daemon, largely due to header tracking.
  • eBPF probes run in application threads, so overhead must be measured inside the app’s cgroup, not just on the agent.
  • Tools like OBI and access logs may miss kernel queue wait times, leading to inaccurate latency measurements during stalls.
  • Inspektor Gadget’s TCP tracer added 11% CPU overhead but successfully identified connection stalls missed by other layers.

Why it matters

Accurate telemetry is foundational for reliable automated investigations. When an AI agent like HolmesGPT acts on data, incorrect numbers can lead to confident but wrong conclusions. By ensuring metrics reflect actual traffic and correcting counter resets, teams prevent false alerts and misdirected debugging efforts. This is especially critical as observability platforms increasingly rely on automated agents to triage incidents before human engineers intervene.

Understanding the precise cost of eBPF instrumentation allows teams to make informed trade-offs between visibility and performance. While eBPF offers deep insights without code changes, it is not free. High-traffic cores may suffer significant throughput reductions if instrumentation is applied indiscriminately. Measuring overhead in production-like conditions helps teams decide which tools to run continuously and which to reserve for incident response.

What you can do

  • Add stable writer labels to all multi-writer metric series and sum over them in queries to prevent reset artifacts.
  • Generate service graph and RED metrics before applying tail sampling to ensure they represent total traffic volume.
  • Audit metric cardinality regularly and replace high-cardinality dimensions like full URLs with lower-cardinality identifiers.
  • Measure eBPF tool overhead inside the application’s cgroup to account for the CPU cost imposed on the target process.
  • Test instrumentation tools against known failure modes, such as process freezes, to identify blind spots in timing logic.
  • Restrict heavy eBPF tools like CPU profilers to non-production environments unless binaries include symbols and frame pointers.
  • #opentelemetry
  • #ebpf
  • #observability
  • #kubernetes
  • #performance

Tools from the Bytechap store

Keep reading

All stories