DevOps

Tuning OpenTelemetry for Flaky Nigerian Networks: File-Based Disk Buffering and 84% Egress Reductions in Production

C
Chidi OkekeVP of Frontend Engineering
October 29, 20268 min read
Tuning OpenTelemetry for Flaky Nigerian Networks: File-Based Disk Buffering and 84% Egress Reductions in Production

When high latency and intermittent fiber cuts destroyed a client's telemetry stream, standard cloud setups failed. Here is how we configured OpenTelemetry Collector with file-storage buffering and tail sampling to survive local network outages.

Most observability guides assume your application server sits in an AWS region with 99.999% network uptime and sub-5ms fiber latency to your telemetry backend. That assumption breaks down completely when you deploy infrastructure in or close to West African edge environments.

During a recent agency engagement with a high-volume agency banking platform operating across Lagos, Ibadan, and Port Harcourt, we ran into a massive observability bottleneck. The system processed thousands of POS terminal requests, card switches, and local transfer webhooks per minute across distributed node clusters hosted on regional virtual private servers.

Every time a local fiber link dropped or packet loss on upstream telco backhauls spiked to 35%, our observability setup crumbled. Traces vanished right when incidents occurred. Application memory bloated as internal logging buffers filled up. To make matters worse, when connection restored, the uncompressed flood of retried spans burned through gigabytes of egress bandwidth, resulting in an astronomical cloud observability bill.

Default cloud configurations do not work here. We had to rethink our telemetry collection pipeline from scratch. Here is how we redesigned our observability pipeline using the OpenTelemetry Collector with file-backed persistent disk queues and dynamic tail-based sampling.

The Situation: Telemetry Black Holes and $1,800 Monthly Ingress Bills

The platform architecture consisted of 14 Go and Node.js microservices handling transaction processing, identity checks, and ledger entries. Originally, these services pushed telemetry directly via HTTP/JSON to a managed Datadog endpoint in Europe (eu-west-1).

When internet routing degraded—a common occurrence during peak afternoon hours on Nigerian ISP networks—three distinct failure modes surfaced simultaneously:

  1. Application Latency Degradation: Node.js backend processes spent precious event-loop cycles retrying telemetry HTTP requests. Socket timeouts clogged memory, spiking p99 API response times from 320ms to over 4,500ms.
  2. Total Blind Spots During Outages: To protect core API throughput, engineers set short 2-second timeout limits on trace exports. When a telco fiber cut severed connection to Europe for 40 minutes, the application dropped 100% of its traces. The engineering team was completely blind during critical outages.
  3. Runaway Egress Costs: When connections flickered back on, services dumped uncompressed JSON payloads across public internet routes. The platform was generating over 1.4 Terabytes of raw telemetry egress monthly, inflating cloud provider egress fees and telemetry ingestion costs to over $1,800/month for a startup with under 50,000 active users.

We needed an architecture where telemetry submission from the main app thread was local, non-blocking, resilient to 12-hour network outages, and dramatically cheaper.

What Failed: Why Standard Cloud-Native Defaults Fall Apart on African ISPs

Before settling on a persistent collector configuration, we attempted two standard fixes recommended in traditional DevOps literature.

Attempt 1: In-Memory Collector Buffering

We deployed an OpenTelemetry Collector sidecar instance on each node, routing application traffic to localhost:4317 over gRPC. We configured the standard batch processor alongside a memory_limiter processor.

This solved the application latency problem because local gRPC exports returned in less than 1ms. However, it created a severe operational failure during sustained network outages. When upstream networks remained down for more than 15 minutes, the collector's in-memory queue hit its 512MB RAM cap. The memory_limiter dropped all incoming spans. The exact spans needed to debug why local transaction webhooks were failing—much like the edge API dropped connections detailed in our post on Telco API Failures in Nigeria: Ditch Celery for a Go Transactional Outbox Engine—were wiped from memory.

Attempt 2: Head-Based Sampling at the SDK Level

Next, we enabled 10% head-based probabilistic sampling in the OpenTelemetry SDKs. The logic seemed sound: emit 90% fewer spans to reduce bandwidth and memory usage.

This was a disaster. Because sampling decisions were made at the start of a request, the collector dropped 90% of overall traffic uniformly. When a payment gateway returned a 500 internal server error or timed out after 30 seconds, 9 times out of 10 the corresponding error trace was discarded before it was ever captured. We saved network bandwidth at the cost of rendering telemetry useless for debugging.

| Approach | Resiliency to Outages | Egress Efficiency | Critical Error Retention | App Performance Impact | | :--- | :--- | :--- | :--- | :--- | | Direct SDK -> Managed SaaS | Very Low | Extremely Poor | High (if network is up) | Severe (Socket blocking) | | In-Memory OTel Collector | Low (Max 10-15 mins) | Moderate | High (until RAM fills) | Excellent (<1ms local gRPC) | | Head-Sampled SDK (10%) | Low | Good | Extremely Poor (drops 90% errors) | Excellent | | File-Storage OTel Collector + Tail Sampling | High (12+ hours) | Excellent (84% reduction) | 100% Error Retention | Excellent |

The Architecture: File-Backed Queues and Tail Sampling at the Edge

To build a system that survived sustained network drops without losing diagnostic data, we decoupled telemetry generation from telemetry transmission using a two-tier collector topology.

  1. Edge Node Collector (Local VPS): Runs alongside application containers on cheap Linux VPS instances. Receives raw, unsampled traces over loopback (127.0.0.1:4317).
  2. Disk-Backed Queueing: Instead of relying on volatile RAM, the local collector uses the file_storage extension to persist queued OTLP payloads directly to local NVMe storage.
  3. Tail-Based Sampling Processor: Evaluates full trace sequences in local collector memory after requests complete. Retains 100% of trace trees containing errors, HTTP status codes >= 400, or latencies exceeding 800ms, while discarding 98% of mundane 200 OK health checks.
  4. Zstd-Compressed OTLP Export: Batches surviving traces and compresses them with Zstd before pushing them to an offshore self-hosted Grafana Tempo backend.

Similar to the infrastructure savings we achieved when Replacing AWS EKS with Nomad and WireGuard on Hetzner, keeping local telemetry processing lightweight allows inexpensive edge VPS nodes to handle heavy operational workloads without burning money on cloud managed services.

OpenTelemetry Collector Architecture showing local file storage queueing and tail sampling pipeline

Production Configuration and Benchmarks

Here is the exact otel-collector-config.yaml deployed across our edge instances. It uses official components from the OpenTelemetry Collector Contrib repository.

Neobot Engineering Standard

Every system deployed by Neobot Tech incorporates enterprise baseline practices. We continuously audit our database topologies, REST API query paths, and frontend modular bundles to prevent latency spikes and ensure top-tier security posture.

Tags:#DevOps#OpenTelemetry#Grafana#Observability#Infrastructure#Go

Discussion

Comments Coming Soon

We are currently migrating our discussion engine to a new real-time database schema. Check back shortly to join the conversation.