Module: Datadog::Tracing::Contrib::Karafka::MessagesPatch
- Defined in:
- lib/datadog/tracing/contrib/karafka/patcher.rb
Overview
Patch to add tracing to Karafka::Messages::Messages
Instance Method Summary collapse
- #configuration ⇒ Object
-
#each(&block) ⇒ Object
‘each` is the most popular access point to Karafka messages, but not the only one Other access patterns do not have a straightforward tracing avenue (e.g. `my_batch_operation messages.payloads`).
- #propagation ⇒ Object
Instance Method Details
#configuration ⇒ Object
13 14 15 |
# File 'lib/datadog/tracing/contrib/karafka/patcher.rb', line 13 def configuration Datadog.configuration.tracing[:karafka] end |
#each(&block) ⇒ Object
‘each` is the most popular access point to Karafka messages, but not the only one
Other access patterns do not have a straightforward tracing avenue
(e.g. ‘my_batch_operation messages.payloads`)
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/datadog/tracing/contrib/karafka/patcher.rb', line 26 def each(&block) @messages_array.each do || if configuration[:distributed_tracing] headers = if ..respond_to?(:raw_headers) ..raw_headers else ..headers end trace_digest = Karafka.extract(headers) Datadog::Tracing.continue_trace!(trace_digest) if trace_digest end Tracing.trace(Ext::SPAN_MESSAGE_CONSUME) do |span| span.set_tag(Ext::TAG_OFFSET, ..offset) span.set_tag(Contrib::Ext::Messaging::TAG_DESTINATION, .topic) span.set_tag(Contrib::Ext::Messaging::TAG_SYSTEM, Ext::TAG_SYSTEM) span.resource = .topic yield end end end |
#propagation ⇒ Object
17 18 19 |
# File 'lib/datadog/tracing/contrib/karafka/patcher.rb', line 17 def propagation @propagation ||= Contrib::Karafka::Distributed::Propagation.new end |