Class: Hephaestus::Middleware::TracingAttributes
- Defined in:
- lib/hephaestus/middleware/tracing_attributes.rb
Constant Summary collapse
- HTTP_REQUEST_CONTENT_LENGTH =
"http.request_content_length"
- HTTP_REQUEST_BODY =
"http.request.body"
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ TracingAttributes
constructor
A new instance of TracingAttributes.
- #process_tracing_body(request) ⇒ Object
Constructor Details
#initialize(app) ⇒ TracingAttributes
Returns a new instance of TracingAttributes.
15 16 17 18 |
# File 'lib/hephaestus/middleware/tracing_attributes.rb', line 15 def initialize(app) @app = app @filterer = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters) end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
10 11 12 |
# File 'lib/hephaestus/middleware/tracing_attributes.rb', line 10 def app @app end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hephaestus/middleware/tracing_attributes.rb', line 20 def call(env) request = ActionDispatch::Request.new(env.dup) OpenTelemetry::Trace.current_span.add_attributes({ "version" => Hephaestus::Engine::GIT_SHA, HTTP_REQUEST_CONTENT_LENGTH => env["CONTENT_LENGTH"].to_i, HTTP_REQUEST_BODY => process_tracing_body(request), }) app.call(env) end |
#process_tracing_body(request) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/hephaestus/middleware/tracing_attributes.rb', line 32 def process_tracing_body(request) if Rails.configuration.respond_to?(:tracing_body_filters) Rails.configuration.tracing_body_filters.each do |path, filter| next unless request.path.starts_with?(path) result = filter.call(request) return result if result.is_a?(String) return result.to_json end end params = request.params @filterer.filter(params).to_json end |