Two-tier OpenTelemetry Collector gateway with the load-balancing exporter

A two-tier Collector gateway uses the load-balancing exporter to send every span of a trace to the same second-tier Collector, so tail sampling and other stateful processing produce correct results. This page covers routing keys, resolvers, the second-tier pool and the trade-offs to plan before you build.

On this page

Why a two-tier OpenTelemetry Collector gateway needs the load-balancing exporter

When you want tail sampling or another stateful step, the first tier of your gateway must send every span of a trace to the same second-tier Collector. The load-balancing exporter does this: it hashes a configured routing_key so that data from the same source reaches the same backend. Per the exporter's README, it consistently exports spans, logs and metrics this way, which is what makes tail-based sampling possible. Maturity differs by signal: the README lists it as beta for traces and logs and alpha for metrics, so confirm the status for each signal in the release you plan to run, using the load-balancing exporter README.

Teams usually need this design when a decision depends on seeing a whole trace at once, such as keeping only traces with errors or slow spans, or when a stateful processor must aggregate across requests. If spans of one trace can land on different gateway replicas, each replica sees only fragments and makes sampling decisions on incomplete data. A single gateway replica avoids the problem, and it is often enough when telemetry volume fits one instance, when no processor needs the complete trace, or when you can accept a single point of failure while you test. Sizing that single instance is a separate question covered in the memory and batching section.

Before you choose, confirm three things with your team: which signals need trace-level or stream-level state, how many gateway replicas you expect to run, and how much you can tolerate a change in routing when replicas are added or removed. Each of these affects how you set the routing key and the resolver. Treat the decision as a design choice you can revisit, and write down which processors depend on whole traces so that a later change to the tier layout is not made by accident.

How spans flow from agents through the load-balancing tier to the sampling pool

The diagram starts at application SDKs, which send spans to agent Collectors next to each workload. Agents forward to the first-tier Collectors running the load-balancing exporter, which read the list of backends from a resolver and use the configured routing_key to send every span of a trace to the same second-tier Collector. That gateway pool runs tail sampling and then exports to the storage backend. Check that each hand-off between tiers uses TLS and authentication, and that the routing key keeps all spans of a trace together.

Span path from SDKs to storage, with the tier boundaries and secured hand-offs marked.

How the routing key keeps every span of a trace on one Collector

The routing key is what makes the first tier work. The load-balancing exporter takes the value of the configured routing_key for each piece of telemetry, hashes it, and uses the result to pick one backend from the resolved pool. Because every span of a trace must reach the same second-tier Collector for tail sampling to see the whole trace, the key has to be the same for all of those spans. For traces, the trace ID is the natural choice, since every span in a trace carries it. Confirm the supported routing_key values for your exporter version in the load-balancing exporter README, because the set of accepted values is the part of the configuration most likely to change between releases.

When keys differ, spans of one trace fan out to different gateways. Each gateway then holds a fragment of the trace, so the tail sampling policy may evaluate an incomplete set of spans and keep or drop the wrong traces. Errors and slow requests can disappear simply because their root span landed elsewhere. The same split happens during a pool change. When a Collector is added or removed, the hash ring is recalculated and some trace IDs move to a different backend mid-trace, so spans that arrived before the change and spans after it end up on different machines. Illustratively, a trace whose first three spans went to gateway A and whose last two went to gateway B would be judged on partial data by both. Plan for this window by testing pool changes under realistic trace load in a staging environment and by checking how your sampling decisions behave during a rollout.

Before go-live, verify the key end to end. Send a set of test traces with known spans, confirm in the second tier that all spans of each trace arrive at one instance, and then scale the pool up and down while traffic runs to measure how many traces split. Keep the resolver's source of backend addresses stable, because churn in that list is the most common cause of mid-trace moves. Ask the implementation team to document which key is used for each signal, since the exporter routes logs and metrics by the same mechanism but with different maturity.

Which load-balancing exporter options fit which design

This table compares the main load-balancing exporter settings for a two-tier gateway: routing key, resolver, protocol, timeouts and queues, and TLS. Read each row for when the setting fits and what it costs you. Defaults differ by Collector version, so confirm them in the exporter README for the release you build.

