zipkin-go的report支持多种传播方式,比如:http,RabbitMq,kafka,log等方式。
此文着重了解http-report的使用方式
github地址:https://github.com/openzipkin/zipkin-go
源码路径为:reporter/http/http.go
1.report的创建
此步主要进行report的一些初始化设置,并创建两个goroutine来处理请求发送
func NewReporter(url string, opts ...ReporterOption) reporter.Reporter {
r := httpReporter{
url: url,
logger: log.New(os.Stderr, "", log.LstdFlags),
client: &http.Client{},
batchInterval: defaultBatchInterval,
batchSize: defaultBatchSize,
maxBacklog: defaultMaxBacklog,
batch: []*model.SpanModel{},
spanC: make(chan *model.SpanModel),
sendC: make(chan struct{}, 1),
quit: make(chan struct{}, 1),
shutdown: make(chan error, 1),
batchMtx: &sync.Mutex{},
serializer: reporter.JSONSerializer{},
reqTimeout: defaultTimeout,
}
//自定义配置
for _, opt := range