Class: OpenTracing::Instrumentation::Sidekiq::JobTagger
- Inherits:
-
Object
- Object
- OpenTracing::Instrumentation::Sidekiq::JobTagger
- Defined in:
- lib/opentracing/instrumentation/sidekiq/job_tagger.rb
Overview
Span tags and logs building mixin
Constant Summary collapse
- LOG_JID_EVENT =
'job_id'
- LOG_ARGS_EVENT =
'job_args'
- DEFAULT_COMPONENT =
'sidekiq'
Instance Attribute Summary collapse
-
#component ⇒ Object
Returns the value of attribute component.
-
#log_args ⇒ Object
Returns the value of attribute log_args.
Instance Method Summary collapse
-
#build_tags(job, span_kind) ⇒ Object
build tags from job data and static attributes.
-
#initialize(component: DEFAULT_COMPONENT, log_args: false) {|_self| ... } ⇒ JobTagger
constructor
A new instance of JobTagger.
-
#write_args_log(span, jid, args) ⇒ Object
write job jid and args if log_args enabled.
Constructor Details
#initialize(component: DEFAULT_COMPONENT, log_args: false) {|_self| ... } ⇒ JobTagger
Returns a new instance of JobTagger.
20 21 22 23 24 25 26 27 28 |
# File 'lib/opentracing/instrumentation/sidekiq/job_tagger.rb', line 20 def initialize( component: DEFAULT_COMPONENT, log_args: false ) @component = component @log_args = log_args yield self if block_given? end |
Instance Attribute Details
#component ⇒ Object
Returns the value of attribute component.
15 16 17 |
# File 'lib/opentracing/instrumentation/sidekiq/job_tagger.rb', line 15 def component @component end |
#log_args ⇒ Object
Returns the value of attribute log_args.
15 16 17 |
# File 'lib/opentracing/instrumentation/sidekiq/job_tagger.rb', line 15 def log_args @log_args end |
Instance Method Details
#build_tags(job, span_kind) ⇒ Object
build tags from job data and static attributes
31 32 33 34 35 36 37 38 39 |
# File 'lib/opentracing/instrumentation/sidekiq/job_tagger.rb', line 31 def (job, span_kind) { component: component, 'span.kind': span_kind, 'sidekiq.queue': job['queue'], 'sidekiq.class': job['class'], 'sidekiq.retry': job['retry'], } end |
#write_args_log(span, jid, args) ⇒ Object
write job jid and args if log_args enabled
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/opentracing/instrumentation/sidekiq/job_tagger.rb', line 45 def write_args_log(span, jid, args) span.log_kv( event: LOG_JID_EVENT, jid: jid, ) return unless log_args span.log_kv( event: LOG_ARGS_EVENT, args: JSON.dump(args), ) end |