SettingWhen it fitsMain trade-offWhat to confirm
routing_key: traceIDTail sampling and any processor that needs every span of a trace in one CollectorSpans of one trace all land on one backend, so a hot trace can concentrate load on a single second-tier CollectorConfirm the key options supported by your version and check the README for the default
routing_key: serviceStateful processing keyed on a service, such as per-service aggregation or metrics derived from tracesTraces that cross services are split across backends, so trace-level tail sampling will not see complete tracesConfirm that your chosen key matches the processing you plan in the second tier
Resolver: static endpointsSmall, fixed second-tier pools where addresses rarely change and you manage membership by handAdding or removing a backend means a configuration change and rollout on every first-tier CollectorConfirm how your version handles a backend that is removed while spans are in flight
Resolver: DNSSecond-tier Collectors behind a DNS name that changes as the pool scalesMembership depends on DNS refresh timing, so routing can briefly disagree across first-tier CollectorsConfirm the resolver's refresh interval and how a DNS failure is handled
Resolver: Kubernetes serviceSecond-tier Collectors run as a Kubernetes workload that scales with the clusterRequires RBAC permissions to read endpoints, and membership changes move trace ownership during scalingConfirm the required RBAC rules and the behavior during scale-out and scale-in
Protocol settings (OTLP)Standard OTLP gRPC or HTTP transport between tiers, with the protocol matching your receiversProtocol choice affects connection reuse, load distribution and debugging, and must match the second-tier receiverConfirm which protocol your second tier exposes and the README's settings for each
Timeout and retry settingsSecond-tier pools that can be slow during bursts or restarts without dropping data at the first tierLonger timeouts hold memory and queue capacity in the first tier, while shorter timeouts push more data into retriesConfirm defaults and size them against your memory limits and queue capacity
Sending queue settingsAbsorbing short backend unavailability while keeping ordering and routing intactA larger queue uses more memory and delays failure signals, and a full queue refuses dataConfirm queue options in your version and monitor queue size and refused-data metrics
TLS settingsEncrypted traffic between first-tier and second-tier Collectors inside a shared or untrusted networkCertificate issuance, rotation and trust bundles add operational work, and misconfiguration breaks routing silentlyConfirm certificate paths, the server name used for verification and your rotation process

Choosing a resolver for the second-tier pool

The load-balancing exporter needs to know which gateway Collectors form the second-tier pool, and the resolver decides how that list is built and refreshed. Each option trades setup effort against how quickly the first tier notices a change, and every choice affects whether spans of one trace keep landing on the same backend.

Static endpoint lists

The resolver is a fixed list of gateway addresses written into the first-tier configuration. It is the simplest option to reason about and to test, and it works well when the second tier is small and rarely changes. The risk is operational: adding or removing a gateway means editing and reloading every first-tier Collector, and a stale address can keep receiving routed spans after the backend behind it is gone. Confirm which resolver types your Collector version supports before you commit to a design.

DNS-based discovery

The resolver looks up a DNS name and treats each returned address as a pool member, so the second tier can grow or shrink without touching first-tier configuration. This fits gateways behind a stable service name in a VM or bare-metal estate. The risk is caching: DNS answers can lag membership changes, and a Collector that resolves once at startup may route to an address that no longer exists. Check how often the resolver re-queries, and test a scale-down while spans are in flight.

Kubernetes endpoint discovery

On Kubernetes, the resolver can follow the endpoints behind a headless Service, so pool membership tracks gateway pods as they start, stop or fail readiness. This is usually the right fit when the gateway runs in the same cluster. The risk is that a pod leaving the pool during a rolling update changes routing for traces already split across replicas. Confirm the RBAC the first tier needs to read endpoints, and confirm the resolver's behavior during a rollout in your Collector version.

Pool membership changes

When a gateway joins or leaves, the routing key maps some traces to a different backend, so spans of one trace can end up split between an old and a new gateway. Tail sampling then sees an incomplete trace and may keep or drop it on partial data. The risk grows with trace duration, because long traces span more of the membership change. Plan scale events for low-traffic windows, and measure how many traces are incomplete after each one.

Health and drain behavior

A resolver only controls which addresses are candidates. Whether a removed gateway gets its in-flight data before it stops depends on the Collector's shutdown and queue settings. A gateway that stops abruptly can lose queued spans even when routing is correct. Before going live, confirm how the first tier handles an unhealthy endpoint and how the gateway drains its sending queue during a planned stop, and test both with a controlled restart.

Verifying discovery in your environment

No resolver choice holds without testing against your own deployment. Run a controlled scale-up and scale-down while generating known traces, then check that each trace arrives complete at one gateway and that the exporter's logs and metrics reflect the membership change. Record which resolver, refresh interval and version you tested, because these behaviors differ across Collector releases. Ask your vendor or the component README which options are stable before you rely on them.

Load-balancing exporter README

Building the two-tier gateway step by step

