Class: ActionSubscriber::OpenTracing::Middleware
- Inherits:
-
Object
- Object
- ActionSubscriber::OpenTracing::Middleware
- Defined in:
- lib/action_subscriber/opentracing/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
8 9 10 |
# File 'lib/action_subscriber/opentracing/middleware.rb', line 8 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/action_subscriber/opentracing/middleware.rb', line 12 def call(env) operation = "Subscriber #{env.subscriber}##{env.action}" parent = ::OpenTracing.extract(::OpenTracing::FORMAT_TEXT_MAP, env.headers) published_at = env.headers["published_at"] = {} [:references] = [::OpenTracing::Reference.follows_from(parent)] if parent [:tags] = { "span.kind" => "consumer", "component" => "ActionSubscriber", "message_bus.destination" => env.routing_key, "message_bus.processed_at" => Time.now.strftime("%F %T.%3N %Z") } [:tags]["message_bus.published_at"] = published_at if published_at result = nil ::OpenTracing.start_active_span(operation, ) do result = @app.call(env) end result end |