Class: Freddy::Delivery
- Inherits:
-
Object
- Object
- Freddy::Delivery
- Defined in:
- lib/freddy/delivery.rb
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#routing_key ⇒ Object
readonly
Returns the value of attribute routing_key.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
- #correlation_id ⇒ Object
- #in_span(force_follows_from: false, &block) ⇒ Object
-
#initialize(payload, metadata, routing_key, tag, exchange) ⇒ Delivery
constructor
A new instance of Delivery.
- #reply_to ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(payload, metadata, routing_key, tag, exchange) ⇒ Delivery
Returns a new instance of Delivery.
7 8 9 10 11 12 13 |
# File 'lib/freddy/delivery.rb', line 7 def initialize(payload, , routing_key, tag, exchange) @payload = payload @metadata = @routing_key = routing_key @tag = tag @exchange = exchange end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
5 6 7 |
# File 'lib/freddy/delivery.rb', line 5 def payload @payload end |
#routing_key ⇒ Object (readonly)
Returns the value of attribute routing_key.
5 6 7 |
# File 'lib/freddy/delivery.rb', line 5 def routing_key @routing_key end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
5 6 7 |
# File 'lib/freddy/delivery.rb', line 5 def tag @tag end |
Instance Method Details
#correlation_id ⇒ Object
15 16 17 |
# File 'lib/freddy/delivery.rb', line 15 def correlation_id @metadata.correlation_id end |
#in_span(force_follows_from: false, &block) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/freddy/delivery.rb', line 27 def in_span(force_follows_from: false, &block) name = "#{@exchange}.#{@routing_key} receive" kind = OpenTelemetry::Trace::SpanKind::CONSUMER producer_context = OpenTelemetry.propagation.extract(@metadata[:headers] || {}) if force_follows_from producer_span_context = OpenTelemetry::Trace.current_span(producer_context).context links = [] links << OpenTelemetry::Trace::Link.new(producer_span_context) if producer_span_context.valid? # In general we should start a new trace here and just link two traces # together. But Zipkin (which we currently use) doesn't support links. # So even though the root trace could finish before anything here # starts executing, we'll continue with the root trace here as well. OpenTelemetry::Context.with_current(producer_context) do Freddy.tracer.in_span(name, attributes: span_attributes, links: links, kind: kind, &block) end else OpenTelemetry::Context.with_current(producer_context) do Freddy.tracer.in_span(name, attributes: span_attributes, kind: kind, &block) end end end |
#reply_to ⇒ Object
23 24 25 |
# File 'lib/freddy/delivery.rb', line 23 def reply_to @metadata.reply_to end |
#type ⇒ Object
19 20 21 |
# File 'lib/freddy/delivery.rb', line 19 def type @metadata.type end |