Package zipkin adds Zipkin tracing support that can be used in conjunction with SpoofingClient to log zipkin traces for requests that have encountered server errors i.e HTTP request that have HTTP status between 500 to 600.
This package exposes following methods:
SetupZipkinTracing(*kubernetes.Clientset) error SetupZipkinTracing sets up zipkin tracing by setting up port-forwarding from localhost to zipkin pod on the cluster. On successful setup this method sets an internal flag zipkinTracingEnabled to true. CleanupZipkinTracingSetup() error CleanupZipkinTracingSetup cleans up zipkin tracing setup by cleaning up the port-forwarding setup by call to SetupZipkinTracing. This method also sets zipkinTracingEnabled flag to false.
A general flow for a Test Suite to use Zipkin Tracing support is as follows:
1. Call SetupZipkinTracing(*kubernetes.Clientset) in TestMain. 2. Use SpoofingClient to make HTTP requests. 3. Call CleanupZipkinTracingSetup on cleanup after tests are executed.
const ( //ZipkinTraceIDHeader HTTP response header key to be used to store Zipkin Trace ID. ZipkinTraceIDHeader = "ZIPKIN_TRACE_ID" // ZipkinPort is port exposed by the Zipkin Pod // https://github.com/knative/serving/blob/master/config/monitoring/200-common/100-zipkin.yaml#L25 configures the Zipkin Port on the cluster. ZipkinPort = 9411 // ZipkinTraceEndpoint port-forwarded zipkin endpoint ZipkinTraceEndpoint = "http://localhost:9411/api/v2/trace/" )
func CheckZipkinPortAvailability() error
CheckZipkinPortAvailability checks to see if Zipkin Port is available on the machine. returns error if the port is not available.
CleanupZipkinTracingSetup cleans up the Zipkin tracing setup on the machine. This involves killing the process performing port-forward.
JSONTrace returns a trace for the given traceId in JSON format
func SetupZipkinTracing ¶
SetupZipkinTracing sets up zipkin tracing which involves: 1. Setting up port-forwarding from localhost to zipkin pod on the cluster
(pid of the process doing Port-Forward is stored in a global variable).
2. Enable AlwaysSample config for tracing.
This section is empty.