rollbar 2.15.4 → 2.15.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +19 -1
- data/lib/generators/rollbar/templates/initializer.rb +12 -0
- data/lib/rollbar/configuration.rb +2 -0
- data/lib/rollbar/notifier.rb +46 -8
- data/lib/rollbar/version.rb +1 -1
- data/spec/rollbar_spec.rb +58 -0
- data/spec/support/notifier_helpers.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ea41fac2007e3ba3b7b13f63f572cc2c1c9d6e2
|
4
|
+
data.tar.gz: 61e75c88eb2f4f53354450dbec86a09f6f08878b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbee402f2d4a50db12cfb30d1f4ccaadaeef12e3e51c71e5363abfe658f1b8362a9985fded59cb01e0f9f48f30bc10fe97cf654934f68ce42fc4a067bc10541c
|
7
|
+
data.tar.gz: 12776611c225ac3cddc5a04054ab0499e1fffdfc80ba72afea3efac838c17ac1c4859355b6687e24690ab709502242f6e1a2c5ba3c9fc974fd536f3b18e3a592
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Rollbar [](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.
|
@@ -1013,6 +1013,24 @@ Rollbar.configure do |config|
|
|
1013
1013
|
end
|
1014
1014
|
```
|
1015
1015
|
|
1016
|
+
## Web Proxies
|
1017
|
+
|
1018
|
+
If your application is deployed behind a proxy server, you can set the ```https_proxy``` (note the 's') environment variable and it will be honored, including username and password, if any.
|
1019
|
+
|
1020
|
+
```shell
|
1021
|
+
export https_proxy='http://some_user:some_password@some.proxy.com:80'
|
1022
|
+
```
|
1023
|
+
|
1024
|
+
Alternately, you can configure the proxy settings in ```config/initializers/rollbar.rb```. If used, ```host``` is mandatory and must include the URL scheme (e.g. ```http://```), all other fields are optional:
|
1025
|
+
|
1026
|
+
```ruby
|
1027
|
+
config.proxy = {
|
1028
|
+
host: 'http://some.proxy.server',
|
1029
|
+
port: 80,
|
1030
|
+
user: 'username_if_auth_required',
|
1031
|
+
password: 'password_if_auth_required'
|
1032
|
+
}
|
1033
|
+
```
|
1016
1034
|
|
1017
1035
|
## Using with Zeus
|
1018
1036
|
|
@@ -57,6 +57,18 @@ Rollbar.configure do |config|
|
|
57
57
|
# You can supply custom Sidekiq options:
|
58
58
|
# config.use_sidekiq 'queue' => 'default'
|
59
59
|
|
60
|
+
# If your application runs behind a proxy server, you can set proxy parameters here.
|
61
|
+
# If https_proxy is set in your environment, that will be used. Settings here have precedence.
|
62
|
+
# The :host key is mandatory and must include the URL scheme (e.g. 'http://'), all other fields
|
63
|
+
# are optional.
|
64
|
+
#
|
65
|
+
# config.proxy = {
|
66
|
+
# host: 'http://some.proxy.server',
|
67
|
+
# port: 80,
|
68
|
+
# user: 'username_if_auth_required',
|
69
|
+
# password: 'password_if_auth_required'
|
70
|
+
# }
|
71
|
+
|
60
72
|
# If you run your staging application instance in production environment then
|
61
73
|
# you'll want to override the environment reported by `Rails.env` with an
|
62
74
|
# environment variable like this: `ROLLBAR_ENV=staging`. This is a recommended
|
@@ -56,6 +56,7 @@ module Rollbar
|
|
56
56
|
attr_accessor :write_to_file
|
57
57
|
attr_reader :send_extra_frame_data
|
58
58
|
attr_accessor :use_exception_level_filters_default
|
59
|
+
attr_accessor :proxy
|
59
60
|
|
60
61
|
attr_reader :project_gem_paths
|
61
62
|
|
@@ -118,6 +119,7 @@ module Rollbar
|
|
118
119
|
@send_extra_frame_data = :none
|
119
120
|
@project_gem_paths = []
|
120
121
|
@use_exception_level_filters_default = false
|
122
|
+
@proxy = nil
|
121
123
|
end
|
122
124
|
|
123
125
|
def initialize_copy(orig)
|
data/lib/rollbar/notifier.rb
CHANGED
@@ -8,6 +8,7 @@ require 'rollbar/delay/girl_friday'
|
|
8
8
|
require 'rollbar/delay/thread'
|
9
9
|
require 'rollbar/logger_proxy'
|
10
10
|
require 'rollbar/item'
|
11
|
+
require 'ostruct'
|
11
12
|
|
12
13
|
module Rollbar
|
13
14
|
# The notifier class. It has the core functionality
|
@@ -438,12 +439,13 @@ module Rollbar
|
|
438
439
|
|
439
440
|
## Delivery functions
|
440
441
|
|
441
|
-
def send_item_using_eventmachine(item)
|
442
|
+
def send_item_using_eventmachine(item, uri)
|
442
443
|
body = item.dump
|
443
444
|
return unless body
|
444
445
|
|
445
446
|
headers = { 'X-Rollbar-Access-Token' => item['access_token'] }
|
446
|
-
|
447
|
+
options = http_proxy_for_em(uri)
|
448
|
+
req = EventMachine::HttpRequest.new(uri.to_s, options).post(:body => body, :head => headers)
|
447
449
|
|
448
450
|
req.callback do
|
449
451
|
if req.response_header.status == 200
|
@@ -463,21 +465,23 @@ module Rollbar
|
|
463
465
|
def send_item(item)
|
464
466
|
log_info '[Rollbar] Sending item'
|
465
467
|
|
466
|
-
if configuration.use_eventmachine
|
467
|
-
send_item_using_eventmachine(item)
|
468
|
-
return
|
469
|
-
end
|
470
|
-
|
471
468
|
body = item.dump
|
472
469
|
return unless body
|
473
470
|
|
474
471
|
uri = URI.parse(configuration.endpoint)
|
475
472
|
|
473
|
+
if configuration.use_eventmachine
|
474
|
+
send_item_using_eventmachine(item, uri)
|
475
|
+
return
|
476
|
+
end
|
477
|
+
|
476
478
|
handle_response(do_post(uri, body, item['access_token']))
|
477
479
|
end
|
478
480
|
|
479
481
|
def do_post(uri, body, access_token)
|
480
|
-
|
482
|
+
proxy = http_proxy(uri)
|
483
|
+
http = Net::HTTP.new(uri.host, uri.port, proxy.host, proxy.port, proxy.user, proxy.password)
|
484
|
+
|
481
485
|
http.open_timeout = configuration.open_timeout
|
482
486
|
http.read_timeout = configuration.request_timeout
|
483
487
|
|
@@ -496,6 +500,40 @@ module Rollbar
|
|
496
500
|
handle_net_retries { http.request(request) }
|
497
501
|
end
|
498
502
|
|
503
|
+
def http_proxy_for_em(uri)
|
504
|
+
proxy = http_proxy(uri)
|
505
|
+
{
|
506
|
+
:proxy => {
|
507
|
+
:host => proxy.host,
|
508
|
+
:port => proxy.port,
|
509
|
+
:authorization => [proxy.user, proxy.password]
|
510
|
+
}
|
511
|
+
}
|
512
|
+
end
|
513
|
+
|
514
|
+
def http_proxy(uri)
|
515
|
+
@http_proxy ||= proxy_from_config || proxy_from_env(uri) || null_proxy
|
516
|
+
end
|
517
|
+
|
518
|
+
def proxy_from_config
|
519
|
+
proxy = configuration.proxy
|
520
|
+
return nil unless proxy
|
521
|
+
|
522
|
+
px = URI.parse(proxy[:host])
|
523
|
+
px.port = proxy[:port]
|
524
|
+
px.user = proxy[:user]
|
525
|
+
px.password = proxy[:password]
|
526
|
+
px
|
527
|
+
end
|
528
|
+
|
529
|
+
def proxy_from_env(uri)
|
530
|
+
uri.find_proxy
|
531
|
+
end
|
532
|
+
|
533
|
+
def null_proxy
|
534
|
+
Struct.new(:host, :port, :user, :password).new
|
535
|
+
end
|
536
|
+
|
499
537
|
def handle_net_retries
|
500
538
|
return yield if skip_retries?
|
501
539
|
|
data/lib/rollbar/version.rb
CHANGED
data/spec/rollbar_spec.rb
CHANGED
@@ -8,6 +8,8 @@ require 'active_support/core_ext/object'
|
|
8
8
|
require 'active_support/json/encoding'
|
9
9
|
|
10
10
|
require 'rollbar/item'
|
11
|
+
require 'ostruct'
|
12
|
+
|
11
13
|
begin
|
12
14
|
require 'rollbar/delay/sidekiq'
|
13
15
|
require 'rollbar/delay/sucker_punch'
|
@@ -1008,6 +1010,62 @@ describe Rollbar do
|
|
1008
1010
|
end
|
1009
1011
|
end
|
1010
1012
|
|
1013
|
+
context 'using a proxy server' do
|
1014
|
+
before do
|
1015
|
+
allow_any_instance_of(Net::HTTP).to receive(:request).and_return(OpenStruct.new(:code => 200, :body => "Success"))
|
1016
|
+
@env_vars = clear_proxy_env_vars
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
after do
|
1020
|
+
restore_proxy_env_vars(@env_vars)
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
context 'via environment variables' do
|
1024
|
+
it 'honors proxy settings in the environment' do
|
1025
|
+
ENV['http_proxy'] = 'http://user:pass@example.com:80'
|
1026
|
+
ENV['https_proxy'] = 'http://user:pass@example.com:80'
|
1027
|
+
|
1028
|
+
uri = URI.parse(Rollbar::Configuration::DEFAULT_ENDPOINT)
|
1029
|
+
expect(Net::HTTP).to receive(:new).with(uri.host, uri.port, 'example.com', 80, 'user', 'pass').and_call_original
|
1030
|
+
Rollbar.info("proxy this")
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
it 'does not use a proxy if no proxy settings in environemnt' do
|
1034
|
+
uri = URI.parse(Rollbar::Configuration::DEFAULT_ENDPOINT)
|
1035
|
+
expect(Net::HTTP).to receive(:new).with(uri.host, uri.port, nil, nil, nil, nil).and_call_original
|
1036
|
+
Rollbar.info("proxy this")
|
1037
|
+
end
|
1038
|
+
end
|
1039
|
+
|
1040
|
+
context 'set in configuration file' do
|
1041
|
+
before do
|
1042
|
+
Rollbar.configure do |config|
|
1043
|
+
config.proxy = {
|
1044
|
+
:host => 'http://config.com',
|
1045
|
+
:port => 8080,
|
1046
|
+
:user => 'foo',
|
1047
|
+
:password => 'bar'
|
1048
|
+
}
|
1049
|
+
end
|
1050
|
+
end
|
1051
|
+
|
1052
|
+
it 'honors proxy settings in the config file' do
|
1053
|
+
uri = URI.parse(Rollbar::Configuration::DEFAULT_ENDPOINT)
|
1054
|
+
expect(Net::HTTP).to receive(:new).with(uri.host, uri.port, 'config.com', 8080, 'foo', 'bar').and_call_original
|
1055
|
+
Rollbar.info("proxy this")
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
it 'gives the configuration settings precedence over environment' do
|
1059
|
+
ENV['http_proxy'] = 'http://user:pass@example.com:80'
|
1060
|
+
ENV['https_proxy'] = 'http://user:pass@example.com:80'
|
1061
|
+
|
1062
|
+
uri = URI.parse(Rollbar::Configuration::DEFAULT_ENDPOINT)
|
1063
|
+
expect(Net::HTTP).to receive(:new).with(uri.host, uri.port, 'config.com', 8080, 'foo', 'bar').and_call_original
|
1064
|
+
Rollbar.info("proxy this")
|
1065
|
+
end
|
1066
|
+
end
|
1067
|
+
end
|
1068
|
+
|
1011
1069
|
context 'asynchronous_handling' do
|
1012
1070
|
before do
|
1013
1071
|
Rollbar.clear_notifier!
|
@@ -36,4 +36,22 @@ module NotifierHelpers
|
|
36
36
|
Rollbar.reconfigure do |config|
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
def clear_proxy_env_vars
|
41
|
+
env_vars = {}
|
42
|
+
proxy_env_vars.each do |var|
|
43
|
+
env_vars[var] = ENV.delete(var)
|
44
|
+
end
|
45
|
+
env_vars
|
46
|
+
end
|
47
|
+
|
48
|
+
def restore_proxy_env_vars(env_vars)
|
49
|
+
proxy_env_vars.each do |var|
|
50
|
+
ENV[var] = env_vars[var]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def proxy_env_vars
|
55
|
+
%w[http_proxy HTTP_PROXY https_proxy HTTPS_PROXY]
|
56
|
+
end
|
39
57
|
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.15.
|
4
|
+
version: 2.15.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rollbar, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|