Skip to content

Commit

Permalink
bug[426]: arguments for different jobs are different so appending the…
Browse files Browse the repository at this point in the history
… context to the arguments array

Signed-off-by: Arjun Rajappa <Arjun.Rajappa@ibm.com>
  • Loading branch information
arjun-rajappa committed Nov 13, 2024
1 parent db3e0a5 commit 2aacf8f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/instana/instrumentation/active_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def self.prepended(target)

::Instana::Tracer.trace(:activejob, tags) do
context = ::Instana.tracer.context
if job.arguments.is_a?(Array) && job.arguments.last.is_a?(Hash)
job.arguments.last[:instana_context] = context ? context.to_hash : nil
end
job.arguments.append({
instana_context: context ? context.to_hash : nil
})

block.call
end
Expand All @@ -34,10 +34,9 @@ def self.prepended(target)
job_id: job.job_id
}
}

incoming_context = if job.arguments.is_a?(Array) && job.arguments.last.is_a?(Hash)
incoming_context = if job.arguments.is_a?(Array) && job.arguments.last.is_a?(Hash) && job.arguments.last.key?(:instana_context)
instana_context = job.arguments.last[:instana_context]
job.arguments.last.delete(:instana_context)
job.arguments.pop
instana_context ? ::Instana::SpanContext.new(instana_context[:trace_id], instana_context[:span_id]) : nil
end

Expand Down

0 comments on commit 2aacf8f

Please sign in to comment.