raygun-apm 1.1.14-x86_64-linux → 1.1.15.pre2-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,49 +1,49 @@
1
- module Raygun
2
- module Apm
3
- module Blacklist
4
- class Parser
5
- COMMENT = /^#[^<].*/
6
- ANONYMOUS = /^#<.*:.*>?/
7
-
8
- def initialize(tracer)
9
- @tracer = tracer
10
- @translator = Blacklist::Translator.new
11
- end
12
-
13
- def add_filters(filters)
14
- filters.each do |filter|
15
- filter.strip!
16
- add_filter(filter)
17
- end
18
- show_filters
19
- end
20
-
21
- private
22
- def add_filter(filter)
23
- if filter =~ COMMENT && filter !~ ANONYMOUS
24
- return
25
- end
26
- if filter.start_with?('+')
27
- @tracer.add_whitelist *translate(filter[1..-1])
28
- elsif filter.start_with?('-')
29
- @tracer.add_blacklist *translate(filter[1..-1])
30
- elsif filter.start_with?('L-')
31
- @tracer.add_blacklist *translate(filter[2..-1])
32
- elsif filter.size > 0
33
- @tracer.add_blacklist *translate(filter)
34
- end
35
- rescue => e
36
- puts "Failed to add line '#{filter}' to the blacklist (#{e}) #{e.backtrace.join("\n")}"
37
- end
38
-
39
- def show_filters
40
- @tracer.show_filters if @tracer.config.loglevel == Tracer::LOG_BLACKLIST
41
- end
42
-
43
- def translate(filter)
44
- @translator.translate(filter)
45
- end
46
- end
47
- end
48
- end
49
- end
1
+ module Raygun
2
+ module Apm
3
+ module Blacklist
4
+ class Parser
5
+ COMMENT = /^#[^<].*/
6
+ ANONYMOUS = /^#<.*:.*>?/
7
+
8
+ def initialize(tracer)
9
+ @tracer = tracer
10
+ @translator = Blacklist::Translator.new
11
+ end
12
+
13
+ def add_filters(filters)
14
+ filters.each do |filter|
15
+ filter.strip!
16
+ add_filter(filter)
17
+ end
18
+ show_filters
19
+ end
20
+
21
+ private
22
+ def add_filter(filter)
23
+ if filter =~ COMMENT && filter !~ ANONYMOUS
24
+ return
25
+ end
26
+ if filter.start_with?('+')
27
+ @tracer.add_whitelist *translate(filter[1..-1])
28
+ elsif filter.start_with?('-')
29
+ @tracer.add_blacklist *translate(filter[1..-1])
30
+ elsif filter.start_with?('L-')
31
+ @tracer.add_blacklist *translate(filter[2..-1])
32
+ elsif filter.size > 0
33
+ @tracer.add_blacklist *translate(filter)
34
+ end
35
+ rescue => e
36
+ puts "Failed to add line '#{filter}' to the blacklist (#{e}) #{e.backtrace.join("\n")}"
37
+ end
38
+
39
+ def show_filters
40
+ @tracer.show_filters if @tracer.config.loglevel == Tracer::LOG_BLACKLIST
41
+ end
42
+
43
+ def translate(filter)
44
+ @translator.translate(filter)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,79 +1,79 @@
1
- module Raygun
2
- module Apm
3
- module Blacklist
4
- class Translator
5
- class RubyTranslator
6
- # Foo::Bar#baz
7
- # Foo::Bar.baz
8
- # Foo::Bar::baz
9
- COMMENT = /^#.*/
10
- ANONYMOUS = /^#<.*>?/
11
- NAMESPACE = /::/
12
- NAMESPACE_ONLY = /::$/
13
- METHOD = /#|\./
14
- LETTER_CASE = /^[A-Z]/
15
- LOWER_CASE = /^[a-z]/
16
-
17
- def translate(filter)
18
- path, method = nil, nil
19
- if filter !~ COMMENT && filter !~ ANONYMOUS
20
- if filter.end_with?("#")
21
- path = filter
22
- else
23
- path, method = filter.split(METHOD)
24
- end
25
- # .NET fallback
26
- return if method =~ LETTER_CASE && !method.start_with?("Ruby")
27
- if path == path.downcase
28
- method = path
29
- path = nil
30
- end
31
-
32
- # .NET fallback
33
- return if method =~ NAMESPACE
34
- if path && (_method = path.split(NAMESPACE).last) =~ LOWER_CASE
35
- method = _method
36
- path.gsub!(Regexp.compile("::#{method}$"), "")
37
- end
38
- [path, method]
39
- elsif filter =~ ANONYMOUS
40
- _, klass, method = filter.split(METHOD)
41
- ["##{klass}", method]
42
- else
43
- nil
44
- end
45
- end
46
- end
47
-
48
- # References https://raygun.com/documentation/product-guides/apm/blacklist/
49
- class DotnetTranslator
50
- # Foo.Bar::Baz
51
- COMMENT = /^#/
52
- NAMESPACE = /\./
53
- METHOD = /::/
54
-
55
- def translate(filter)
56
- if filter !~ COMMENT
57
- path, method = nil, nil
58
- path, method = filter.split(METHOD)
59
- path.gsub!(NAMESPACE, "::")
60
- [path, method]
61
- else
62
- nil
63
- end
64
- end
65
- end
66
-
67
- def initialize
68
- @ruby = RubyTranslator.new
69
- @dotnet = DotnetTranslator.new
70
- end
71
-
72
- def translate(filter)
73
- translated = @ruby.translate(filter)
74
- translated ? translated : @dotnet.translate(filter)
75
- end
76
- end
77
- end
78
- end
1
+ module Raygun
2
+ module Apm
3
+ module Blacklist
4
+ class Translator
5
+ class RubyTranslator
6
+ # Foo::Bar#baz
7
+ # Foo::Bar.baz
8
+ # Foo::Bar::baz
9
+ COMMENT = /^#.*/
10
+ ANONYMOUS = /^#<.*>?/
11
+ NAMESPACE = /::/
12
+ NAMESPACE_ONLY = /::$/
13
+ METHOD = /#|\./
14
+ LETTER_CASE = /^[A-Z]/
15
+ LOWER_CASE = /^[a-z]/
16
+
17
+ def translate(filter)
18
+ path, method = nil, nil
19
+ if filter !~ COMMENT && filter !~ ANONYMOUS
20
+ if filter.end_with?("#")
21
+ path = filter
22
+ else
23
+ path, method = filter.split(METHOD)
24
+ end
25
+ # .NET fallback
26
+ return if method =~ LETTER_CASE && !method.start_with?("Ruby")
27
+ if path == path.downcase
28
+ method = path
29
+ path = nil
30
+ end
31
+
32
+ # .NET fallback
33
+ return if method =~ NAMESPACE
34
+ if path && (_method = path.split(NAMESPACE).last) =~ LOWER_CASE
35
+ method = _method
36
+ path.gsub!(Regexp.compile("::#{method}$"), "")
37
+ end
38
+ [path, method]
39
+ elsif filter =~ ANONYMOUS
40
+ _, klass, method = filter.split(METHOD)
41
+ ["##{klass}", method]
42
+ else
43
+ nil
44
+ end
45
+ end
46
+ end
47
+
48
+ # References https://raygun.com/documentation/product-guides/apm/blacklist/
49
+ class DotnetTranslator
50
+ # Foo.Bar::Baz
51
+ COMMENT = /^#/
52
+ NAMESPACE = /\./
53
+ METHOD = /::/
54
+
55
+ def translate(filter)
56
+ if filter !~ COMMENT
57
+ path, method = nil, nil
58
+ path, method = filter.split(METHOD)
59
+ path.gsub!(NAMESPACE, "::")
60
+ [path, method]
61
+ else
62
+ nil
63
+ end
64
+ end
65
+ end
66
+
67
+ def initialize
68
+ @ruby = RubyTranslator.new
69
+ @dotnet = DotnetTranslator.new
70
+ end
71
+
72
+ def translate(filter)
73
+ translated = @ruby.translate(filter)
74
+ translated ? translated : @dotnet.translate(filter)
75
+ end
76
+ end
77
+ end
78
+ end
79
79
  end