This sequence takes a team from a confirmed Collector build to a verified two-tier gateway in which every span of a test trace reaches the same second-tier Collector, so tail sampling can make correct decisions.

  1. Confirm the distribution and version

    The platform engineer confirms that both tiers run the same contrib build of the OpenTelemetry Collector, pinned to one release, because the load-balancing exporter is a contrib component and must be present in the binary or image. Check the release notes for the load-balancing component's stability level, since it is beta for traces and logs and alpha for metrics. Verify the binary or image with the release's published checksums and SBOM before deployment. Done when both tiers report the same version and the component list includes the load-balancing exporter and the tail sampling processor.

  2. Deploy the second-tier pool with tail sampling

    The platform engineer deploys the second-tier Collectors first, so the first tier has valid destinations when it starts. Each instance receives OTLP, runs the tail_sampling processor with the policies your sampling design needs, and exports to your back end. Keep the pool's receivers bound to internal addresses and configure health checks. Done when each instance starts cleanly, its health endpoint responds, and a test span sent directly to one instance appears at the back end under the expected sampling decision.

  3. Configure the load-balancing exporter and resolver

    The platform engineer configures the first-tier Collectors with the load-balancing exporter. Choose a resolver that matches your environment, such as a static list of second-tier endpoints or a DNS name that returns every pool member, and set the routing_key to traceID so all spans of a trace go to one backend. Confirm the exact resolver and routing options in the component README before writing the configuration. Done when the first-tier logs show the expected set of backends discovered and no resolution errors appear.

  4. Set TLS and authentication between tiers

    The security engineer enables TLS on the OTLP connections between the first and second tiers, using certificates issued by your internal CA, and restricts the second-tier receivers so only first-tier Collectors can connect. Where your policy requires identity on the connection, use a Collector authenticator extension on the receiving side and the matching client extension on the exporting side, and confirm the supported options for your build. Store the configuration and any credentials securely. Done when a connection from an unauthorized client is refused and first-tier exports succeed over the encrypted, authenticated path.

  5. Scale the second tier and confirm membership changes

    The platform engineer adds a second-tier instance and then removes one, watching the first-tier resolver update its backend list. This shows whether your resolver picks up membership changes as expected in your environment. Trace routing is expected to shift for some traces when membership changes, so confirm how your sampling window handles traces that span a change. Done when the first tier logs the membership update and new exports reach the added instance without errors.

  6. Validate that one trace lands on one backend

    The engineer sends a set of test traces with several spans each through the first tier, then searches the second-tier instances or the back end for each trace ID. Every span of a given trace should appear on exactly one second-tier instance. Run the test with the full pool and repeat it after a membership change. Done when all spans of each test trace are found on a single instance, and the results are recorded as the baseline for the team's runbook.

Securing the link between Collector tiers

The first tier receives application telemetry and the second tier makes sampling decisions, so the connection between them carries complete, sensitive trace data. Each card below covers one control on that link: where servers listen, how traffic is encrypted and authenticated, how configuration is stored, and what is removed before data leaves the first tier.

Bind server components to localhost

Since Collector v0.110.0, server components bind to localhost by default instead of 0.0.0.0. Any receiver or exporter endpoint you set for the tier-to-tier link will override that default, so check every endpoint value in both tiers. Confirm which interfaces the second-tier receiver listens on and restrict them to the private network segment that the first tier uses. Verify with a port scan from a host outside that segment.

Collector security practices

Encrypt inter-tier traffic

Span data crosses the link in the clear unless you enable TLS on the OTLP receiver in the second tier and the load-balancing exporter in the first tier. Plan a certificate chain that both tiers trust, decide who issues and rotates the certificates, and confirm how the exporter validates server names when it resolves pool members. Test a certificate expiry in a staging pipeline so rotation failures show up before production.

Authenticate with authenticator extensions

Collector authenticator extensions can check incoming connections on receivers, for example with OIDC, and attach credentials to outgoing exporter requests, for example with the oauth2client extension. Decide whether the second tier should accept only requests from first-tier Collectors and how those Collectors obtain their identity. Confirm that the extension versions you deploy support the receiver and exporter types in your pipeline, because stability varies by component.

Collector configuration docs

Store configuration securely

Tier configuration often contains client secrets, token endpoints and certificate paths. Keep those values out of version control and inject them at runtime from a secrets store your platform already governs. Restrict read access to the Collector configuration file so that only the Collector's service account can open it. Review who can change the configuration, because a changed routing_key or resolver can silently move traffic.

Redact sensitive attributes in tier one

