Documentation ¶
Overview ¶
* Package traceandtrace-go is the go language tracing lib, which can integrate different tracers such as: jeager, zipkin, skywalking, etc. reporter_job can report tracing data and optimize performance to achieve low business intrusion and high performance.
// quick start
import ( tracing "github.com/codeandcode0x/traceandtrace-go" ) // Add in func or middleware _, cancel := tracing.AddHttpTracing("HttpTracingTest", [your http Header], map[string]string{"version": "v1"}) defer cancel() ... reporter_job optimizes the reported tracing data (using goroutine processing), has little business intrusion, and reports with high performance. After the job ends, resources can be released.
Index ¶
- Constants
- func AddHttpTracing(svcName, spanName string, header http.Header, tags map[string]string, ...) (context.Context, context.CancelFunc)
- func AddRpcClientTracing(serviceName string, param ...map[string]string) (grpc.DialOption, io.Closer)
- func AddRpcServerTracing(serviceName string, param ...map[string]string) (grpc.ServerOption, io.Closer, opentracing.Tracer)
- func GenerateTracingJobs(pch chan<- context.Context, parent context.Context, svc, spanName string, ...)
Examples ¶
Constants ¶
View Source
const ( JAEGER_TRACER = "jaeger" ZIPKIN_TRACER = "zipkin" SKYWALKING_TRACER = "skywalking" )
Variables ¶
This section is empty.
Functions ¶
func AddHttpTracing ¶
func AddHttpTracing(svcName, spanName string, header http.Header, tags map[string]string, param ...map[string]string) (context.Context, context.CancelFunc)
Add http tracing , tags is k-v map which can set in span log, param map can set trace type .
Example ¶
package main import ( "io/ioutil" "log" "net/http" tracing "github.com/codeandcode0x/traceandtrace-go" ) func main() { httpClient := &http.Client{} r, _ := http.NewRequest("GET", "http://www.weather.com.cn/data/sk/101010100.html", nil) // set tracing _, cancel := tracing.AddHttpTracing("HttpClent", r.Header, map[string]string{"version": "v1"}) defer cancel() // send reqeust response, _ := httpClient.Do(r) if response.StatusCode == 200 { str, _ := ioutil.ReadAll(response.Body) bodystr := string(str) log.Println("body string", bodystr) } }
Output:
func AddRpcClientTracing ¶
func AddRpcClientTracing(serviceName string, param ...map[string]string) (grpc.DialOption, io.Closer)
add rpc client tracing
func AddRpcServerTracing ¶
func AddRpcServerTracing(serviceName string, param ...map[string]string) (grpc.ServerOption, io.Closer, opentracing.Tracer)
add rpc server tracing
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.