Class: OpenTracing::Instrumentation::Sidekiq::ClientMiddleware
- Inherits:
-
Object
- Object
- OpenTracing::Instrumentation::Sidekiq::ClientMiddleware
- Extended by:
- Forwardable
- Defined in:
- lib/opentracing/instrumentation/sidekiq/client_middleware.rb
Overview
Sidekiq producer middleware
Constant Summary collapse
- DEFAULT_SPAN_KIND =
'producer'
- DEFAULT_OPERATION_NAME_TEMPLATE =
'sidekiq_enqueue(%<sidekiq.class>s)'
- DEFAULT_OPERATION_NAME_BUILDER =
Common::OperationNameBuilder.new( operation_name_template: DEFAULT_OPERATION_NAME_TEMPLATE, )
Instance Attribute Summary collapse
-
#error_writter ⇒ Object
readonly
Returns the value of attribute error_writter.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#operation_name_builder ⇒ Object
readonly
Returns the value of attribute operation_name_builder.
-
#span_kind ⇒ Object
readonly
Returns the value of attribute span_kind.
-
#tagger ⇒ Object
readonly
Returns the value of attribute tagger.
-
#tracer ⇒ Object
readonly
Returns the value of attribute tracer.
Instance Method Summary collapse
-
#call(_worker_class, job, _queue, _redis_pool, &block) ⇒ Object
rubocop:enable Metrics/ParameterLists.
-
#initialize(tracer: OpenTracing.global_tracer, tagger: JobTagger.new, error_writter: Common::ErrorWriter.new, logger: nil, span_kind: DEFAULT_SPAN_KIND, operation_name_builder: DEFAULT_OPERATION_NAME_BUILDER) ⇒ ClientMiddleware
constructor
rubocop:disable Metrics/ParameterLists.
Constructor Details
#initialize(tracer: OpenTracing.global_tracer, tagger: JobTagger.new, error_writter: Common::ErrorWriter.new, logger: nil, span_kind: DEFAULT_SPAN_KIND, operation_name_builder: DEFAULT_OPERATION_NAME_BUILDER) ⇒ ClientMiddleware
rubocop:disable Metrics/ParameterLists
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/opentracing/instrumentation/sidekiq/client_middleware.rb', line 27 def initialize( tracer: OpenTracing.global_tracer, tagger: JobTagger.new, error_writter: Common::ErrorWriter.new, logger: nil, span_kind: DEFAULT_SPAN_KIND, operation_name_builder: DEFAULT_OPERATION_NAME_BUILDER ) @tracer = tracer @tagger = tagger @error_writter = error_writter @logger = logger @span_kind = span_kind @operation_name_builder = operation_name_builder end |
Instance Attribute Details
#error_writter ⇒ Object (readonly)
Returns the value of attribute error_writter.
19 20 21 |
# File 'lib/opentracing/instrumentation/sidekiq/client_middleware.rb', line 19 def error_writter @error_writter end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
19 20 21 |
# File 'lib/opentracing/instrumentation/sidekiq/client_middleware.rb', line 19 def logger @logger end |
#operation_name_builder ⇒ Object (readonly)
Returns the value of attribute operation_name_builder.
19 20 21 |
# File 'lib/opentracing/instrumentation/sidekiq/client_middleware.rb', line 19 def operation_name_builder @operation_name_builder end |
#span_kind ⇒ Object (readonly)
Returns the value of attribute span_kind.
19 20 21 |
# File 'lib/opentracing/instrumentation/sidekiq/client_middleware.rb', line 19 def span_kind @span_kind end |
#tagger ⇒ Object (readonly)
Returns the value of attribute tagger.
19 20 21 |
# File 'lib/opentracing/instrumentation/sidekiq/client_middleware.rb', line 19 def tagger @tagger end |
#tracer ⇒ Object (readonly)
Returns the value of attribute tracer.
19 20 21 |
# File 'lib/opentracing/instrumentation/sidekiq/client_middleware.rb', line 19 def tracer @tracer end |
Instance Method Details
#call(_worker_class, job, _queue, _redis_pool, &block) ⇒ Object
rubocop:enable Metrics/ParameterLists
44 45 46 47 48 49 50 |
# File 'lib/opentracing/instrumentation/sidekiq/client_middleware.rb', line 44 def call(_worker_class, job, _queue, _redis_pool, &block) scope = safe_start_scope(job) inject(scope.span.context, job) log(scope.span, job, &block) ensure safe_close_scope(scope) end |