hoss-agent 1.0.4 → 1.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8dd2239031e74d5f25fafa6f441f51b3e0d58b9bc751fd71969991fa0761e261
4
- data.tar.gz: db69f9d259c944bfbc935ab0967d20e39403fbaa86169188c597bcc9fff31fcb
3
+ metadata.gz: fc1cebfdfba6abb3ab019045a1faa17d1bcf97a687d0697beb58aad31858f326
4
+ data.tar.gz: 535953f56fb21bfd7c7609a6d108c92ae8b481f68897ae2e70d623db5262d9d3
5
5
  SHA512:
6
- metadata.gz: a05a2e06817b1535ad21b76c0a72ca7bcf148ab3cfce2aeb5e9f96052d4cc3be9e8d6eb802cb270fe65ab08ace0befe92f446236d4ae468428923c9f9716b821
7
- data.tar.gz: 50b283758201a779aa3648cb8f7928682a8fbfd0cb53d8280d89d65956064bed5e4cb4225875d4c2efa3e124848011a1a12c2cef10eee98bc524e143a5d755d5
6
+ metadata.gz: aa5f706cd00e4ad32552dafd841d9058f1ad3eedba861245fe9499f1f4a04af8b4573290d1939eb4a984e9bea878735bb055da4cd2fa4bdce87d12e2d17e81a2
7
+ data.tar.gz: bfab7adec4611a3fb091cf99a28594ea8b7250597ade3d86e0ef9c6a077ccc7f302e4e34981f8c6d2894ae8bbeb49faf2f9948158bed09dfc290b49ba6a3709e
@@ -61,100 +61,104 @@ module Hoss
61
61
 
62
62
  done = false
63
63
  while (!done && msg = queue.pop)
64
- debug 'working message', msg
64
+ begin
65
+ debug 'working message', msg
65
66
 
66
- # wait if we don't have a config
67
- while config.agentConfig.nil?
68
- sleep 0.1
69
- end
70
-
71
- case msg
72
- when StopMessage
73
- debug 'Stopping worker -- %s', self
74
- done = true
75
- break
76
- else
77
- batch = []
78
- current_batch_size = 0
79
-
80
- # Use this as the first message in the batch
81
- event = msg.filtered ? msg : filter_resource(msg)
82
- unless event.nil?
83
- event_size = resource_size(event)
84
- if current_batch_size + event_size <= @config.batch_size
85
- unless host_blacklisted(event)
86
- current_batch_size += event_size
87
- if event.retries < @config.max_event_retries
88
- batch.push(event)
89
- else
90
- debug "max retries hit for event"
67
+ # wait if we don't have a config
68
+ while config.agentConfig.nil?
69
+ sleep 0.1
70
+ end
71
+
72
+ case msg
73
+ when StopMessage
74
+ debug 'Stopping worker -- %s', self
75
+ done = true
76
+ break
77
+ else
78
+ batch = []
79
+ current_batch_size = 0
80
+
81
+ # Use this as the first message in the batch
82
+ event = msg.filtered ? msg : filter_resource(msg)
83
+ unless event.nil?
84
+ event_size = resource_size(event)
85
+ if current_batch_size + event_size <= @config.batch_size
86
+ unless host_blacklisted(event)
87
+ current_batch_size += event_size
88
+ if event.retries < @config.max_event_retries
89
+ batch.push(event)
90
+ else
91
+ debug "max retries hit for event"
92
+ end
91
93
  end
94
+ else
95
+ debug "Event is too large, body needs to be truncated"
92
96
  end
93
- else
94
- debug "Event is too large, body needs to be truncated"
95
97
  end
96
- end
97
98
 
