logjam_agent 0.27.0 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52d512cc6fe0a7ce5767156b12a2a9d95e552ef36f2333e7ddabf75ed74f19c5
4
- data.tar.gz: 2d671e9ba73b11f9140f343157d5d22746ed729e54deb0a4f717f1ee462f66fb
3
+ metadata.gz: 42a443531b0f42f9a5facc12e29186e0588e65a503ed066747d4a01e8545c4d7
4
+ data.tar.gz: e9b3e84141df640116d7992707e2e16d783d3c61aeff6204202cc177f64706c2
5
5
  SHA512:
6
- metadata.gz: 8b22a1a1b6ad30072ac6d6ba07a1d4758d245b2ca98382c30dd5378082d6c6530e2f5723fff4db90b71d811fa9274eb8e8d56988f84eeb208dae687975bf6e09
7
- data.tar.gz: 1f133bb814007b037158ed3088ae8f5f5bd77387c97e4e4036c23fdfb2f816a309cd309e8ed118ee038db8409c5582706108c419d009c14b00e86808a30298e8
6
+ metadata.gz: 3d4072d17788175b864c19bee9fd0e200fac5bc8bf9efa30d20d4eecc02c51f1ef95117c463c187e9fbd41f19a5604d598de0ebd3d65adeb4014bfb9dcd8e6ac
7
+ data.tar.gz: 9dd5d5b9a0a79e406567925ed7a18b2a93a8619d60042f4cf38ebd258018c32c023d38ce1e8911ac397c045c1f3799355ab4dcd99d0be9ff1cd8a701761138e7
data/README.md CHANGED
@@ -5,16 +5,11 @@ Client side library for logjam.
5
5
  Hooks into Rails, collects log lines, performance metrics, error/exception infomation and Rack
