DEV Community

Cover image for Milestone 4 Complete — OTLP HTTP Exporter for Heka Insights Agent
Farhan Munir
Farhan Munir

Posted on

Milestone 4 Complete — OTLP HTTP Exporter for Heka Insights Agent

In this milestone, I completed the OTLP HTTP exporter implementation for Heka Insights Agent and validated it with both unit tests and Docker-backed integration tests.

Repo: https://github.com/ronin1770/heka-insights-agent

What was implemented in Milestone 4

Milestone 4 includes:

  • OTLP HTTP exporter wiring
  • OTLP metric payload mapping
  • OTLP auth header support
  • OTLP resource attribute mapping
  • Retry/backoff behavior for transient failures
  • Unit test coverage for config + sender + exporter + mapping
  • Docker integration tests against a real OpenTelemetry Collector

Configuration added

OTLP configuration is environment-driven through .env:

LOG_LOCATION=./log/heka_agent.log
CPU_POLL_INTERVAL_SECONDS=10
EXPORTER_TYPE=otlp_http
OTLP_HTTP_ENDPOINT=http://localhost:4318/v1/metrics
OTLP_HTTP_HEADERS=key=Bearer abcd1234
OTLP_RESOURCE_ATTRIBUTES=service.name=heka-insights-agent,host.name=localhost
OTLP_HTTP_TIMEOUT_SECONDS=10
OTLP_HTTP_RETRY_MAX_ATTEMPTS=5
OTLP_HTTP_RETRY_INITIAL_BACKOFF_SECONDS=1
OTLP_HTTP_RETRY_MAX_BACKOFF_SECONDS=5
Enter fullscreen mode Exit fullscreen mode

Notes

  • OTLP_HTTP_HEADERS format: key=value,key2=value2
  • OTLP_RESOURCE_ATTRIBUTES format: key=value,key2=value2
  • Retryable failures:
    • transport errors
    • HTTP 408, 429, and 5xx
  • Non-retryable failures:
    • HTTP 400, 401, 403, 404, and similar client-side errors

Unit tests

Unit tests cover:

  • OTLP env parsing and validation
  • OTLP payload mapping
  • OTLP HTTP sender behavior
  • Retry/backoff behavior
  • Exporter initialization and wiring

Run unit tests:

PYTHONPATH=src python3 -m unittest discover -s tests -v
Enter fullscreen mode Exit fullscreen mode

Unit test output

Ran 27 tests in 0.008s

OK
Enter fullscreen mode Exit fullscreen mode

Integration tests (Docker + real collector)

Integration tests validate:

  • auth success (200)
  • auth reject path (401) and no retry on non-retryable status
  • no-auth collector path

Run OTLP integration tests:

RUN_OTLP_INTEGRATION=1 PYTHONPATH=src python3 -m unittest -v tests.test_otlp_http_integration
Enter fullscreen mode Exit fullscreen mode

Integration test output

test_auth_rejected_without_retry_for_401 ... ok
test_auth_success_with_bearer_header ... ok
test_no_auth_collector_accepts_without_headers ... ok

----------------------------------------------------------------------
Ran 3 tests in 2.417s

OK
Enter fullscreen mode Exit fullscreen mode

Collector config used in tests

The project includes collector fixtures under tests/fixtures/otlp/, including auth-required and no-auth variants for scenario testing.


Final result

Milestone 4 now has:

  • working OTLP HTTP exporter
  • production-style config controls
  • retry/backoff logic for transient failures
  • unit + integration test coverage
  • updated docs and run instructions

Repo again: https://github.com/ronin1770/heka-insights-agent

Top comments (0)