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) @options = end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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 Datadog::AppSec::Utils::TraceOperation.appsec_standalone_reject?(trace) trace.sampling_priority = Tracing::Sampling::Ext::Priority::AUTO_REJECT end propagate!(trace, span, env) if [:distributed_tracing] && Tracing.enabled? app.call(env).on_complete { |resp| handle_response(span, resp, ) } end end |