openzipkin / zipkin-go

Zipkin distributed tracing library for go.
Apache License 2.0
612 stars 114 forks source link

Function to get TraceID #195

Closed androna-xm closed 3 years ago

androna-xm commented 3 years ago

Is there a function to get the TraceID of a trace created?

jcchavezs commented 3 years ago

Only on reporting. What are you trying to achieve?

On Mon, 14 Jun 2021, 19:48 androna-xm, @.***> wrote:

Is there a function to get the TraceID of a trace created?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openzipkin/zipkin-go/issues/195, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXOYATDSBVOG6UZHQSVYJLTSY6G7ANCNFSM46VVZDKQ .

androna-xm commented 3 years ago

I would like to get the TraceID to add it as an exemplar to a metric. So i guess i have to use an instrumentation tool ( Opencencus or OpenTelemetry ) to get the TraceID ?

basvanbeek commented 3 years ago

You do have access to TraceID from span context:

// get as hex string (the typical propagation format)
span.Context().ID.String()
jcchavezs commented 3 years ago

@basvanbeek is totally right, I misunderstood the question.

As he pointed out you can access to it through the context so you can use that and put in the metric.

androna-xm commented 3 years ago

That's great! Thank you!