使用golang http.PostForm进行分布式跟踪 [英] Distributed tracing with golang http.PostForm
问题描述
在我的项目中,我尝试使用opentracing
实施分布式跟踪.
我的微服务具有以下结构.
-- API-Gateway
|_ User-Service
|_ Notification
在我的API网关中,我启动并在API网关中,我使用到函数来开始跟踪,代码取自 我使用 此处 如何克服这个问题? 我认为不能通过 In my project, I try to implement distributed tracing using My microservice has following structure. In my API-gateway, I start and in API gateway, I use a to a function to start tracing, code is taken from Setting up your tracer in I call to my User-service from Here How to overcome this issue? I don't think it can be done from 这篇关于使用golang http.PostForm进行分布式跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!http.PostForm()
从validateemail()
调用我的用户服务. _, err := http.PostForm("http://user:7071/checkemail", url.Values{"uuid": {uuid}, "email": {email}})
uuid
用于单独的任务,而不用于跟踪.
我无法使用PostForm()
将此Span
发布到下一个服务.PostForm
完成.您可能需要使用http.NewRequest
创建POST请求,使用Inject
标头中的跨度,并使用Client.Do
发送请求. opentracing
.-- API-Gateway
|_ User-Service
|_ Notification
main()
: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")
}
validateemail()
using http.PostForm()
. _, err := http.PostForm("http://user:7071/checkemail", url.Values{"uuid": {uuid}, "email": {email}})
uuid
is for separate task, not for tracing.
I can not post this Span
to the next service using PostForm()
.PostForm
. You would need to use http.NewRequest
to create the POST request, Inject
the span in headers and use Client.Do
to send the request.