Class: OpenTelemetry::Instrumentation::Faraday::Middlewares::TracerMiddleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- OpenTelemetry::Instrumentation::Faraday::Middlewares::TracerMiddleware
- Defined in:
- lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb
Overview
TracerMiddleware propagates context and instruments Faraday requests by way of its middlware system
Constant Summary collapse
- HTTP_METHODS_SYMBOL_TO_STRING =
{ connect: 'CONNECT', delete: 'DELETE', get: 'GET', head: 'HEAD', options: 'OPTIONS', patch: 'PATCH', post: 'POST', put: 'PUT', trace: 'TRACE' }.freeze
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb', line 26 def call(env) http_method = HTTP_METHODS_SYMBOL_TO_STRING[env.method] tracer.in_span( "HTTP #{http_method}", attributes: { 'http.method' => http_method, 'http.url' => env.url.to_s }, kind: :client ) do |span| OpenTelemetry.propagation.inject(env.request_headers) app.call(env).on_complete { |resp| trace_response(span, resp) } end end |