Module: NewRelic::Agent::OpenTelemetry::TransactionPatch

Defined in:
lib/new_relic/agent/opentelemetry/transaction_patch.rb

Instance Method Summary collapse

Instance Method Details

#finishObject



28
29
30
31
32
# File 'lib/new_relic/agent/opentelemetry/transaction_patch.rb', line 28

def finish
  Thread.current[:nr_otel_current_span] = nil

  super
end

#remove_current_segment_by_thread_id(id) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/new_relic/agent/opentelemetry/transaction_patch.rb', line 20

def remove_current_segment_by_thread_id(id)
  if id == Thread.current.object_id
    Thread.current[:nr_otel_current_span] = nil
  end

  super
end

#set_current_segment(new_segment) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/new_relic/agent/opentelemetry/transaction_patch.rb', line 9

def set_current_segment(new_segment)
  @current_segment_lock.synchronize do
    if new_segment&.respond_to?(:transaction) && new_segment.transaction
      span = find_or_create_span(new_segment)
      Thread.current[:nr_otel_current_span] = span
    end
  end

  super
end