Class: Rabbitek::Utils::OpenTracing
- Inherits:
-
Object
- Object
- Rabbitek::Utils::OpenTracing
- Defined in:
- lib/rabbitek/utils/open_tracing.rb
Overview
OpenTracing helpers
Constant Summary collapse
- OPENTRACING_COMPONENT =
'rabbitek'
- OPENTRACING_KIND_SERVER =
'server'
- OPENTRACING_KIND_CLIENT =
'client'
Class Method Summary collapse
- .client_options(params) ⇒ Object
- .inject!(span, carrier) ⇒ Object
- .log_error(span, err) ⇒ Object
- .server_options(delivery_info, properties) ⇒ Object
Class Method Details
.client_options(params) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/rabbitek/utils/open_tracing.rb', line 17 def (params) { tags: { 'component' => OPENTRACING_COMPONENT, 'span.kind' => OPENTRACING_KIND_CLIENT, 'rabbitmq.routing_key' => params[:routing_key] } } end |
.inject!(span, carrier) ⇒ Object
13 14 15 |
# File 'lib/rabbitek/utils/open_tracing.rb', line 13 def inject!(span, carrier) ::OpenTracing.inject(span.context, ::OpenTracing::FORMAT_TEXT_MAP, carrier) end |
.log_error(span, err) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/rabbitek/utils/open_tracing.rb', line 45 def log_error(span, err) span.set_tag('error', true) span.log_kv( event: 'error', 'error.kind': err.class.to_s, 'error.object': err, message: err. ) end |
.server_options(delivery_info, properties) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rabbitek/utils/open_tracing.rb', line 27 def (delivery_info, properties) references = server_references(properties) = { tags: { 'component' => OPENTRACING_COMPONENT, 'span.kind' => OPENTRACING_KIND_SERVER, 'rabbitmq.routing_key' => delivery_info.routing_key, 'rabbitmq.jid' => Thread.current[:rabbit_context][:jid], 'rabbitmq.queue' => Thread.current[:rabbit_context][:queue], 'rabbitmq.worker' => Thread.current[:rabbit_context][:consumer] } } [:references] = [references] if references end |