98
- # Do inner loop reading queue to build report
99
- requeue_messages = []
100
- while current_batch_size < @config.batch_size && !queue.empty?
101
- next_msg = queue.pop
102
- case next_msg
103
- when StopMessage
104
- debug 'Stopping worker -- %s', self
105
- done = true
106
- break
107
- else
108
- event = next_msg.filtered ? next_msg : filter_resource(next_msg) unless
109
- unless event.nil?
110
- event_size = resource_size(event)
111
- if current_batch_size + event_size <= @config.batch_size
112
- unless host_blacklisted(event)
113
- current_batch_size += event_size
114
- if event.retries < @config.max_event_retries
115
- batch.push(event)
116
- else
117
- debug "max retries hit for event"
99
+ # Do inner loop reading queue to build report
100
+ requeue_messages = []
101
+ while current_batch_size < @config.batch_size && !queue.empty?
102
+ next_msg = queue.pop
103
+ case next_msg
104
+ when StopMessage
105
+ debug 'Stopping worker -- %s', self
106
+ done = true
107
+ break
108
+ else
109
+ event = next_msg.filtered ? next_msg : filter_resource(next_msg)
110
+ unless event.nil?
111
+ event_size = resource_size(event)
112
+ if current_batch_size + event_size <= @config.batch_size
113
+ unless host_blacklisted(event)
114
+ current_batch_size += event_size
115
+ if event.retries < @config.max_event_retries
116
+ batch.push(event)
117
+ else
118
+ debug "max retries hit for event"
119
+ end
118
120
  end
121
+ else
122
+ debug "Event too large for this batch, requeue"
123
+ requeue_messages.push(event)
119
124
  end
120
- else
121
- debug "Event too large for this batch, requeue"
122
- requeue_messages.push(event)
123
125
  end
124
126
  end
125
127
  end
126
- end
127
-
128
- if batch.length == 0
129
- debug "batch is empty, breaking"
130
- break
131
- end
132
128
 
133
- debug "Requeue #{requeue_messages.length} messages" if requeue_messages.length > 0
134
- requeue_messages.each {|msg| queue.push(msg, false) }
129
+ if batch.length == 0
130
+ debug "batch is empty, breaking"
131
+ break
132
+ end
135
133
 
136
- report = Report.new
137
- report.events = batch.map {|event| serializers.serialize(event) }
134
+ debug "Requeue #{requeue_messages.length} messages" if requeue_messages.length > 0
135
+ requeue_messages.each {|msg| queue.push(msg, false) }
138
136
 
139
- debug "Finished building report"
140
- data = serializers.serialize(report)
141
- json = JSON.fast_generate(data)
142
- begin
143
- debug json
144
- rescue Exception => e
145
- debug 'unable to print body'
146
- puts json if config.debug
147
- end
148
- begin
149
- connection.write(json)
150
- rescue Exception => e
151
- error format('Failed send report: %s %s', e.inspect, e.backtrace)
152
- batch.each do |m|
153
- m.retries += 1
154
- queue.push(m, false)
137
+ report = Report.new
138
+ report.events = batch.map {|event| serializers.serialize(event) }
139
+
140
+ debug "Finished building report"
141
+ data = serializers.serialize(report)
142
+ json = JSON.fast_generate(data)
143
+ begin
144
+ debug json
145
+ rescue Exception => e
146
+ debug 'unable to print body'
147
+ puts json if config.debug
148
+ end
149
+ begin
150
+ connection.write(json)
151
+ rescue Exception => e
152
+ error format('Failed send report: %s %s', e.inspect, e.backtrace)
153
+ batch.each do |m|
154
+ m.retries += 1
155
+ queue.push(m, false)
156
+ end
157
+ sleep 1
155
158
  end
156
- sleep 1
157
159
  end
160
+ rescue Exception => e
161
+ debug "error in worker #{e.inspect}"
158
162
  end
159
163
  end
160
164
  rescue Exception => e
@@ -183,6 +187,9 @@ module Hoss
183
187
  else
184
188
  body
185
189
  end
190
+ rescue Exception => e
191
+ debug "unable to decompress body #{e.inspect}"
192
+ return nil
186
193
  end
187
194
 
188
195
  def get_header(headers, name)
@@ -18,5 +18,5 @@
18
18
  # frozen_string_literal: true
19
19
 
20
20
  module Hoss
21
- VERSION = '1.0.4'
21
+ VERSION = '1.0.5'
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoss-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Cooper