6
6
  environment information and sends this data to [Logjam](https://github.com/skaes/logjam_app).
7
7
 
8
- Currently two alternate mechanisms are available for data transport: AMQP or ZeroMQ.
8
+ Currently only one mechanism is available for data transport:
9
+ ZeroMQ. Support for AMQP has been dropped.
9
10
 
10
11
  ## Usage
11
12
 
12
- For AMQP, add
13
-
14
- ```ruby
15
- gem "logjam_agent"
16
- gem "bunny"
17
- ```
18
13
  For ZeroMQ, add
19
14
 
20
15
  ```ruby
@@ -50,9 +45,6 @@ module LogjamAgent
50
45
  :rcv_timeo => 5000,
51
46
  :snd_timeo => 5000)
52
47
 
53
- # Configure request data forwarder for AMQP.
54
- # add_forwarder(:amqp, :host => "message.broker.at.your.org")
55
-
56
48
  # Configure ip obfuscation. Defaults to no obfuscation.
57
49
  self.obfuscate_ips = true
58
50
 
@@ -162,8 +154,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
162
154
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
163
155
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
164
156
  THE SOFTWARE.
165
-
166
-
167
-
168
-
169
-
@@ -30,7 +30,6 @@ end
30
30
 
31
31
  require "logjam_agent/version"
32
32
  require "logjam_agent/util"
33
- require "logjam_agent/amqp_forwarder"
34
33
  require "logjam_agent/zmq_forwarder"
35
34
  require "logjam_agent/forwarders"
36
35
  require "logjam_agent/request"
@@ -269,7 +268,7 @@ module LogjamAgent
269
268
  def self.add_forwarder(type, *args)
270
269
  case type
271
270
  when :zmq then Forwarders.add(ZMQForwarder.new(*args))
272
- when :amqp then Forwarders.add(AMQPForwarder.new(*args))
271
+ when :amqp then ArgumentError.new("logjam amqp transport no longer supported")
273
272
  else raise ArgumentError.new("unkown logjam transport: '#{type}'")
274
273
  end
275
274
  end
@@ -16,8 +16,7 @@ module LogjamAgent
16
16
  @@forwarders.each_value {|f| f.reset}
17
17
  end
18
18
 
19
- # properly close AMQP connections on program termination
20
- # this avoids 'connection_closed_abruptly' in the rabbit logs
19
+ # properly close open sockets on program termination
21
20
  at_exit { reset }
22
21
 
23
22
  def inspect
@@ -1,3 +1,3 @@
1
1
  module LogjamAgent
2
- VERSION = "0.27.0"
2
+ VERSION = "0.28.0"
3
3
  end
@@ -28,4 +28,6 @@ Gem::Specification.new do |s|
28
28
 
29
29
  s.add_runtime_dependency "activesupport"
30
30
  s.add_runtime_dependency "time_bandits", [">= 0.6.0"]
31
+ s.add_runtime_dependency "ffi-rzmq-core", [">= 1.0.5"]
32
+ s.add_runtime_dependency "ffi-rzmq", [">= 2.0.4"]
31
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logjam_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kaes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-17 00:00:00.000000000 Z
11
+ date: 2018-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -136,6 +136,34 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.6.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: ffi-rzmq-core
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 1.0.5
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 1.0.5
153
+ - !ruby/object:Gem::Dependency
154
+ name: ffi-rzmq
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 2.0.4
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 2.0.4
139
167
  description: Logjam logger and request information forwarding
140
168
  email:
141
169
  - stefan.kaes@xing.com
@@ -149,7 +177,6 @@ files:
149
177
  - Rakefile
150
178
  - lib/logjam_agent.rb
151
179
  - lib/logjam_agent/actionpack/lib/action_dispatch/middleware/remote_ip.rb
152
- - lib/logjam_agent/amqp_forwarder.rb
153
180
  - lib/logjam_agent/buffered_logger.rb
154
181
  - lib/logjam_agent/forwarders.rb
155
182
  - lib/logjam_agent/middleware.rb
@@ -162,7 +189,6 @@ files:
162
189
  - lib/logjam_agent/zmq_forwarder.rb
163
190
  - logjam_agent.gemspec
164
191
  - script/console
165
- - test/amqp_forwarder_test.rb
166
192
  - test/request_test.rb
167
193
  - test/test_helper.rb
168
194
  - test/util_test.rb
@@ -186,12 +212,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
212
  version: '0'
187
213
  requirements: []
188
214
  rubyforge_project: logjam_agent
189
- rubygems_version: 2.7.7
215
+ rubygems_version: 2.7.8
190
216
  signing_key:
191
217
  specification_version: 4
192
218
  summary: Logjam client library to be used with logjam
193
219
  test_files:
194
- - test/amqp_forwarder_test.rb
195
220
  - test/request_test.rb
196
221
  - test/test_helper.rb
197
222
  - test/util_test.rb
@@ -1,108 +0,0 @@
1
- module LogjamAgent
2
- class AMQPForwarder
3
-
4
- RETRY_AFTER = 10.seconds
5
-
6
- attr_reader :app, :env
7
-
8
- include LogjamAgent::Util
9
-
10
- def initialize(*args)
11
- opts = args.extract_options!
12
- @app = args[0] || LogjamAgent.application_name
13
- @env = args[1] || LogjamAgent.environment_name
14
- @app_env = "#{@app}-#{@env}"
15
- @config = default_options.merge!(opts)
16
- @exchanges = {}
17
- @bunny = nil
18
- @sequence = 0
19
- @paused = nil
20
- ensure_bunny_gem_is_available
21
- end
22
-
23
- def default_options
24
- {
25
- :host => "localhost",
26
- :exchange_durable => true,
27
- :exchange_auto_delete => false,
28
- }
29
- end
30
-
31
- # TODO: mutex!
32
- def forward(data, options = {})
33
- return if paused?
34
- app_env = options[:app_env] || @app_env
35
- key = options[:routing_key] || "logs.#{app_env.sub('-','.')}"
36
- if engine = options[:engine]
37
- key += ".#{engine}"
38
- end
39
- msg = LogjamAgent.encode_payload(data)
40
- publish(app_env, key, msg)
41
- rescue => error
42
- reraise_expectation_errors!
43
- pause(error)
44
- end
45
-
46
- def publish(app_env, key, data)
47
- info = pack_info(@sequence = next_fixnum(@sequence))
48
- exchange(app_env).publish(data, :key => key, :persistent => false, :headers => {:info => info})
49
- end
50
-
51
- def reset(exception=nil)
52
- return unless @bunny
53
- if exception
54
- @bunny.__send__(:close_socket)
55
- else
56
- @bunny.stop
57
- end
58
- rescue
59
- # swallow StandardError
60
- ensure
61
- # if bunny throws an exception here, its not usable anymore anyway
62
- @exchanges = {}
63
- @bunny = nil
64
- end
65
-
66
- private
67
-
68
- if defined?(Mocha)
69
- def reraise_expectation_errors! #:nodoc:
70
- raise if $!.is_a?(Mocha::ExpectationError)
71
- end
72
- else
73
- def reraise_expectation_errors! #:nodoc:
74
- # noop
75
- end
76
- end
77
-
78
- def pause(exception)
79
- @paused = Time.now
80
- reset(exception)
81
- raise ForwardingError.new("Could not log to AMQP exchange (#{exception.message})")
82
- end
83
-
84
- def paused?
85
- @paused && @paused > RETRY_AFTER.ago
86
- end
87
-
88
- def exchange(app_env)
89
- @exchanges[app_env] ||=
90
- begin
91
- bunny.start unless bunny.connected?
92
- bunny.exchange("request-stream-#{app_env}",
93
- :durable => @config[:exchange_durable],
94
- :auto_delete => @config[:exchange_auto_delete],
95
- :type => :topic)
96
- end
97
- end
98
-
99
- #TODO: verify socket_timout for ruby 1.9
100
- def bunny
101
- @bunny ||= Bunny.new(:host => @config[:host], :socket_timeout => 1.0)
102
- end
103
-
104
- def ensure_bunny_gem_is_available
105
- require "bunny" unless defined?(Bunny)
106
- end
107
- end
108
- end
@@ -1,32 +0,0 @@
1
- require_relative "test_helper.rb"
2
-
3
- module LogjamAgent
4
- class AMQPForwarderTest < MiniTest::Test
5
- def setup
6
- AMQPForwarder.any_instance.expects(:ensure_bunny_gem_is_available)
7
- end
8
-
9
- def teardown
10
- LogjamAgent.compression_method = NO_COMPRESSION
11
- end
12
-
13
- test "encodes the payload" do
14
- data = {a: 1, b: "str"}
15
- msg = LogjamAgent.encode_payload(data)
16
- f = AMQPForwarder.new
17
- f.expects(:publish).with("a-b", "x", msg)
18
- f.forward(data, :routing_key => "x", :app_env => "a-b")
19
- end
20
-
21
- test "compressed message using snappy can be uncompressed" do
22
- data = {a: 1, b: "str"}
23
- normal_msg = LogjamAgent.encode_payload(data)
24
- LogjamAgent.compression_method = SNAPPY_COMPRESSION
25
- compressed_msg = LogjamAgent.encode_payload(data)
26
- assert_equal normal_msg, Snappy.inflate(compressed_msg)
27
- f = AMQPForwarder.new
28
- f.expects(:publish).with("a-b", "x", compressed_msg)
29
- f.forward(data, :routing_key => "x", :app_env => "a-b")
30
- end
31
- end
32
- end