Skip to main content

a6-plugin-zipkin

Overview

The zipkin plugin sends distributed traces to Zipkin-compatible collectors using the Zipkin v2 HTTP API. It supports B3 propagation headers for trace context across services. Compatible backends include Zipkin, Jaeger, and SkyWalking (via Zipkin receiver).

When to Use

  • Distributed tracing with Zipkin, Jaeger, or compatible collectors
  • B3 header propagation across microservices
  • Per-request sampling control via headers
  • Trace ID injection into access logs

Plugin Configuration Reference

FieldTypeRequiredDefaultDescription
endpointstringYesZipkin collector URL (e.g. http://zipkin:9411/api/v2/spans)
sample_rationumberYesSampling rate from 0.00001 to 1
service_namestringNo"APISIX"Service name in Zipkin UI
server_addrstringNo$server_addrIPv4 address for span reporting
span_versionintegerNo2Span format: 1 (legacy) or 2 (default)

B3 Propagation Headers

The plugin uses B3 propagation format:

Injected to upstream

HeaderDescription
x-b3-traceidTrace ID (16 or 32 hex chars)
x-b3-spanidSpan ID (16 hex chars)
x-b3-parentspanidParent span ID
x-b3-sampledSampling decision (1 or 0)

Extracted from client

HeaderDescription
b3Single-header format: {traceid}-{spanid}-{sampled}-{parentspanid}
x-b3-sampled1 = force sample, 0 = skip, d = debug
x-b3-flags1 = force debug sampling

Clients can override sampling per-request by setting x-b3-sampled: 1.

Span Versions

Version 2 (default, recommended):

request
├── proxy (request start → header_filter)
└── response (header_filter → log)

Version 1 (legacy):

request
├── rewrite
├── access
└── proxy
└── body_filter

Step-by-Step: Enable Zipkin Tracing

1. Create a route with zipkin

a6 route create -f - <<'EOF'
{
"id": "traced-api",
"uri": "/api/*",
"plugins": {
"zipkin": {
"endpoint": "http://zipkin:9411/api/v2/spans",
"sample_ratio": 1,
"service_name": "my-gateway",
"span_version": 2
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"backend:8080": 1
}
}
}
EOF

2. Send a request

curl http://127.0.0.1:9080/api/hello

3. View traces in Zipkin UI

Open http://zipkin:9411 and search for service my-gateway.

Common Patterns

Send traces to Jaeger

Jaeger supports the Zipkin v2 API:

{
"plugins": {
"zipkin": {
"endpoint": "http://jaeger-collector:9411/api/v2/spans",
"sample_ratio": 1,
"service_name": "my-gateway"
}
}
}

Production sampling (10%)

{
"plugins": {
"zipkin": {
"endpoint": "http://zipkin:9411/api/v2/spans",
"sample_ratio": 0.1,
"service_name": "production-gateway"
}
}
}

Trace IDs in access logs

Add to APISIX config.yaml:

plugin_attr:
zipkin:
set_ngx_var: true

nginx_config:
http:
access_log_format: '{"trace_id":"$zipkin_trace_id","span_id":"$zipkin_span_id","traceparent":"$zipkin_context_traceparent"}'
access_log_format_escape: json

Available variables:

  • $zipkin_trace_id — Trace ID
  • $zipkin_span_id — Span ID
  • $zipkin_context_traceparent — W3C traceparent header

External IP address

{
"plugins": {
"zipkin": {
"endpoint": "http://zipkin:9411/api/v2/spans",
"sample_ratio": 1,
"server_addr": "10.0.1.5"
}
}
}

Config Sync Example

version: "1"
routes:
- id: traced-api
uri: /api/*
plugins:
zipkin:
endpoint: http://zipkin:9411/api/v2/spans
sample_ratio: 1
service_name: my-gateway
span_version: 2
upstream_id: my-upstream
upstreams:
- id: my-upstream
type: roundrobin
nodes:
"backend:8080": 1

Troubleshooting

SymptomCauseFix
No traces in Zipkin UIWrong endpoint URLVerify collector is reachable; must include /api/v2/spans
Traces not connectedB3 headers stripped by proxyEnsure intermediate proxies forward x-b3-* headers
All requests sampledsample_ratio: 1Lower for production (e.g. 0.01-0.1)
Missing trace variables in logsset_ngx_var not enabledSet plugin_attr.zipkin.set_ngx_var: true in config.yaml
400 from collectorSpan version mismatchTry span_version: 1 if collector only supports v1

This page is generated from a6-plugin-zipkin/SKILL.md in the api7/a6 repository. Browse all skills on the AI Agent Skills page.

API7.ai Logo

The digital world is connected by APIs,
API7.ai exists to make APIs more efficient, reliable, and secure.

Sign up for API7 newsletter

Product

API7 Gateway

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

Copyright © APISEVEN PTE. LTD 2019 – 2026. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the Apache Software Foundation