使用golang http.PostForm进行分布式跟踪
在我的项目中,我尝试使用使用golang http.PostForm进行分布式跟踪,go,microservices,trace,opentracing,distributed-tracing,Go,Microservices,Trace,Opentracing,Distributed Tracing,在我的项目中,我尝试使用opentracing实现分布式跟踪 我的微服务有以下结构 -- API-Gateway |_ User-Service |_ Notification 在我的API网关中,我启动,在API网关中,我使用一个to函数来启动跟踪,代码取自 在main()中: 我使用http.PostForm()从validateemail()调用我的用户服务 \错误:=http.PostForm('http://user:7071/checkemail,ur
opentracing
实现分布式跟踪
我的微服务有以下结构
-- API-Gateway
|_ User-Service
|_ Notification
在我的API网关中,我启动,在API网关中,我使用一个to函数来启动跟踪,代码取自
在main()
中:
我使用http.PostForm()
从validateemail()
调用我的用户服务
\错误:=http.PostForm('http://user:7071/checkemail,url.Values{“uuid”:{uuid},“email”:{email})
这里的uuid
用于单独的任务,而不是跟踪。
我无法使用PostForm()
将此Span
发布到下一个服务
如何克服这个问题 我认为这不能从
PostForm
完成。您需要使用http.NewRequest
来创建POST请求,在头中插入span
并使用Client.Do
来发送请求
gatewayTracer := &apiTracer{tracer: startTracing("API Gateway")}
http.HandleFunc("/getemail", gatewayTracer.validatemail)
func (apitracer apiTracer) validatemail(res http.ResponseWriter, req *http.Request) {
validateEmailSpan := apitracer.tracer.StartSpan("Validate Email")
}