Module: NewRelic::Agent::OpenTelemetry::TransactionPatch
- Defined in:
- lib/new_relic/agent/opentelemetry/transaction_patch.rb
Instance Attribute Summary collapse
-
#opentelemetry_context ⇒ Object
Returns the value of attribute opentelemetry_context.
Instance Method Summary collapse
- #initialize(_category, _options) ⇒ Object
- #remove_current_segment_by_thread_id(id) ⇒ Object
- #set_current_segment(new_segment) ⇒ Object
Instance Attribute Details
#opentelemetry_context ⇒ Object
Returns the value of attribute opentelemetry_context.
9 10 11 |
# File 'lib/new_relic/agent/opentelemetry/transaction_patch.rb', line 9 def opentelemetry_context @opentelemetry_context end |
Instance Method Details
#initialize(_category, _options) ⇒ Object
11 12 13 14 |
# File 'lib/new_relic/agent/opentelemetry/transaction_patch.rb', line 11 def initialize(_category, ) @opentelemetry_context = {} super end |
#remove_current_segment_by_thread_id(id) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/new_relic/agent/opentelemetry/transaction_patch.rb', line 32 def remove_current_segment_by_thread_id(id) # make sure the context is fully detached when the transaction ends @current_segment_lock.synchronize do ::OpenTelemetry::Context.detach(opentelemetry_context[otel_current_span_key]) opentelemetry_context.delete(id) end super end |
#set_current_segment(new_segment) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/new_relic/agent/opentelemetry/transaction_patch.rb', line 16 def set_current_segment(new_segment) @current_segment_lock.synchronize do unless opentelemetry_context.empty? ::OpenTelemetry::Context.detach(opentelemetry_context[otel_current_span_key]) end span = find_or_create_span(new_segment) ctx = ::OpenTelemetry::Context.current.set_value(otel_current_span_key, span) token = ::OpenTelemetry::Context.attach(ctx) opentelemetry_context[otel_current_span_key] = token end super end |