Skip to content
Latchkey

Zipkin reporter "failed to report spans" on port 9411 in CI

A Zipkin reporter posts encoded spans to http://localhost:9411/api/v2/spans. When no Zipkin server runs in CI, the connection is refused; depending on the client, spans are dropped or the reporter logs an error each flush.

What this error means

Logs show "Dropped ... spans" or "failed to report" / "connection refused" against :9411/api/v2/spans while the test suite runs.

text
Reporting spans to Zipkin failed:
POST http://localhost:9411/api/v2/spans failed:
connect ECONNREFUSED 127.0.0.1:9411

Common causes

No Zipkin server on 9411 in CI

The reporter targets the default Zipkin collector endpoint on port 9411. Without a Zipkin service, POSTs are refused and spans are dropped.

Reporter created unconditionally in tests

The tracer initializes a Zipkin HTTP reporter regardless of environment, so importing the app under test starts trying to report.

How to fix it

Skip the Zipkin reporter in tests

  1. Use a no-op / in-memory reporter when running tests.
  2. If reporting must be exercised, run the Zipkin server as a service.
  3. Point the reporter endpoint at that service, not a remote host.
.github/workflows/ci.yml
services:
  zipkin:
    image: openzipkin/zipkin:latest
    ports: ['9411:9411']

Assert on spans in memory

Collect spans with an in-memory handler and assert on them rather than posting to a live server.

How to prevent it

  • Disable the Zipkin reporter for unit tests.
  • Run openzipkin/zipkin as a service only when export is under test.
  • Do not point CI reporters at remote Zipkin hosts.

Frequently asked questions

What causes ""failed to report ... spans""?
The reporter targets the default Zipkin collector endpoint on port 9411. Without a Zipkin service, POSTs are refused and spans are dropped.
How do I fix "failed to report ... spans"?
Skip the Zipkin reporter in tests

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card