Run the redaction processor in the first tier so that sensitive span attributes, such as authorization headers, personal identifiers or query strings with tokens, are removed before data is forwarded. Removing them later in the second tier means the first tier has already sent them across the link and may have written them to its own logs. List the attribute keys your applications emit, test the rules on sample spans, and confirm that the routing key still resolves after redaction.

Questions teams ask before building a load-balanced gateway

How much effort does a two-tier load-balanced gateway take to design?

Design effort depends mostly on how many signals, sources and back ends the gateway must serve, and on how much stateful processing depends on trace routing. A team that only needs traces routed to one tail sampling pool has a small design. Adding logs and metrics, multiple regions or several back ends adds routing keys, resolver decisions and failure cases to work through. The first tier needs a clear answer for which attribute keeps each trace together, how the second tier is discovered, and what happens when pool membership changes. Ask any partner to show how each of these decisions is documented in the written scope before build work starts.

Can our own team build this without outside help?

A team with strong Collector experience and a clear owner can build it in-house, especially if the platform is small. The harder parts are usually not the YAML. They are agreeing on the routing key, sizing the second tier, testing behavior during pool changes, and keeping the configuration in version control with a review process. Outside help is most useful when the team has not operated stateful Collector pipelines before, or when the design must pass a security review and needs written evidence. Compare the cost of your engineers' time against a fixed-scope engagement that includes testing and handover documentation.

What does the design need from our platform and network teams?

The platform team provides the cluster or VM environment, the service discovery method used for the second tier, and the rules for how pods or hosts can reach each other. The network team confirms that first-tier Collectors can open connections to every second-tier Collector on the OTLP ports in use, and that traffic stays inside the approved network. Both teams also decide how Collector configuration is stored, who can change it, and how secrets for exporters are provided. Agree on these items early, because a firewall or DNS change can take longer to approve than the Collector work itself.

How long does validation take for a load-balanced gateway?

Validation time depends on the number of signals, the number of second-tier replicas, and how many failure scenarios the team must test. Plan separate test runs for normal routing, adding and removing a second-tier Collector, a resolver change, and a first-tier restart. Each run should confirm that spans of the same trace arrive at the same backend and that dropped data is visible in Collector metrics. Confirm the expected duration with your partner or internal team against your own environment, because no general duration applies to every platform.

Does tail sampling require this two-tier design?

Yes, if tail sampling runs in more than one Collector. Tail-based sampling needs all spans of a trace in one place before a decision can be made. A single gateway Collector can do this at low volume, but once several replicas receive traffic, spans of one trace can land on different replicas and the sampling decision becomes incorrect. The load-balancing exporter, configured with a routing key such as the trace ID, sends the spans of each trace to the same second-tier Collector. If your volume fits one tail sampling instance with headroom, a single tier may be enough, so check that before adding a tier.

How do we scale the second tier as traffic grows?

Scale the second tier by adding Collector replicas and making sure the first tier learns about the change through its resolver. Routing changes move some traces to a new backend, so any trace that is partway through sampling can be split across two Collectors for a short period. Plan for this by sizing tail sampling windows, watching queue and memory metrics on each second-tier Collector, and choosing a resolver method that matches your environment. Review the load-balancing exporter documentation for the resolver options it supports, and confirm the behavior of your chosen version in a test environment before relying on it in production.

What should a quote for this work include?

A quote should follow directly from a written scope. It should list the signals in scope, the number of first-tier and second-tier environments, the routing key and resolver method, the sampling and processing rules that run in the second tier, the test scenarios, and the handover documentation. It should also state what the client provides, such as cluster access, network approvals and Collector backend access, and whether any ongoing support or upgrade retainer is included. Ask for one-time costs and recurring costs to be shown separately. DeployOpen does not publish a price list, so the quote is the place to compare scope against your own estimate.

Limits to confirm in your environment before you commit

The load-balancing exporter sits in the first tier of a two-tier gateway, so its maturity, version pinning, resolver behavior and capacity all shape whether tail sampling stays correct. Each card below names one limit and the check to run before you commit to a design.

Beta maturity for traces and logs

The load-balancing exporter is beta for traces and logs, so routing behavior and configuration keys can change between releases. Ask the OpenTelemetry maintainers and your own platform team which parts of the exporter your design depends on, and record that list. Then decide who owns the risk if a behavior changes during a planned upgrade, and whether a rollback path exists for the first tier.

Traces and logs maturity
Beta
Exporter README

Alpha maturity for metrics

