class OpenTracing::Instrumentation::Rack::UrlCommandNameBuilder
UrlCommandNameBuilder
build command name with request url
Constants
- DEFAULT_COMMAND_PATTERN
Public Class Methods
new( command_pattern: DEFAULT_COMMAND_PATTERN, host_sanitazer: RegexpHostSanitazer.new, path_sanitazer: RegexpPathSanitazer.new )
click to toggle source
# File lib/opentracing/instrumentation/rack/url_command_name_builder.rb, line 13 def initialize( command_pattern: DEFAULT_COMMAND_PATTERN, host_sanitazer: RegexpHostSanitazer.new, path_sanitazer: RegexpPathSanitazer.new ) @command_pattern = command_pattern @host_sanitazer = host_sanitazer @path_sanitazer = path_sanitazer end
Public Instance Methods
build_command_name(env)
click to toggle source
# File lib/opentracing/instrumentation/rack/url_command_name_builder.rb, line 23 def build_command_name(env) format(@command_pattern, pattern_args(env)) end
Private Instance Methods
pattern_args(env)
click to toggle source
# File lib/opentracing/instrumentation/rack/url_command_name_builder.rb, line 29 def pattern_args(env) path = env[::Rack::REQUEST_PATH] sanitazed_path = @path_sanitazer.sanitaze_path(path) { schema: env[::Rack::RACK_URL_SCHEME], method: env[::Rack::REQUEST_METHOD], host: sanitaze_host(env[::Rack::HTTP_HOST]), port: env[::Rack::HTTP_PORT], path: sanitazed_path, } end
sanitaze_host(host)
click to toggle source
# File lib/opentracing/instrumentation/rack/url_command_name_builder.rb, line 41 def sanitaze_host(host) return if host.nil? @host_sanitazer.sanitaze_host(host) end