链路追踪实例参数

来源:5-7 商品领域 链路追踪使用

慕瓜9063200

2022-12-22

老师你好,本节课中添加链路追踪对于其中的配置并没有详细说明

func NerTracer(serviceName string, addr string) (opentracing.Tracer, io.Closer, error) {
	cfg := &config.Configuration{
		ServiceName: serviceName,
		Sampler: &config.SamplerConfig{
			Type: jaeger.SamplerTypeConst,
			Param: 1,
		},
		Reporter: &config.ReporterConfig{
			BufferFlushInterval: 1*time.Second,
			LogSpans: true,
			LocalAgentHostPort: addr,
		},
	}
	return cfg.NewTracer()
}

cfg := &config.Configuration{},创建了什么?
Sampler配置又是什么意思呢,它里面的type、param是什么意思
还有Reporter配置了什么,BufferFlushInterval、LogSpans是什么意思,为什么要这么配置

写回答

1回答

Cap

2022-12-26

你好问题的问题比较细,我教你如何如理解这块。这块是链路追踪里面的特有代码,是插件自己带的。具体说明可以点击config 跳转到详细的源代码中有说明。

0
1
慕瓜9063200
老师,如果不知道这些配置信息,那创建Jaeger追踪器的时候你是如何知道为什么要配置Sampler、Reporter这些参数呢, type Configuration struct { ServiceName string `yaml:"serviceName"` Disabled bool `yaml:"disabled"` RPCMetrics bool `yaml:"rpc_metrics"` Tags []opentracing.Tag `yaml:"tags"` Sampler *SamplerConfig `yaml:"sampler"` Reporter *ReporterConfig `yaml:"reporter"` Headers *jaeger.HeadersConfig `yaml:"headers"` BaggageRestrictions *BaggageRestrictionsConfig `yaml:"baggage_restrictions"` Throttler *ThrottlerConfig `yaml:"throttler"` } 可选的配置参数这么多,为啥只选了三个配置,而不选择其他的
2023-01-11
共1条回复

Go微服务入门到容器化实践,落地可观测微服务项目

这可能是你全面提升Go微服务能力的好机会

861 学习 · 322 问题

查看课程