Sha256: 925db313c91fe6e8582eb0974bf736e9ec04175814fd724bf5139277c13e96fc

Contents?: true

Size: 655 Bytes

Versions: 2

Compression:

Stored size: 655 Bytes

Contents

# frozen_string_literal: true

require 'rack'

module OpenTracing
  module Instrumentation
    module Rack
      # RegexpPathSanitazer return raw path
      class RegexpPathSanitazer
        DEFAULT_REPLACE_MAP = {
          '/:object_id\1' => %r{/[0-9a-f]{24}(/|$)},
          '/:sequence_id\1' => %r{/\d+(/|$)},
        }.freeze

        def initialize(
          replace_map: DEFAULT_REPLACE_MAP
        )
          @replace_map = replace_map
        end

        def sanitaze_path(path)
          @replace_map.each do |(target, regexp)|
            path = path.gsub(regexp, target)
          end
          path
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opentracing-instrumentation-0.1.3 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
opentracing-instrumentation-0.1.2 lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb