-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zipkinContext.TraceID.ToHex undefined (type model.TraceID has no field or method ToHex) #142
Comments
We'll need more information (show me the code) to triage this... |
|
Ah yes, So the problem is you're using the old SpanContext object from the native For pure OpenTracing API usage this makes no difference but you are actually using non portable logic that ties you to Zipkin specifically. You can do two things...
If you want the best experience I'd suggest switching to native Zipkin Go. If you are determined to stick with OpenTracing (which will be superseded by OpenTelemetry so you'd have to invest heavily in the future anyway) you can do this for now: import (
zipkinot "github.com/openzipkin-contrib/zipkin-go-opentracing"
zipkin "github.com/openzipkin/zipkin-go"
)
func main () {
// ...
nativeTracer, err := zipkin.NewTracer(reporter, ...)
if err != nil {
// ...
}
tracer := zipkinot.Wrap(nativeTracer)
// InitGlobalTracer is deprecated...
opentracing.SetGlobalTracer(tracer)
ctx := opentracing.ContextWithSpan(context.Background(), span)
spanCtx := opentracing.SpanFromContext(ctx).Context().(zipkinot.SpanContext)
traceID := spanCtx.TraceID.String()
spanID := spanCtx.ID.String()
// ...
} |
@dd I see you want to extract the IDs from the span and I suspect it is
because you want to correlate it somewhere (maybe logs), this can be
achieved in many ways and they can even be transparent. opentracing-go does
not support access to identifiers (see the full thread in
opentracing/opentracing-go#188) and hence we
don't either so I would suggest that you explain more your specific use
case and we can suggest you more concrete solutions.
In any case, I would also suggest using zipkin-go instead as you will get much more value out of it.
|
@jcchavezs Yes, it is used for logging purposes and I am trying to set it up in the main function as suggested by @basvanbeek as below
If i do the above for some reasons I dont know, the service calls never reach my service. I believe this is where its hanging while returning the response
|
This explains the specific usecase, I have Looks like this is happening only for REST and not grpc.
|
I think the problem you have is in the grpc-zipkin-with-grpc-gateway you use From Goexit:
So basically you trigger the reporter to be closed. I suggest not using Goexit. If you want a nice way of running multiple goroutines and having a way to handle graceful shutdown take a look at run.Group |
Wooh. Right! Thank you so much! |
I know I closed this issue, but with the approach here using the
Below is the tracer I have
Here is the repo again, https://github.com/dayadev/grpc-zipkin-with-grpc-gateway |
I was able to further debug this and found when |
@dayadev can you check if latest in master fixes your issue? |
@basvanbeek Yes, this fixed the issue. Thank you! |
So the problem is the old SpanContext object from the native zipkin-go-opentracing tracer. From version 0.4.0 onwards this project has become a bridge to the zipkin-go native tracer which has its own SpanContext object and logic which is a bit different from the one it's used. openzipkin-contrib/zipkin-go-opentracing#142
Having this issue today
The text was updated successfully, but these errors were encountered: