Class: RubyZipkin::TraceFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-zipkin/trace_filter.rb

Class Method Summary collapse

Class Method Details

.KeywordFilterMatches?(keyword, keyword_blacklist = []) ⇒ Boolean

Filter a string based on a keyword blacklist Meant to define if a key should be traced or not.

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
# File 'lib/ruby-zipkin/trace_filter.rb', line 20

def self.KeywordFilterMatches?(keyword, keyword_blacklist = [])
  #exclude static content requests
  keyword_blacklist.each do |blacklisted|
    if keyword.to_s.match(/.*(#{blacklisted}).*/)
      return true
    end
  end
  false
end

.UriFilterMatches?(uri, keyword_blacklist = []) ⇒ Boolean

Filter uri’s from being traced based on their type or a keyword listed in the blacklist Known static content requests like fonts are filtered as well

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
16
# File 'lib/ruby-zipkin/trace_filter.rb', line 8

def self.UriFilterMatches?(uri, keyword_blacklist = [])
  #exclude static content requests
  if uri.to_s.match(/.*(\.svg)|(\.ttf)|(\.ott)|(\.woff)/)
    return true
  end

  #check the uri against the blacklist
  return KeywordFilterMatches?(uri, keyword_blacklist)
end