salemove / jaeger-client-ruby

OpenTracing Tracer implementation for Jaeger in Ruby
MIT License
62 stars 38 forks source link

how to read the trace id of a trace #16

Closed c5c86a closed 5 years ago

c5c86a commented 5 years ago

The UI on the top left has a nice search box to search by trace ID and it's great that you can share a trace x for analysis with others by sharing the URL http://your-jaeger-host:16686/trace/x

However, it's not clear at least to me, how to read the trace id of a trace.

The following is a way to have it as a tag. This is at the call method of a custom rails middleware that takes env as an argument. I tried first to use 'set_baggage_item' but at the UI I only see tags.

tracer.start_active_span(...) do |scope|                                                                                                                                                                                      
  scope.span.set_tag('trace-id', scope.span.context.trace_id.to_s(16))                                                                                                                            
  result = @app.call(env).tap do |status_code, _headers, _body|                                                                                                                                   
  end                                                                                                                                                                                             
end

Is there a better way?

indrekj commented 5 years ago

If you already see the trace in the UI, then you can just open it and the URL. If the URL is http://localhost:16686/trace/880831d918bb7faa, then In this case 880831d918bb7faa is the trace id. No need to add it as a tag or baggage.

If you need to get the trace id in your ruby application (e.g. log it in the console) then you can use scope.span.context.to_trace_id

c5c86a commented 5 years ago

thanks