Metrics routing through the load-balancing exporter is alpha, which makes it a weaker basis for production than trace routing. If your design also needs metrics to reach the same backend as their related traces, plan that path separately and test it before relying on it. Confirm the status with the maintainers and in the component README for the exact version you deploy.

Metrics maturity
Alpha

Pinning a Collector release

Because the component is changing, pin the Collector version and the contrib distribution you test with, then promote that exact version through your environments. Select the release from the official releases page, check its signed artifacts, checksums and SBOM files, and record the version in your deployment manifests. Ask who approves each version bump and whether the change needs a new round of routing tests.

Collector releases

Resolver behavior during pool changes

The resolver decides which second-tier Collectors the first tier knows about, and that list changes during scaling, restarts and failures. During a pool change, traces for one trace ID can briefly split across backends if the ring moves, which breaks tail sampling for those traces. Test scale-out, scale-in and a single-pod restart under load, and measure how many traces arrive incomplete. Confirm with your resolver's documentation how fast membership updates propagate.

Load and memory testing the first tier

The first tier handles every span before routing, so its CPU and memory set the capacity of the whole gateway. Run load tests that match your real span rate, attribute size and burst pattern, and watch memory, queue depth and refused-data signals on each first-tier instance. Ask the team that will operate the gateway what limits they will set and who gets paged when they are hit, then rerun the test after any configuration change.

Collector configuration

Routing key and trace completeness

The routing key determines whether all spans of a trace land on the same second-tier Collector, so a key that is missing on some spans breaks tail sampling silently. Confirm which attribute or field your routing key uses, check that every service sets it, and build a test that sends a multi-service trace and verifies that all its spans reach one backend. Treat this check as a release gate for any new service that joins the pipeline.

Operating the tiers after go-live

Watch the two tiers with different questions. On the first tier, the load-balancing exporter is the component that decides where each trace goes, so the signals to track are the exporter's send failures and retries, the backend the resolver returns, and any spans that fail to reach a second-tier Collector. On the second tier, watch the processors that hold state, such as tail sampling, along with memory use, refused data from the memory_limiter and queue saturation on the exporters that ship to the back end. Confirm in the Collector's own telemetry which metric names and levels your release exposes, since the exact set changes between versions.

Scaling the second tier is safe for new traces but can split a trace that is already in progress. When a Collector joins or leaves the pool, the resolver changes the ring, and spans for a trace that was routed to one backend may land on another, so tail sampling sees only part of the trace. Plan pool changes for low-traffic windows where possible, and check the routing key and resolver settings in the first-tier configuration before each change. Scaling the first tier is less risky for affinity, but every first-tier replica must use the same routing key and the same resolver view of the pool, or two first-tier Collectors may route the same trace to different places.

Sequence upgrades from the back of the pipeline to the front: second tier first, then first tier, then agents. Because the load-balancing exporter is beta for traces and logs and alpha for metrics, read the release notes of each Collector version for changes to its configuration keys before you bump it. After every release, test the same checks on a staging pool: that a multi-span trace arrives at a single second-tier Collector, that tail sampling decisions match the previous version for a fixed set of test traces, that the resolver updates when a replica is added or removed, and that the refused-data and queue metrics still report. Keep the previous release available so you can roll back a tier without changing the other.

How DeployOpen scopes and delivers a two-tier Collector gateway

DeployOpen plans and builds the two-tier gateway inside your own infrastructure, starting from the trace flows, routing key and back-end pool you need. Each engagement is fixed-scope, with scope, deliverables and timelines agreed in writing before work starts, and the result is documented so your team can run it.

How we scope

  • We map which services emit spans, which trace keys must stay together, and which back ends receive them.
  • We agree the routing key, resolver type and second-tier pool layout with your platform and security owners.
  • The written scope names the Collector distribution, component stability levels and the tail sampling policies covered.

How we build

  • We deploy the first-tier load-balancing exporter and second-tier gateway pool in the clusters or hosts you control.
  • We configure the resolver, routing key and endpoint TLS and authentication, and test that all spans of a trace land on one gateway.
  • We test failover, pool scale-out and scale-in, then retest the routing after each Collector release upgrade.

How we hand over

  • You receive the configuration, deployment manifests and a runbook covering routing, resolver changes and pool scaling.
  • We document the verification checks, the metrics to watch for dropped or refused spans and the known limits of beta components.
  • Handover includes a walkthrough with your engineers so they can change routing keys and pool sizes without us.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • Retainers can cover Collector release upgrades, component stability reviews and retesting after topology changes.
  • Ask us to confirm in the quote which upgrade and testing tasks are included and how often they recur.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.