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)


25
26
27
28
29
30
31
32
33
# File 'lib/ruby-zipkin/trace_filter.rb', line 25

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
17
18
19
20
21
# 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

  keyword_blacklist.each do |key|
    if uri.to_s.match key
      return true
    end
  end

  return false
end