Client and status¶
ZipkinClient talks to one Zipkin server (port 9411). It owns the HTTP connections; the query
client, the reporter and the tracing handles created through it share them. Stock Zipkin has
no authentication — when a gateway sits in front of it, put the credentials in headers
(they are sent on every call, including span ingest, and redacted everywhere).
Create and close¶
import { ZipkinClient } from "@grow-codes/zipkin";
const client = ZipkinClient.fromEnv(); // GROW_ZIPKIN_URL, ZIPKIN_URL, …
const gw = new ZipkinClient({
url: "https://gw.example/zipkin",
headers: { authorization: `Bearer ${process.env.GW_TOKEN}` },
});
await client.close(); // idempotent; also shuts down tracing handles from client.initTracing
client, err := zipkin.NewClientFromEnv()
if err != nil {
return err
}
defer client.Close() // idempotent; later calls fail with CANCELLED
gw, err := zipkin.NewClient(zipkin.Config{CommonConfig: zipkin.CommonConfig{
URL: "https://gw.example/zipkin",
Headers: map[string]string{"Authorization": "Bearer " + token},
}})
Any call on a closed client fails with CANCELLED ("client is closed"); initTracing on a
closed client fails with CONFIG.
health¶
GET /health → {"status":"UP"}. A 503 (DOWN, storage unavailable) gives healthy: false
without retries; an unreachable server gives status: "unreachable". Never fails except for
CANCELLED and CONFIG.
ping¶
A round trip through the query API and the storage: GET /api/v2/services. Behind a gateway it
also proves the credentials (AUTHENTICATION on 401). Returns the latency.
serverInfo / serverVersion¶
GET /info → {"zipkin":{"version":"3.6.1","commit":"b2b0c98"}}. serverInfo() returns both
fields (empty when the server or a gateway answers 404); serverVersion() returns the version
and fails with UNSUPPORTED when there is none.
query, reporter, createReporter¶
query is the ZipkinQueryClient and reporter the ZipkinReporter
of this client (no compression, 512 spans per POST, the config's endpoint); both share the
client's connections. createReporter(options) makes a reporter with other options
(compression, maxBatchSize, endpoint) on the client's settings; close() closes it too.
initTracing¶
Starts OpenTelemetry tracing to this Zipkin (see Tracing setup). With the
native protocol and no explicit endpoint, spans go to the client's endpoint with the client's
headers, TLS, proxy, retries and hooks. close() shuts the handle down and flushes it.