0

In my project, I try to implement distributed tracing using opentracing.

My microservice has following structure.

-- API-Gateway
       |_ User-Service
       |_ Notification 

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 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")
}

I call to my User-service from validateemail() using http.PostForm().

_, err := http.PostForm("http://user:7071/checkemail", url.Values{"uuid": {uuid}, "email": {email}})

Here uuid is for separate task, not for tracing. I can not post this Span to the next service using PostForm().

How to overcome this issue?

1 Answer 1

1

I don't think it can be done from 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.