hoss-agent 1.0.3 → 1.0.8

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: 0a5dc8f27616545b119c326f640f637d2771adb92a39f6e60c5efc6f7635f6ea
4
- data.tar.gz: 3962d5f37d1fe1d2695daa6c51bdc6a8402a6eeb4a7504014de2d31cb06f7809
3
+ metadata.gz: 8e6c9d937aeedc94daaf59fbcefd4a37bf5982662586489b659913b47d2e27b3
4
+ data.tar.gz: 0a7f8e92ce4eef17f8415946c2e620a390c4bf99fb99df23f6e1c2c5284b6918
5
5
  SHA512:
6
- metadata.gz: 4c4eef26d646864c31ddb0aeee65532162f4a85c68b7f563b4babe3b5cec1bbdbca9c420cd9cd1969498a1569c865703eccfa26011040fa149c13e7c4db57a15
7
- data.tar.gz: 6ad4c3a97be28038aa69e196af7aa559472ed14fbd2ab2d968fc44364f896e78ae9fa48c68a6fb443267ef24e724f03927903c2d3ed6b704314ca2fc8e5c0197
6
+ metadata.gz: e5716d01ea3752aaa88bdcd48a37819a70602752e21e56ab7a816d15cda3b3db835a72c4247ef02b276518cface16467c11fb658be8c6d23207a2c83bf196d4b
7
+ data.tar.gz: 137ad627f7cd3565aeff78d02aed3ede01a2f20106e1333aeaeba71ef180402e964969a8cde302ba1b43dabbf14c598017411a5497f8bc7596bd897e235e1df5
@@ -103,6 +103,10 @@ module Hoss
103
103
  def_delegator :@central_config, :config
104
104
 
105
105
  def start
106
+ unless config.api_key
107
+ config.logger.warn "Hoss API Key missing, not starting."
108
+ return
109
+ end
106
110
  unless config.disable_start_message?
107
111
  config.logger.info format(
108
112
  '[%s] Starting agent, reporting to %s',
@@ -41,7 +41,7 @@ module Hoss
41
41
  option :remote_config_fetch_interval, type: :int, default: 300
42
42
  option :agentConfig, type: :dict
43
43
  option :debug, type: :boolean, default: ENV['HOSS_DEBUG']
44
-
44
+ option :disable_reporting, type: :boolean, default: ENV['HOSS_DISABLE_REPORTING'] == 'true'
45
45
 
46
46
  option :central_config, type: :bool, default: true
47
47
  option :capture_body, type: :string, default: 'off'
@@ -109,7 +109,9 @@ module Hoss
109
109
  )
110
110
  end
111
111
 
112
- warn '[HOSS] No API Key provided' unless self.api_key
112
+ unless self.disable_reporting.nil?
113
+ self.disable_reporting = self.disable_reporting == 'true' || self.disable_reporting == true
114
+ end
113
115
 
114
116
  yield self if block_given?
115
117
 
@@ -81,7 +81,7 @@ module Hoss
81
81
 
82
82
  result
83
83
  rescue Exception => e
84
- if e.wrapped_exception.is_a? Net::OpenTimeout
84
+ if e.respond_to?(:wrapped_exception) && e.wrapped_exception.is_a?(Net::OpenTimeout)
85
85
  event.error = Hoss::Event::Error.new(Hoss::Event::Error::ConnectionTimeout)
86
86
  else
87
87
  event.error = Hoss::Event::Error.new(Hoss::Event::Error::ConnectionError)
@@ -45,7 +45,7 @@ module Hoss
45
45
  return perform_without_apm(req, options)
46
46
  end
47
47
  Hoss.with_event do |event|
48
- event.request.headers['host'] = req.uri.hostname
48
+ event.request.headers['host'] = req.uri.host
49
49
  req.headers.each {|n,v| event.request.headers[n] = v}
50
50
  event.request.method = req.verb.to_s.upcase
51
51
  event.request.url = req.uri.to_s
@@ -58,7 +58,7 @@ module Hoss
58
58
  event.response.received_at = DateTime.now.strftime('%Q').to_i
59
59
  event.response.status_code = result.code.to_i
60
60
  result.headers.each {|n,v| event.response.headers[n] = v}
61
- event.response.body = result.body.dup.to_s
61
+ event.response.body = result.body.to_s
62
62
  end
63
63
  result
64
64
  rescue HTTP::TimeoutError => e
@@ -61,100 +61,108 @@ 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
+ if config.disable_reporting
151
+ debug "Reprting disabled, skipping"
152
+ else
153
+ connection.write(json)
154
+ end
155
+ rescue Exception => e
156
+ error format('Failed send report: %s %s', e.inspect, e.backtrace)
157
+ batch.each do |m|
158
+ m.retries += 1
159
+ queue.push(m, false)
160
+ end
161
+ sleep 1
155
162
  end
156
- sleep 1
157
163
  end
164
+ rescue Exception => e
165
+ debug "error in worker #{e.inspect}"
158
166
  end
159
167
  end
160
168
  rescue Exception => e
@@ -183,6 +191,9 @@ module Hoss
183
191
  else
184
192
  body
185
193
  end
194
+ rescue Exception => e
195
+ debug "unable to decompress body #{e.inspect}"
196
+ return nil
186
197
  end
187
198
 
188
199
  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.3'
21
+ VERSION = '1.0.8'
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoss-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Cooper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-17 00:00:00.000000000 Z
11
+ date: 2020-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby