Zipkin distributed tracing library for go.
Go to file
Adrian Cole e609ce4fbe
Adds SECURITY.md and scanning workflow (#223)
This adds SECURITY.md and a scanning workflow, using Trivy. In
particular, this clarifies what we use to scan for vulnerabilities
(Trivy, not anything else), and the only channel likely to be responded
to on a significant issue (zipkin-admin email, not advisories as people
ignored them).

This is the same approach as approved and merged in
openzipkin/zipkin-reporter-java#267

---------

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2024-04-29 08:11:29 +08:00
.github/workflows Adds SECURITY.md and scanning workflow (#223) 2024-04-29 08:11:29 +08:00
examples Bump dependencies and remove unnecessary external dependency for example. (#212) 2022-10-11 20:21:16 +02:00
idgenerator chore(deps): bump sarama to v1.40.0 (#214) 2023-08-10 16:38:07 +02:00
middleware Updates to latest actions and fixes golangci-lint drift (#221) 2024-04-20 06:33:13 -10:00
model Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
propagation Bump dependencies and remove unnecessary external dependency for example. (#212) 2022-10-11 20:21:16 +02:00
proto Bump dependencies and remove unnecessary external dependency for example. (#212) 2022-10-11 20:21:16 +02:00
reporter Updates to latest actions and fixes golangci-lint drift (#221) 2024-04-20 06:33:13 -10:00
.gitattributes Add gRPC client handler. (#95) 2018-11-30 10:56:12 +01:00
.gitignore Add gRPC client handler. (#95) 2018-11-30 10:56:12 +01:00
.golangci.yml Updates to latest actions and fixes golangci-lint drift (#221) 2024-04-20 06:33:13 -10:00
bench_test.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
context_test.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
context.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
doc.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
endpoint_test.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
endpoint.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
example_test.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
go.mod bumps to latest dependencies (#222) 2024-04-23 17:01:36 -10:00
go.sum bumps to latest dependencies (#222) 2024-04-23 17:01:36 -10:00
LICENSE first stab at basic span model (using V2 api as native container) 2017-10-31 00:16:53 +11:00
Makefile Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
noop_test.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
noop.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
README.md Set Go support policy to latest-2 (#220) 2024-04-23 16:36:40 -10:00
sample_test.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
sample.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
SECURITY.md Adds SECURITY.md and scanning workflow (#223) 2024-04-29 08:11:29 +08:00
span_implementation.go When serializing SpanModel, if there is any external modification of TAGS, it will lead to panic, add RLock before calling Send to prevent this error. (#218) 2024-04-23 17:03:27 -10:00
span_options.go Updates to latest actions and fixes golangci-lint drift (#221) 2024-04-20 06:33:13 -10:00
span_test.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
span.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
tags.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
tracer_options.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
tracer_test.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00
tracer.go Baggage Interface and explicit accept list Implementation for HTTP and gRPC middleware (#210) 2022-01-13 11:53:05 +01:00

Zipkin Library for Go

GHA codecov Go Report Card GoDoc Gitter chat Sourcegraph

Zipkin Go is the official Go Tracer / Tracing implementation for Zipkin, supported by the OpenZipkin community.

package organization

zipkin-go is built with interoperability in mind within the OpenZipkin community and even 3rd parties, the library consists of several packages.

The main tracing implementation can be found in the root folder of this repository. Reusable parts not considered core implementation or deemed beneficiary for usage by others are placed in their own packages within this repository.

model

This library implements the Zipkin V2 Span Model which is available in the model package. It contains a Go data model compatible with the Zipkin V2 API and can automatically sanitize, parse and (de)serialize to and from the required JSON representation as used by the official Zipkin V2 Collectors.

propagation

The propagation package and B3 subpackage hold the logic for propagating SpanContext (span identifiers and sampling flags) between services participating in traces. Currently Zipkin B3 Propagation is supported for HTTP and GRPC.

middleware

The middleware subpackages contain officially supported middleware handlers and tracing wrappers.

http

An easy to use http.Handler middleware for tracing server side requests is provided. This allows one to use this middleware in applications using standard library servers as well as most available higher level frameworks. Some frameworks will have their own instrumentation and middleware that maps better for their ecosystem.

For HTTP client operations NewTransport can return a http.RoundTripper implementation that can either wrap the standard http.Client's Transport or a custom provided one and add per request tracing. Since HTTP Requests can have one or multiple redirects it is advisable to always enclose HTTP Client calls with a Span either around the *http.Client call level or parent function level.

For convenience NewClient is provided which returns a HTTP Client which embeds *http.Client and provides an application span around the HTTP calls when calling the DoWithAppSpan() method.

grpc

Easy to use grpc.StatsHandler middleware are provided for tracing gRPC server and client requests.

For a server, pass NewServerHandler when calling NewServer, e.g.,

import (
	"google.golang.org/grpc"
	zipkingrpc "github.com/openzipkin/zipkin-go/middleware/grpc"
)

server = grpc.NewServer(grpc.StatsHandler(zipkingrpc.NewServerHandler(tracer)))

For a client, pass NewClientHandler when calling Dial, e.g.,

import (
	"google.golang.org/grpc"
	zipkingrpc "github.com/openzipkin/zipkin-go/middleware/grpc"
)

conn, err = grpc.Dial(addr, grpc.WithStatsHandler(zipkingrpc.NewClientHandler(tracer)))

reporter

The reporter package holds the interface which the various Reporter implementations use. It is exported into its own package as it can be used by 3rd parties to use these Reporter packages in their own libraries for exporting to the Zipkin ecosystem. The zipkin-go tracer also uses the interface to accept 3rd party Reporter implementations.

HTTP Reporter

Most common Reporter type used by Zipkin users transporting Spans to the Zipkin server using JSON over HTTP. The reporter holds a buffer and reports to the backend asynchronously.

Kafka Reporter

High performance Reporter transporting Spans to the Zipkin server using a Kafka Producer digesting JSON V2 Spans. The reporter uses the Sarama async producer underneath.

Usage and Examples

HTTP Server Example

Go Support Policy

zipkin-go follows the same version policy as Go's Release Policy: two versions. zipkin-go will ensure these versions work and bugs are valid if there's an issue with a current Go version.

Additionally, zipkin-go intentionally delays usage of language or standard library features one additional version. For example, when Go 1.29 is released, zipkin-go can use language features or standard libraries added in 1.27. This is a convenience for embedders who have a slower version policy than Go. However, only supported Go versions may be used to raise support issues.