Class: Datadog::Tracing::Contrib::Faraday::Middleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Datadog::Tracing::Contrib::Faraday::Middleware
- Includes:
- HttpAnnotationHelper
- Defined in:
- lib/datadog/tracing/contrib/faraday/middleware.rb
Overview
Middleware implements a faraday-middleware for datadog instrumentation
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Methods included from HttpAnnotationHelper
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
20 21 22 23 |
# File 'lib/datadog/tracing/contrib/faraday/middleware.rb', line 20 def initialize(app, = {}) super(app) = end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/datadog/tracing/contrib/faraday/middleware.rb', line 25 def call(env) # Resolve configuration settings to use for this request. # Do this once to reduce expensive regex calls. = (env) Tracing.trace(Ext::SPAN_REQUEST, on_error: [:on_error]) do |span, trace| annotate!(span, env, ) if Tracing::Distributed::PropagationPolicy.enabled?( global_config: , trace: trace ) propagate!(trace, span, env) end app.call(env).on_complete { |resp| handle_response(span, resp, ) } end end |