fluent-plugin-detect-exceptions 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,9 +22,9 @@ class DetectExceptionsOutputTest < Test::Unit::TestCase
22
22
  Fluent::Test.setup
23
23
  end
24
24
 
25
- CONFIG = <<END.freeze
26
- remove_tag_prefix prefix
27
- END
25
+ CONFIG = <<~END_CONFIG.freeze
26
+ remove_tag_prefix prefix
27
+ END_CONFIG
28
28
 
29
29
  DEFAULT_TAG = 'prefix.test.tag'.freeze
30
30
 
@@ -32,37 +32,37 @@ END
32
32
 
33
33
  ARBITRARY_TEXT = 'This line is not an exception.'.freeze
34
34
 
35
- JAVA_EXC = <<END.freeze
36
- SomeException: foo
37
- at bar
38
- Caused by: org.AnotherException
39
- at bar2
40
- at bar3
41
- END
42
-
43
- PHP_EXC = <<END.freeze
44
- exception 'Exception' with message 'Custom exception' in /home/joe/work/test-php/test.php:5
45
- Stack trace:
46
- #0 /home/joe/work/test-php/test.php(9): func1()
47
- #1 /home/joe/work/test-php/test.php(13): func2()
48
- #2 {main}
49
- END
50
-
51
- PYTHON_EXC = <<END.freeze
52
- Traceback (most recent call last):
53
- File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
54
- rv = self.handle_exception(request, response, e)
55
- Exception: ('spam', 'eggs')
56
- END
57
-
58
- RUBY_EXC = <<END.freeze
59
- examble.rb:18:in `thrower': An error has occurred. (RuntimeError)
60
- from examble.rb:14:in `caller'
61
- from examble.rb:10:in `helper'
62
- from examble.rb:6:in `writer'
63
- from examble.rb:2:in `runner'
64
- from examble.rb:21:in `<main>'
65
- END
35
+ JAVA_EXC = <<~END_JAVA.freeze
36
+ SomeException: foo
37
+ at bar
38
+ Caused by: org.AnotherException
39
+ at bar2
40
+ at bar3
41
+ END_JAVA
42
+
43
+ PHP_EXC = <<~END_PHP.freeze
44
+ exception 'Exception' with message 'Custom exception' in /home/joe/work/test-php/test.php:5
45
+ Stack trace:
46
+ #0 /home/joe/work/test-php/test.php(9): func1()
47
+ #1 /home/joe/work/test-php/test.php(13): func2()
48
+ #2 {main}
49
+ END_PHP
50
+
51
+ PYTHON_EXC = <<~END_PYTHON.freeze
52
+ Traceback (most recent call last):
53
+ File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
54
+ rv = self.handle_exception(request, response, e)
55
+ Exception: ('spam', 'eggs')
56
+ END_PYTHON
57
+
58
+ RUBY_EXC = <<~END_RUBY.freeze
59
+ examble.rb:18:in `thrower': An error has occurred. (RuntimeError)
60
+ from examble.rb:14:in `caller'
61
+ from examble.rb:10:in `helper'
62
+ from examble.rb:6:in `writer'
63
+ from examble.rb:2:in `runner'
64
+ from examble.rb:21:in `<main>'
65
+ END_RUBY
66
66
 
67
67
  def create_driver(conf = CONFIG, tag = DEFAULT_TAG)
68
68
  d = Fluent::Test::OutputTestDriver.new(Fluent::DetectExceptionsOutput, tag)
@@ -76,22 +76,22 @@ END
76
76
  log_entry
77
77
  end
78
78
 
79
- def feed_lines_without_line_breaks(driver, t, *messages, stream: nil)
79
+ def feed_lines_without_line_breaks(driver, timestamp, *messages, stream: nil)
80
80
  count = 0
81
81
  messages.each do |m|
82
82
  m.each_line do |line|
83
83
  line.delete!("\n")
84
- driver.emit(log_entry(line, count, stream), t + count)
84
+ driver.emit(log_entry(line, count, stream), timestamp + count)
85
85
  count += 1
86
86
  end
87
87
  end
88
88
  end
89
89
 
90
- def feed_lines(driver, t, *messages, stream: nil)
90
+ def feed_lines(driver, timestamp, *messages, stream: nil)
91
91
  count = 0
92
92
  messages.each do |m|
93
93
  m.each_line do |line|
94
- driver.emit(log_entry(line, count, stream), t + count)
94
+ driver.emit(log_entry(line, count, stream), timestamp + count)
95
95
  count += 1
96
96
  end
97
97
  end
@@ -104,11 +104,11 @@ END
104
104
  end
105
105
  end
106
106
 
107
- def make_logs(t, *messages, stream: nil)
107
+ def make_logs(timestamp, *messages, stream: nil)
108
108
  count = 0
109
109
  logs = []
110
110
  messages.each do |m|
111
- logs << [t + count, log_entry(m, count, stream)]
111
+ logs << [timestamp + count, log_entry(m, count, stream)]
112
112
  count += m.lines.count
113
113
  end
114
114
  logs
@@ -148,7 +148,7 @@ languages #{language})
148
148
  single_line_exception = exception.gsub("\n", '\\n')
