Sha256: 172e256c76c37219c9beef2b8db9e348d559efde01c564e677d4575495a6f613
Contents?: true
Size: 1.3 KB
Versions: 57
Compression:
Stored size: 1.3 KB
Contents
# typed: false # frozen_string_literal: true require "opentelemetry" require "active_support/parameter_filter" module Hephaestus module Middleware class TracingAttributes attr_reader :app HTTP_REQUEST_CONTENT_LENGTH = "http.request_content_length" HTTP_REQUEST_BODY = "http.request.body" def initialize(app) @app = app @filterer = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters) end 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 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 end end end
Version data entries
57 entries across 57 versions & 1 rubygems