logjam_agent 0.16.0 → 0.17.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
  SHA1:
3
- metadata.gz: 27c960ded3fc0d72bf9712505dc0bae9b401c4ad
4
- data.tar.gz: 9ffc60c42b42a2774f5e8652dd5696bbcfe8a599
3
+ metadata.gz: fa38a215553f0e5b93916fbe5f5b1f23d25a088d
4
+ data.tar.gz: 86d813bd6c4ca2830637eca5799d4e23866434de
5
5
  SHA512:
6
- metadata.gz: 4f33b5fc478e0d43f6f7aae8884cc809632b71747b772e5da4c1ac049266337a5f656dd569653772d34870dd6a058fd3671f140b6fd2c860c483f7c397abecda
7
- data.tar.gz: 20aad7ff6e1fd3404112575aa182cfcadfc2f24e69e8ccce941127bfabb09cf9ab6ee63f5bdf86e4e961ad7d082d51528263ab9cf54ac480841714d3613ae2d5
6
+ metadata.gz: 2a6fef99a5b96a77e12d5467ee064187499cfce06f2d179a6a110753d8997ff477903bea56f5d3b97faeb426c9fa6cb1116f1aa65b780d237e271aac6763c74a
7
+ data.tar.gz: 3e0055031a828a202bb9d12db658e9437eabe9bfa22b39a6c9c8eb787dde3312a423d80e9169936a4cf177c8e4f6d4d0286554f2d886c18d519a88c5f73b76cf
data/README.md CHANGED
@@ -78,6 +78,12 @@ module LogjamAgent
78
78
  # Configure max bytes allowed for all log lines. Defaults to 1Mb.
79
79
  # This setting only applies to the lines sent with the request.
80
80
  self.max_bytes_all_lines = 1024 * 1024
81
+
82
+ # Configure compression method. Defaults to NO_COMPRESSION. Available
83
+ # compression methods are GZIP_COMPRESSION and SNAPPY_COMPRESSION.
84
+ # Snappy is faster and less CPU intensive than GZIP, GZIP achieves
85
+ # higher compression rates.
86
+ # self.compression_method = GZIP_COMPRESSION
81
87
  end
82
88
  ```
83
89
 
@@ -43,19 +43,19 @@ module LogjamAgent
43
43
  end
44
44
 
45
45
  def pack_info(n)
46
- info = [META_INFO_TAG, META_INFO_VERSION, META_INFO_DEVICE_NUMBER].pack("nnN")
46
+ info = [META_INFO_TAG, LogjamAgent.compression_method, META_INFO_VERSION, META_INFO_DEVICE_NUMBER].pack("nCCN")
47
47
  info << pack_uint64_big_endian(zclock_time)
48
48
  info << pack_uint64_big_endian(n)
49
49
  end
50
50
 
51
51
  def unpack_info(info)
52
- tag, version, device = info[0..7].unpack("nnN")
52
+ tag, compression_method, version, device = info[0..7].unpack("nCCN")
53
53
  zclock = unpack_uint64_big_endian(info[8..15])
54
54
  secs = zclock / 1000
55
55
  msecs = zclock % 1000
56
56
  sent = Time.at(secs) + 1000.0/msecs
57
57
  sequence = unpack_uint64_big_endian(info[16..23])
58
- [tag, version, device, sent, sequence]
58
+ [tag, compression_method, version, device, sent, sequence]
59
59
  end
60
60
  end
61
61
  end
@@ -1,3 +1,3 @@
1
1
  module LogjamAgent
2
- VERSION = "0.16.0"
2
+ VERSION = "0.17.0"
3
3
  end
data/lib/logjam_agent.rb CHANGED
@@ -114,6 +114,28 @@ module LogjamAgent
114
114
 
115
115
  extend RequestHandling
116
116
 
117
+ NO_COMPRESSION = 0
118
+ GZIP_COMPRESSION = 1
119
+ SNAPPY_COMPRESSION = 2
120
+
121
+ mattr_reader :compression_method
122
+ def self.compression_method=(compression_method)
123
+ case compression_method
124
+ when SNAPPY_COMPRESSION
125
+ begin
126
+ require "snappy"
127
+ @@compression_method = SNAPPY_COMPRESSION
128
+ rescue LoadError
129
+ # do nothing
130
+ end
131
+ when NO_COMPRESSION, GZIP_COMPRESSION
132
+ @@compression_method = compression_method
133
+ else
134
+ raise ArgumentError.new("unknown compression method")
135
+ end
136
+ end
137
+ self.compression_method = NO_COMPRESSION
138
+
117
139
  mattr_accessor :exception_classes
118
140
  self.exception_classes = []
119
141
 
@@ -191,15 +213,27 @@ module LogjamAgent
191
213
  # setup json encoding
192
214
  begin
193
215
  require "oj"
194
- def self.encode_payload(data)
216
+ def self.json_encode_payload(data)
195
217
  Oj.dump(data, :mode => :compat)
196
218
  end
197
219
  rescue LoadError
198
- def self.encode_payload(data)
220
+ def self.json_encode_payload(data)
199
221
  data.to_json
200
222
  end
201
223
  end
202
224
 
225
+ def self.encode_payload(data)
226
+ json = json_encode_payload(data)
227
+ case compression_method
228
+ when GZIP_COMPRESSION
229
+ ActiveSupport::Gzip.compress(json)
230
+ when SNAPPY_COMPRESSION
231
+ Snappy.deflate(json)
232
+ else
233
+ json
234
+ end
235
+ end
236
+
203
237
  def self.event(label, extra_fields = {})
204
238
  fields = {
205
239
  :label => label,
data/logjam_agent.gemspec CHANGED
@@ -20,6 +20,9 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_development_dependency "rake"
22
22
  s.add_development_dependency "i18n"
23
+ s.add_development_dependency "snappy"
24
+ s.add_development_dependency "oj"
25
+ s.add_development_dependency "byebug"
23
26
 
24
27
  s.add_runtime_dependency "activesupport"
25
28
  s.add_runtime_dependency "time_bandits", [">= 0.6.0"]
data/script/console ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+
4
+ options = { }
5
+ OptionParser.new do |opt|
6
+ opt.banner = "Usage: console [options]"
7
+ opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v }
8
+ opt.parse!(ARGV)
9
+ end
10
+
11
+ lib_dir = File.expand_path("../../lib/", __FILE__)
12
+ libs = " -r irb/completion"
13
+ libs << " -I #{lib_dir}"
14
+ libs << " -r #{lib_dir}/logjam_agent.rb"
15
+
16
+ if options[:debugger]
17
+ begin
18
+ require 'byebug'
19
+ libs << " -r byebug"
20
+ puts "=> Debugger enabled"
21
+ rescue Exception
22
+ puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'"
23
+ exit
24
+ end
25
+ end
26
+
27
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
28
+ exec "#{irb} #{libs} --simple-prompt"
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.16.0
4
+ version: 0.17.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: 2016-04-11 00:00:00.000000000 Z
11
+ date: 2016-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,6 +38,48 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: snappy
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: oj
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
41
83
  - !ruby/object:Gem::Dependency
42
84
  name: activesupport
43
85
  requirement: !ruby/object:Gem::Requirement
@@ -90,6 +132,7 @@ files:
90
132
  - lib/logjam_agent/version.rb
91
133
  - lib/logjam_agent/zmq_forwarder.rb
92
134
  - logjam_agent.gemspec
135
+ - script/console
93
136
  homepage: ''
94
137
  licenses: []
95
138
  metadata: {}