149
149
 
150
150
  # There is a nested exception within the body, we should ignore those!
151
- json_line_with_exception = {
151
+ json_with_exception = {
152
152
  'timestamp' => {
153
153
  'nanos' => 998_152_494,
154
154
  'seconds' => 1_496_420_064
@@ -156,8 +156,9 @@ languages #{language})
156
156
  'message' => single_line_exception,
157
157
  'thread' => 139_658_267_147_048,
158
158
  'severity' => 'ERROR'
159
- }.to_json + "\n"
160
- json_line_without_exception = {
159
+ }
160
+ json_line_with_exception = "#{json_with_exception.to_json}\n"
161
+ json_without_exception = {
161
162
  'timestamp' => {
162
163
  'nanos' => 5_990_266,
163
164
  'seconds' => 1_496_420_065
@@ -165,7 +166,8 @@ languages #{language})
165
166
  'message' => 'next line',
166
167
  'thread' => 139_658_267_147_048,
167
168
  'severity' => 'INFO'
168
- }.to_json + "\n"
169
+ }
170
+ json_line_without_exception = "#{json_without_exception.to_json}\n"
169
171
 
170
172
  router_mock = flexmock('router')
171
173
 
@@ -245,7 +247,7 @@ multiline_flush_interval 1)
245
247
  feed_lines(d, t2, " at x\n at y\n")
246
248
  d.instance.before_shutdown
247
249
  end
248
- assert_equal(make_logs(t1, JAVA_EXC + " at x\n at y\n"), d.events)
250
+ assert_equal(make_logs(t1, "#{JAVA_EXC} at x\n at y\n"), d.events)
249
251
  end
250
252
 
251
253
  def test_remove_tag_prefix_is_required
@@ -317,9 +319,9 @@ max_lines 2)
317
319
  # For the following Java stack trace, the two lines of the first exception
318
320
  # are buffered and combined. So are the first two lines of the second
319
321
  # exception. Then the rest is logged line-by-line.
320
- expected = [PYTHON_EXC.lines[0..1].join] + PYTHON_EXC.lines[2..-1] + \
322
+ expected = [PYTHON_EXC.lines[0..1].join] + PYTHON_EXC.lines[2..] + \
321
323
  [JAVA_EXC.lines[0..1].join] + [JAVA_EXC.lines[2..3].join] + \
322
- JAVA_EXC.lines[4..-1]
324
+ JAVA_EXC.lines[4..]
323
325
  assert_equal(make_logs(t, *expected), d.events)
324
326
  end
325
327
 
@@ -332,9 +334,9 @@ stream stream)
332
334
  d.run do
333
335
  feed_lines(d, t, JAVA_EXC.lines[0], stream: 'java')
334
336
  feed_lines(d, t, PYTHON_EXC.lines[0..1].join, stream: 'python')
335
- feed_lines(d, t, JAVA_EXC.lines[1..-1].join, stream: 'java')
337
+ feed_lines(d, t, JAVA_EXC.lines[1..].join, stream: 'java')
336
338
  feed_lines(d, t, JAVA_EXC, stream: 'java')
337
- feed_lines(d, t, PYTHON_EXC.lines[2..-1].join, stream: 'python')
339
+ feed_lines(d, t, PYTHON_EXC.lines[2..].join, stream: 'python')
338
340
  feed_lines(d, t, 'something else', stream: 'java')
339
341
  end
340
342
  # Expected: the Python and the Java exceptions are handled separately
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-detect-exceptions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stackdriver Agents
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-07 00:00:00.000000000 Z
11
+ date: 2023-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -25,61 +25,61 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.10'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: flexmock
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.3'
33
+ version: '2.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.3'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rubocop
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.42.0
47
+ version: '10.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.42.0
54
+ version: '10.3'
55
55
  - !ruby/object:Gem::Dependency
56
- name: test-unit
56
+ name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: 1.48.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: 1.48.1
69
69
  - !ruby/object:Gem::Dependency
70
- name: flexmock
70
+ name: test-unit
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.0'
75
+ version: '3.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.0'
82
+ version: '3.0'
83
83
  description: |2
84
84
  Fluentd output plugin which detects exception stack traces in a stream of
85
85
  JSON log messages and combines all single-line messages that belong to the
@@ -93,6 +93,7 @@ extra_rdoc_files: []
93
93
  files:
94
94
  - CONTRIBUTING
95
95
  - Gemfile
96
+ - Gemfile.lock
96
97
  - LICENSE
97
98
  - README.rdoc
98
99
  - Rakefile
@@ -115,14 +116,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
116
  requirements:
116
117
  - - ">="
117
118
  - !ruby/object:Gem::Version
118
- version: '2.0'
119
+ version: '2.6'
119
120
  required_rubygems_version: !ruby/object:Gem::Requirement
120
121
  requirements:
121
122
  - - ">="
122
123
  - !ruby/object:Gem::Version
123
124
  version: '0'
124
125
  requirements: []
125
- rubygems_version: 3.0.8
126
+ rubygems_version: 3.1.6
126
127
  signing_key:
127
128
  specification_version: 4
128
129
  summary: fluentd output plugin for combining stack traces as multi-line JSON logs