Skip to content

Coorelation with logs generated via Lograge #1289

Answered by arielvalentin
sharozem asked this question in Q&A
Discussion options

You must be logged in to vote

I have not used lograge before but I imagine you could do something like this:

config.lograge.custom_options = lambda do |event|
  span = OpenTelemetry::Trace.current_span
  { "trace_id" => span.context.hex_trace_id, "span_id" => span.context.hex_span_id }
end

Or with the propagation API, however that will inject attributes for all of the propagators you have configured, which may not be ideal:

config.lograge.custom_options = lambda do |event|
  {}.tap do |carrier| 
    OpenTelemetry.propagation.inject(carrier)
  end
end

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@sharozem
Comment options

Comment options

You must be logged in to vote
2 replies
@sharozem
Comment options

@sharozem
Comment options

Answer selected by sharozem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants