• /
  • EnglishEspañolFrançais日本語한국어Português
  • EntrarComeçar agora

HAProxy distributed tracing with OpenTelemetry

|View as Markdown (English)

See HAProxy as a connected hop in your distributed traces, not just a black box between services. HAProxy 3.4 and later includes an OpenTelemetry filter that lets your load balancer participate directly in distributed traces, so New Relic can automatically map service relationships between your applications and the HAProxy entity in service maps — no manual configuration required.

This page shows you how to configure the HAProxy OTel filter, its exporter, and the OTel Collector so trace data reaches New Relic. For a look at how tracing works under the hood — extracting and propagating W3C Trace Context through HAProxy — see How it works below.

How it works

In a typical setup, traffic flows like this:

Instrumented app (frontend) → HAProxy (with OTel filter) → Instrumented app (backend)
  1. The frontend application sends a request with a W3C traceparent header.
  2. HAProxy's OTel filter extracts the trace context, creates spans covering the request lifecycle, and injects updated trace context into the request forwarded to the backend.
  3. The backend application receives the request with the propagated trace context and continues the trace.
  4. The frontend, HAProxy, and backend export their spans to an OpenTelemetry Collector, which forwards them to New Relic.

New Relic uses these connected spans to create CALLS relationships:

  • Frontend service CALLS HAProxy entity
  • HAProxy entity CALLS Backend service

These relationships are visible in service maps and the maps experience.

Before you begin

The HAProxy OTel filter works with any application that supports W3C Trace Context propagation, including:

  • OpenTelemetry SDK instrumented applications (any language)
  • OpenTelemetry auto-instrumentation (Java, .NET, Python, Node.js)
  • New Relic APM agents (Go, Java, .NET, Node.js, Python, Ruby, PHP) with distributed tracing enabled

You can mix instrumentation approaches. For example, an OTel SDK frontend can call through HAProxy to a New Relic APM agent backend, and the relationship chain appears correctly in New Relic.

Ensure you also have:

  • Valid New Relic license key
  • HAProxy 3.4 or later with the OTel filter enabled. Refer to the HAProxy OTel installation guide for instructions on obtaining a distribution with OTel filter support.
  • OpenTelemetry Collector (OTel Collector Contrib or NRDOT) running on the same host or accessible from the HAProxy host
  • Instrumented applications sending requests through HAProxy, using any of the compatible instrumentation approaches listed above
  • Network access from the collector to New Relic's OTLP endpoint

Dica

This guide sets up both metrics collection and distributed tracing in a single OTel Collector. For advanced metrics configuration or Kubernetes deployment, see Monitor self-hosted HAProxy and Monitor HAProxy on Kubernetes.

Set up distributed tracing

Dica

The traces pipeline below is the same standard setup you would use for any service participating in distributed tracing — not a manual relationship configuration. Once tracing is active, New Relic automatically detects the connected spans and creates service relationships. There is no additional configuration needed for relationships to appear.

View your service relationships

Once HAProxy and the collector are running, generate some traffic through your instrumented applications. After a few minutes, verify data is arriving in New Relic:

-- Verify HAProxy trace spans
FROM Span SELECT count(*)
WHERE service.name = 'YOUR_HAPROXY_SERVICE_NAME'
SINCE 10 minutes ago
-- Verify HAProxy metrics
FROM Metric SELECT count(*)
WHERE metricName LIKE 'haproxy.%'
SINCE 10 minutes ago

After trace data is flowing, New Relic automatically creates CALLS relationships between your services and the HAProxy entity. It may take up to 10 minutes for relationships to appear.

Follow these steps to view the relationships:

  1. Go to one.newrelic.com > All capabilities > All entities.
  2. Search for your HAProxy entity or one of your instrumented services.
  3. Select an entity to open its summary page.
  4. Click Service map to see the entity relationship graph.

You should see your frontend services connected to HAProxy, and HAProxy connected to your backend services:

[Frontend app] → CALLS → [HAProxy] → CALLS → [Backend app]

You can also query relationships with NRQL:

FROM Relationship SELECT *
WHERE source.entityName = 'YOUR_HAPROXY_SERVICE_NAME'
OR target.entityName = 'YOUR_HAPROXY_SERVICE_NAME'
SINCE 1 day ago

Troubleshooting

Next steps

Copyright © 2026 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.