Class: OpenTracing::Instrumentation::Bunny::PublishTagsBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/opentracing/instrumentation/bunny/publish_tags_builder.rb

Overview

PublishTagsBuilder build span tags for Bunny::PublishTracer

Constant Summary collapse

DEFAULT_STATIC_TAGS =
{
  'span.kind' => 'publiser',
  'component' => 'bunny',
}.freeze
DEFAULT_CONTENT_TYPE =
::Bunny::Channel::DEFAULT_CONTENT_TYPE
DEFAULT_PERSISTENT =
true
DEFAAUL_PRIORITY =
0

Instance Method Summary collapse

Constructor Details

#initialize(static_tags: DEFAULT_STATIC_TAGS) ⇒ PublishTagsBuilder

Returns a new instance of PublishTagsBuilder.

Parameters:

  • static_tags (Hash<String, String>) (defaults to: DEFAULT_STATIC_TAGS)


20
21
22
# File 'lib/opentracing/instrumentation/bunny/publish_tags_builder.rb', line 20

def initialize(static_tags: DEFAULT_STATIC_TAGS)
  @static_tags = static_tags
end

Instance Method Details

#build_tags(exchange, opts) ⇒ Hash<String, String>

Parameters:

  • exchange (Bunny::Exchange)
  • opts (Hash<>)

Options Hash (opts):

  • :routing_key (String, nil)
  • :content_type (String, nil)
  • :message_id (String, nil)
  • :expiration (Integer, nil)
  • :content_encoding (String, nil)
  • :persistent (Boolean, nil)
  • :mandatory (Boolean, nil)
  • :priority (Integer, nil)
  • :app_id (String, nil)

Returns:

  • (Hash<String, String>)


36
37
38
39
40
41
42
# File 'lib/opentracing/instrumentation/bunny/publish_tags_builder.rb', line 36

def build_tags(exchange, opts)
  @static_tags
    .merge(exchange_tags(exchange))
    .merge(meta_tags(opts))
    .merge(extended_tags(opts))
    .compact
end