Sha256: da20da41cb125d50ccc5fc086eb4cf3b4b4634d2698f48015c3529b0358a6708

Contents?: true

Size: 899 Bytes

Versions: 7

Compression:

Stored size: 899 Bytes

Contents

# frozen_string_literal: true

require 'elastic_apm/filters/request_body_filter'
require 'elastic_apm/filters/secrets_filter'

module ElasticAPM
  # @api private
  module Filters
    def self.new(config)
      Container.new(config)
    end

    # @api private
    class Container
      def initialize(config)
        @config = config
        @filters = {
          request_body: RequestBodyFilter.new(config),
          secrets: SecretsFilter.new(config)
        }
      end

      attr_reader :config

      def add(key, filter)
        @filters[key] = filter
      end

      def remove(key)
        @filters.delete(key)
      end

      def apply(payload)
        @filters.reduce(payload) do |result, (_key, filter)|
          result = filter.call(result)
          break if result.nil?
          result
        end
      end

      def length
        @filters.length
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
elastic-apm-1.1.0 lib/elastic_apm/filters.rb
elastic-apm-1.0.2 lib/elastic_apm/filters.rb
elastic-apm-1.0.1 lib/elastic_apm/filters.rb
elastic-apm-1.0.0 lib/elastic_apm/filters.rb
elastic-apm-1.0.0.beta2 lib/elastic_apm/filters.rb
elastic-apm-1.0.0.beta1 lib/elastic_apm/filters.rb
elastic-apm-0.8.0 lib/elastic_apm/filters.rb