rollbar 2.2.0 → 2.2.1

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
  SHA1:
3
- metadata.gz: 245d598a698d57310a524065495b585450e183d8
4
- data.tar.gz: ae4841097d594e0b58528806f3b151163e9b432a
3
+ metadata.gz: a8387b8dd9b53558f27d84908e1f3ac8beb26204
4
+ data.tar.gz: d8eec2f09315894700991fbaf1765d30cd0c697d
5
5
  SHA512:
6
- metadata.gz: 43011a9710f91e3640dc5542d099b112ea4b2424842d2db8045a5f14444027ec225b15380539d7f38ecde2258744db6e74df31855b1a293c36d106c7ee2ac0dd
7
- data.tar.gz: 47bfe86f356e5efa27fea9ef15c5150541d4c065c9d8c72f0def6c1ad2813d8ff0be5bc1381b0b9bea38f7df49f3fc3dfb03a3b23a362510da196a1391596668
6
+ metadata.gz: 15191d6677c822f80dadeb608d41e1cd35e778e15a4f2e49254bd954e2db4179127406c841f05910cee36a8d2be6adabbb70704f18e53f6b9da0c773bb231585
7
+ data.tar.gz: 59e4273d242a88151f509845334448c067eb63b97241785eb4b46db6fbe1afcb4a916760fa2351283df1b10357394c59026aaeb808784f5119295394123b1289
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.2.1
4
+
5
+ Improvement:
6
+
7
+ - Speed-up payload encoding. See [#285](https://github.com/rollbar/rollbar-gem/pull/285)
8
+
3
9
  ## 2.2.0
4
10
 
5
11
  New features:
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rollbar notifier for Ruby [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v2.2.0)](https://travis-ci.org/rollbar/rollbar-gem/branches)
1
+ # Rollbar notifier for Ruby [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v2.2.1)](https://travis-ci.org/rollbar/rollbar-gem/branches)
2
2
 
3
3
  <!-- RemoveNext -->
4
4
  [Rollbar](https://rollbar.com) is an error tracking service for Ruby and other languages. The Rollbar service will alert you of problems with your code and help you understand them in a ways never possible before. We love it and we hope you will too.
@@ -12,7 +12,7 @@ This is the Ruby library for Rollbar. It will instrument many kinds of Ruby appl
12
12
  Add this line to your application's Gemfile:
13
13
 
14
14
  ```ruby
15
- gem 'rollbar', '~> 2.2.0'
15
+ gem 'rollbar', '~> 2.2.1'
16
16
  ```
17
17
 
18
18
  And then execute:
@@ -1,21 +1,27 @@
1
1
  module Rollbar
2
2
  module Encoding
3
- def self.encode(object)
4
- can_be_encoded = object.is_a?(Symbol) || object.is_a?(String)
5
-
6
- return object unless can_be_encoded
7
-
8
- encoding_class.new(object).encode
3
+ class << self
4
+ attr_accessor :encoding_class
9
5
  end
10
6
 
11
- def self.encoding_class
7
+ def self.setup
12
8
  if String.instance_methods.include?(:encode)
13
9
  require 'rollbar/encoding/encoder'
14
- Encoder
10
+ self.encoding_class = Rollbar::Encoding::Encoder
15
11
  else
16
12
  require 'rollbar/encoding/legacy_encoder'
17
- LegacyEncoder
13
+ self.encoding_class = Rollbar::Encoding::LegacyEncoder
18
14
  end
19
15
  end
16
+
17
+ def self.encode(object)
18
+ can_be_encoded = object.is_a?(String) || object.is_a?(Symbol)
19
+
20
+ return object unless can_be_encoded
21
+
22
+ encoding_class.new(object).encode
23
+ end
20
24
  end
21
25
  end
26
+
27
+ Rollbar::Encoding.setup
@@ -4,6 +4,8 @@ module Rollbar
4
4
  ALL_ENCODINGS = [::Encoding::UTF_8, ::Encoding::ISO_8859_1, ::Encoding::ASCII_8BIT, ::Encoding::US_ASCII]
5
5
  ASCII_ENCODINGS = [::Encoding::US_ASCII, ::Encoding::ASCII_8BIT, ::Encoding::ISO_8859_1]
6
6
  ENCODING_OPTIONS = { :invalid => :replace, :undef => :replace, :replace => '' }
7
+ UTF8 = 'UTF-8'.freeze
8
+ BINARY = 'binary'.freeze
7
9
 
8
10
  attr_accessor :object
9
11
 
@@ -13,8 +15,14 @@ module Rollbar
13
15
 
14
16
  def encode
15
17
  value = object.to_s
18
+ encoding = value.encoding
16
19
 
17
- encoded_value = force_encoding(value).encode(*encoding_args(value))
20
+ # This will be most of cases so avoid force anything for them
21
+ if encoding == ::Encoding::UTF_8 && value.valid_encoding?
22
+ encoded_value = value
23
+ else
24
+ encoded_value = force_encoding(value).encode(*encoding_args(value))
25
+ end
18
26
 
19
27
  object.is_a?(Symbol) ? encoded_value.to_sym : encoded_value
20
28
  end
@@ -34,6 +42,7 @@ module Rollbar
34
42
 
35
43
  ALL_ENCODINGS.detect do |encoding|
36
44
  begin
45
+ # Seems #codepoints is faster than #valid_encoding?
37
46
  value.force_encoding(encoding).encode(::Encoding::UTF_8).codepoints
38
47
  true
39
48
  rescue
@@ -43,8 +52,8 @@ module Rollbar
43
52
  end
44
53
 
45
54
  def encoding_args(value)
46
- args = ['UTF-8']
47
- args << 'binary' if ASCII_ENCODINGS.include?(value.encoding)
55
+ args = [UTF8]
56
+ args << BINARY if ASCII_ENCODINGS.include?(value.encoding)
48
57
  args << ENCODING_OPTIONS
49
58
 
50
59
  args
@@ -1,18 +1,20 @@
1
1
  require 'iconv'
2
2
 
3
3
  module Rollbar
4
- class LegacyEncoder
5
- attr_accessor :object
4
+ module Encoding
5
+ class LegacyEncoder
6
+ attr_accessor :object
6
7
 
7
- def initialize(object)
8
- @object = object
9
- end
8
+ def initialize(object)
9
+ @object = object
10
+ end
10
11
 
11
- def encode
12
- value = object.to_s
13
- encoded_value = ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', value)
12
+ def encode
13
+ value = object.to_s
14
+ encoded_value = ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', value)
14
15
 
15
- object.is_a?(Symbol) ? encoded_value.to_sym : encoded_value
16
+ object.is_a?(Symbol) ? encoded_value.to_sym : encoded_value
17
+ end
16
18
  end
17
19
  end
18
20
  end
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rollbar, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-28 00:00:00.000000000 Z
11
+ date: 2015-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -360,7 +360,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
360
360
  version: '0'
361
361
  requirements: []
362
362
  rubyforge_project:
363
- rubygems_version: 2.4.1
363
+ rubygems_version: 2.3.0
364
364
  signing_key:
365
365
  specification_version: 4
366
366
  summary: Reports exceptions to Rollbar