binnacle 0.4.8 → 0.4.9

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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +26 -26
  4. data/lib/binnacle/client.rb +10 -6
  5. data/lib/binnacle/commands/tail.rb +23 -15
  6. data/lib/binnacle/logging/formatter.rb +3 -4
  7. data/lib/binnacle/resources/event.rb +19 -6
  8. data/lib/binnacle/trap/exception_event.rb +4 -6
  9. data/lib/binnacle/version.rb +1 -1
  10. data/spec/client_spec.rb +15 -41
  11. data/spec/commands_spec.rb +22 -12
  12. data/spec/logger_spec.rb +6 -1
  13. data/spec/vcr/binnacle_client/events_invokes_the_events_api.yml +52 -55
  14. data/spec/vcr/binnacle_client/events_returns_a_collection_of_event_objects.yml +52 -55
  15. data/spec/vcr/binnacle_client/recents_invokes_the_events_api_recents.yml +59 -22
  16. data/spec/vcr/binnacle_client/recents_returns_a_collection_of_event_objects.yml +98 -22
  17. data/spec/vcr/binnacle_client/report_exception_invokes_the_events_api_signal.yml +23 -24
  18. data/spec/vcr/binnacle_client/signal_asynch_invokes_the_events_api_signal.yml +26 -19
  19. data/spec/vcr/binnacle_client/signal_invokes_the_events_api_signal.yml +60 -15
  20. data/spec/vcr/binnacle_client_ready_/returns_true_if_a_connection_has_been_successfully_established.yml +45 -6
  21. data/spec/vcr/binnacle_command/requires_a_known_subcommand_argument.yml +42 -0
  22. data/spec/vcr/binnacle_command/tail_command_validates_the_passed_params_before_executing.yml +42 -0
  23. data/spec/vcr/binnacle_command/tail_command_with_n_flag_returns_recent_events.yml +61 -16
  24. data/spec/vcr/binnacle_http_logger/_htt_party_adapter_should_log__ge_t_requests.yml +38 -1
  25. data/spec/vcr/binnacle_http_logger/_http_client_adapter_should_log__ge_t_requests.yml +74 -0
  26. data/spec/vcr/binnacle_http_logger/open_uri_adapter_should_log__ge_t_requests.yml +333 -0
  27. data/spec/vcr/binnacle_http_logger/typhoeus_adapter_should_log__ge_t_requests.yml +38 -1
  28. data/spec/vcr/binnacle_logging/logging_allows_passing_other_parameters_using_a_hash.yml +35 -33
  29. data/spec/vcr/binnacle_logging/logging_invokes_the_events_api_signal.yml +60 -15
  30. data/spec/vcr/binnacle_logging/logging_respects_the_logger_severity.yml +54 -15
  31. data/vendor/assets/javascripts/binnacle/binnacle.js +39 -18
  32. metadata +6 -4
  33. data/spec/exception_event_spec.rb +0 -72
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac88903228fc74fc1b88017ad2b8a5c61432bb5d
4
- data.tar.gz: 5faf3822abed8fe7e29efc915821fd376015476f
3
+ metadata.gz: 957b5284e87ffafca6a136ed720f5b7fc95cf095
4
+ data.tar.gz: 78b6d5c88873e108f166a13b2d8b001ded78c98d
5
5
  SHA512:
6
- metadata.gz: e1fdc27769de722bf9f258b42aadca2cf4ce4497a01a7caa156b067ddc890f7ce1f0e2e556dbf90ea2d72e87614fd6e53d39e43a7a7965ba751ce76efd33ffc8
7
- data.tar.gz: f06922bca53b26e5e60b27b923665d6a1a517036f8ec0fedb353b424c461c0adc28cba825c74b459dbad2beb3ef781f171b2d2d20c1e642e83e9977d960638e2
6
+ metadata.gz: 652ce111e80447a30de76e235bc54626908cb9a25d2bab117d9360643ed045b301a416e91206793c30ff47744e78911e9bf1141c7242b6b6c2386225238e6509
7
+ data.tar.gz: 56720fc4a5ce64a7966472b6703d0a03714215fdab8253f232b63c6b8d640a418b1b257ac61ca15dc98f9a8cfea26a480f9a701bf91352b01e283a018f0634a2
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
  source 'https://rails-assets.org'
3
3
 
4
4
  source 'https://rails-assets.org' do
5
- gem 'rails-assets-binnacle', '>= 0.2.5'
5
+ gem 'rails-assets-binnacle', '>= 0.2.6'
6
6
  end
7
7
 
8
8
  gemspec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- binnacle (0.4.8)
4
+ binnacle (0.4.9)
5
5
  addressable (~> 2.5)
6
6
  colorize (~> 0.8.1)
7
7
  faraday (~> 0.11)
@@ -29,37 +29,37 @@ GEM
29
29
  ethon (0.10.1)
30
30
  ffi (>= 1.3.0)
31
31
  eventmachine (1.2.3)
32
- excon (0.55.0)
33
- faraday (0.12.0.1)
32
+ excon (0.57.1)
33
+ faraday (0.12.1)
34
34
  multipart-post (>= 1.2, < 3)
35
35
  faye-websocket (0.10.7)
36
36
  eventmachine (>= 0.12.0)
37
37
  websocket-driver (>= 0.5.1)
38
38
  ffi (1.9.18)
39
- fivemat (1.3.3)
40
- hashdiff (0.3.2)
41
- http (2.2.1)
39
+ fivemat (1.3.5)
40
+ hashdiff (0.3.4)
41
+ http (2.2.2)
42
42
  addressable (~> 2.3)
43
43
  http-cookie (~> 1.0)
44
44
  http-form_data (~> 1.0.1)
45
45
  http_parser.rb (~> 0.6.0)
46
46
  http-cookie (1.0.3)
47
47
  domain_name (~> 0.5)
48
- http-form_data (1.0.1)
48
+ http-form_data (1.0.3)
49
49
  http_parser.rb (0.6.0)
50
- httparty (0.14.0)
50
+ httparty (0.15.5)
51
51
  multi_xml (>= 0.5.2)
52
52
  httpclient (2.8.3)
53
- json (2.0.4)
53
+ json (2.1.0)
54
54
  multi_xml (0.6.0)
55
55
  multipart-post (2.0.0)
56
56
  patron (0.8.0)
57
57
  public_suffix (2.0.5)
58
- rack (2.0.1)
58
+ rack (2.0.3)
59
59
  rack-timeout (0.4.2)
60
60
  rails-assets-atmosphere (2.3.2)
61
61
  rails-assets-base64 (1.0.0)
62
- rails-assets-binnacle (0.2.5)
62
+ rails-assets-binnacle (0.2.6)
63
63
  rails-assets-atmosphere (= 2.3.2)
64
64
  rails-assets-base64 (= 1.0.0)
65
65
  rails-assets-firebase (= 3.7.1)
@@ -67,21 +67,21 @@ GEM
67
67
  rails-assets-firebase (3.7.1)
68
68
  rails-assets-moment (2.18.0)
69
69
  rake (10.5.0)
70
- rspec (3.5.0)
71
- rspec-core (~> 3.5.0)
72
- rspec-expectations (~> 3.5.0)
73
- rspec-mocks (~> 3.5.0)
70
+ rspec (3.6.0)
71
+ rspec-core (~> 3.6.0)
72
+ rspec-expectations (~> 3.6.0)
73
+ rspec-mocks (~> 3.6.0)
74
74
  rspec-collection_matchers (1.1.3)
75
75
  rspec-expectations (>= 2.99.0.beta1)
76
- rspec-core (3.5.4)
77
- rspec-support (~> 3.5.0)
78
- rspec-expectations (3.5.0)
76
+ rspec-core (3.6.0)
77
+ rspec-support (~> 3.6.0)
78
+ rspec-expectations (3.6.0)
79
79
  diff-lcs (>= 1.2.0, < 2.0)
80
- rspec-support (~> 3.5.0)
81
- rspec-mocks (3.5.0)
80
+ rspec-support (~> 3.6.0)
81
+ rspec-mocks (3.6.0)
82
82
  diff-lcs (>= 1.2.0, < 2.0)
83
- rspec-support (~> 3.5.0)
84
- rspec-support (3.5.0)
83
+ rspec-support (~> 3.6.0)
84
+ rspec-support (3.6.0)
85
85
  rspec-wait (0.0.9)
86
86
  rspec (>= 3, < 4)
87
87
  safe_yaml (1.0.4)
@@ -89,8 +89,8 @@ GEM
89
89
  docile (~> 1.1.0)
90
90
  json (>= 1.8, < 3)
91
91
  simplecov-html (~> 0.10.0)
92
- simplecov-html (0.10.0)
93
- thin (1.7.0)
92
+ simplecov-html (0.10.1)
93
+ thin (1.7.1)
94
94
  daemons (~> 1.0, >= 1.0.9)
95
95
  eventmachine (~> 1.0, >= 1.0.4)
96
96
  rack (>= 1, < 3)
@@ -99,7 +99,7 @@ GEM
99
99
  ethon (>= 0.9.0)
100
100
  unf (0.1.4)
101
101
  unf_ext
102
- unf_ext (0.0.7.3)
102
+ unf_ext (0.0.7.4)
103
103
  vcr (3.0.3)
104
104
  webmock (2.3.2)
105
105
  addressable (>= 2.3.6)
@@ -123,7 +123,7 @@ DEPENDENCIES
123
123
  httparty (~> 0.14)
124
124
  patron (~> 0.8)
125
125
  rack (~> 2.0)
126
- rails-assets-binnacle (>= 0.2.5)!
126
+ rails-assets-binnacle (>= 0.2.6)!
127
127
  rake (~> 10.5)
128
128
  rspec (~> 3.5, >= 3.2.0)
129
129
  rspec-collection_matchers (~> 1.1, >= 1.1.2)
@@ -29,15 +29,19 @@ module Binnacle
29
29
  @formatter = Binnacle::Logging::Formatter.new(self)
30
30
  end
31
31
 
32
- def signal(channel_id, event_name, client_id, session_id, log_level, tags = [], json = {}, asynch = false)
32
+ def signal(channel_id, event_name, client_id, session_id, log_level, environment = Event.rails_env, tags = [], json = {}, asynch = false)
33
33
  event = Binnacle::Event.new()
34
- event.configure(channel_id, event_name, client_id, session_id, log_level, nil, tags, json)
34
+ event.configure(channel_id, event_name, client_id, session_id, log_level, environment, nil, tags, json)
35
35
  event.connection = connection
36
36
  asynch ? event.post_asynch : event.post
37
37
  end
38
38
 
39
- def signal_asynch(channel_id, event_name, client_id = '', session_id = '', log_level = 'INFO', tags = [], json = {})
40
- signal(channel_id, event_name, client_id, session_id, log_level, tags, json, true)
39
+ def signal_asynch(channel_id, event_name, client_id = '', session_id = '', log_level = 'INFO', environment = Event.rails_env, tags = [], json = {})
40
+ signal(channel_id, event_name, client_id, session_id, log_level, environment, tags, json, true)
41
+ end
42
+
43
+ def broadcast(channel_id, event_name, json)
44
+ signal(channel_id, event_name, "", "", 'CABLE', nil, [], json, true)
41
45
  end
42
46
 
43
47
  def recents(lines, since, channel)
@@ -82,7 +86,7 @@ module Binnacle
82
86
  event_name = %[#{data[:method]} #{data[:path]}]
83
87
 
84
88
  event = Binnacle::Event.new()
85
- event.configure(logging_channel_id, event_name, client_id, session_id, 'log', data[:time], [], data)
89
+ event.configure(logging_channel_id, event_name, client_id, session_id, 'log', nil, data[:time], [], data)
86
90
  write(event)
87
91
  end
88
92
 
@@ -91,7 +95,7 @@ module Binnacle
91
95
  event_name = %[#{data[:method]} #{data[:url]}]
92
96
 
93
97
  event = Binnacle::Event.new()
94
- event.configure(logging_channel_id, event_name, client_id, session_id, 'log', data[:time], [], data)
98
+ event.configure(logging_channel_id, event_name, client_id, session_id, 'log', nil, data[:time], [], data)
95
99
  write(event)
96
100
  end
97
101
 
@@ -22,6 +22,8 @@ module Binnacle::Commands
22
22
  opt(:lines, "Get the last n events on the Channel", type: :int, short: '-n')
23
23
  opt(:since, "Number of minutes in the past to search for events", type: :int)
24
24
  opt(:encrypted, "Use SSL/HTTPS", default: true)
25
+ opt(:environment, "The target environment (Rails.env)", type: :string, default: 'production')
26
+ opt(:payload, "Show JSON Payload", default: false)
25
27
  end
26
28
 
27
29
  if (errors = validate(opts)).empty?
@@ -48,23 +50,23 @@ module Binnacle::Commands
48
50
  def self.dispatch(opts)
49
51
  # tail --follow
50
52
  if opts[:follow_given] && opts[:app_given]
51
- monitor(opts[:host], opts[:api_key], opts[:api_secret], opts[:app], true, opts[:encrypted])
53
+ monitor(opts[:host], opts[:api_key], opts[:api_secret], opts[:app], opts[:environment], true, opts[:encrypted], opts[:payload])
52
54
  elsif opts[:follow_given] && opts[:channel_given]
53
- monitor(opts[:host], opts[:api_key], opts[:api_secret], opts[:channel], false, opts[:encrypted])
55
+ monitor(opts[:host], opts[:api_key], opts[:api_secret], opts[:channel], opts[:environment], false, opts[:encrypted], opts[:payload])
54
56
  end
55
57
 
56
58
  # tail --lines
57
- lines(opts[:host], opts[:api_key], opts[:api_secret], opts[:channel], opts[:lines], opts[:since], opts[:encrypted_given] ? opts[:encrypted] : false) if opts[:lines_given]
59
+ lines(opts[:host], opts[:api_key], opts[:api_secret], opts[:channel], opts[:lines], opts[:since], opts[:environment], opts[:encrypted]) if opts[:lines_given]
58
60
  end
59
61
 
60
62
  #
61
63
  # tail --follow --host=my_host --channel=my_channel
62
- def self.monitor(host, api_key, api_secret, channel, is_app = false, encrypted = true)
64
+ def self.monitor(host, api_key, api_secret, channel, environment, is_app = false, encrypted = true, payload = false)
63
65
  EM.run do
64
66
  Signal.trap("INT") { EventMachine.stop }
65
67
  Signal.trap("TERM") { EventMachine.stop }
66
68
 
67
- ws_url = build_ws_url(host, api_key, api_secret, channel, is_app, encrypted)
69
+ ws_url = build_ws_url(host, api_key, api_secret, channel, environment, is_app, encrypted)
68
70
  ws = Faye::WebSocket::Client.new(ws_url)
69
71
 
70
72
  ws.on :open do |event|
@@ -73,7 +75,7 @@ module Binnacle::Commands
73
75
 
74
76
  ws.on :message do |event|
75
77
  if event.data !~ /\s/ && event.data != 'X'
76
- print_event_from_json(event.data)
78
+ print_event_from_json(event.data, payload)
77
79
  end
78
80
  end
79
81
 
@@ -85,24 +87,24 @@ module Binnacle::Commands
85
87
 
86
88
  #
87
89
  # tail --lines=50 --since=10 --host=my_host --channel=my_channel
88
- def self.lines(host, api_key, api_secret, channel, lines, since, encrypted = true)
90
+ def self.lines(host, api_key, api_secret, channel, lines, since, environment = 'production', encrypted = true, payload = false)
89
91
  puts "Retrieving last #{lines} lines since #{since} minutes ago from Channel #{channel} ..."
90
92
  Binnacle.configuration.encrypted = encrypted
91
93
  client = Binnacle::Client.new(api_key, api_secret, host)
92
94
 
93
95
  client.recents(lines, since, channel).each do |e|
94
- print_event(e)
96
+ print_event(e, payload)
95
97
  end
96
98
  end
97
99
 
98
100
  protected
99
101
 
100
- def self.build_ws_url(host, api_key, api_secret, channel, is_app = false, encrypted = true)
102
+ def self.build_ws_url(host, api_key, api_secret, channel, environment, is_app = false, encrypted = Binnacle.configuration.encrypted)
101
103
  Addressable::URI.new(
102
104
  host: host,
103
105
  port: Binnacle::Configuration::DEFAULT_PORT,
104
106
  scheme: encrypted ? 'wss' : 'ws',
105
- path: ["/api/subscribe", is_app ? "app" : "channel", channel].join("/"),
107
+ path: ["/api/subscribe", is_app ? "app" : "channel", channel, environment].join("/"),
106
108
  query: build_ws_query(api_key, api_secret)
107
109
  ).to_s
108
110
  end
@@ -118,7 +120,7 @@ module Binnacle::Commands
118
120
  }.map { |n,v| "#{n}=#{v}" }.join("&")
119
121
  end
120
122
 
121
- def self.print_event(event)
123
+ def self.print_event(event, payload = false)
122
124
  message = ""
123
125
 
124
126
  level = '%-10.10s' % event.log_level
@@ -138,7 +140,9 @@ module Binnacle::Commands
138
140
  level.colorize(:blue)
139
141
  end.colorize(mode: :bold)
140
142
 
141
- message << "#{level} [#{Time.at(event.event_time)}] "
143
+ env = event.environment.colorize(mode: :bold)
144
+
145
+ message << "#{env}::#{level} [#{Time.at(event.event_time)}] "
142
146
 
143
147
  message << ('%-10.10s' % event.event_name).colorize(color: :green, mode: :bold)
144
148
 
@@ -158,19 +162,23 @@ module Binnacle::Commands
158
162
 
159
163
  unless event.tags.empty?
160
164
  tags = event.tags.join(',')
161
- rest << "#{'tags'.colorize(mode: :bold)} = [#{event.tags}]"
165
+ rest << "#{'tags'.colorize(mode: :bold)} = [#{tags}]"
162
166
  end
163
167
 
164
168
  message << " :: ".colorize(mode: :bold) + rest.join(", ") unless rest.empty?
165
169
 
170
+ if payload && event.json
171
+ message << "\n\t ==> #{event.json}"
172
+ end
173
+
166
174
  puts message
167
175
  end
168
176
 
169
- def self.print_event_from_json(json)
177
+ def self.print_event_from_json(json, payload = false)
170
178
  begin
171
179
  data = JSON.parse(json)
172
180
  event = Binnacle::Event.from_hash(data)
173
- print_event(event)
181
+ print_event(event, payload)
174
182
  rescue JSON::ParserError => jpe
175
183
  # do nothing!
176
184
  end
@@ -14,15 +14,14 @@ module Binnacle
14
14
  event = Binnacle::Event.new()
15
15
 
16
16
  logging_tags = current_tags.dup
17
-
18
17
  if progname
19
- event.configure_from_logging_progname(progname, @client.logging_channel_id, client_id, session_id, severity, datetime, [], { message: msg })
18
+ event.configure_from_logging_progname(progname, @client.logging_channel_id, client_id, session_id, severity, nil, datetime, [], { message: msg })
20
19
  elsif defined?(ActiveSupport::TaggedLogging) && logging_tags && !logging_tags.empty? && logging_tags.size > 2
21
20
  logging_tags.shift(2)
22
21
  event_name = logging_tags.shift
23
- event.configure_from_logging_progname(event_name, @client.logging_channel_id, client_id, session_id, severity, datetime, logging_tags, { message: msg })
22
+ event.configure_from_logging_progname(event_name, @client.logging_channel_id, client_id, session_id, severity, nil, datetime, logging_tags, { message: msg })
24
23
  else
25
- event.configure(@client.logging_channel_id, 'log', client_id, session_id, severity, datetime, [], { message: msg })
24
+ event.configure(@client.logging_channel_id, 'log', client_id, session_id, severity, nil, datetime, [], { message: msg })
26
25
  end
27
26
 
28
27
  event
@@ -11,8 +11,9 @@ module Binnacle
11
11
  attr_accessor :tags
12
12
  attr_accessor :json
13
13
  attr_accessor :event_time
14
+ attr_accessor :environment
14
15
 
15
- def configure(channel_id, event_name, client_id, session_id, log_level, ts = Time.now, tags = [], json = {})
16
+ def configure(channel_id, event_name, client_id, session_id, log_level, environment = Event.rails_env, ts = Time.now, tags = [], json = {})
16
17
  self.channel_id = channel_id
17
18
  self.event_name = event_name
18
19
  self.client_id = client_id
@@ -21,9 +22,10 @@ module Binnacle
21
22
  self.log_level = log_level
22
23
  self.tags = tags
23
24
  self.json = json
25
+ self.environment = environment || Event.rails_env
24
26
  end
25
27
 
26
- def configure_from_logging_progname(progname, channel_id, client_id, session_id, log_level, ts = Time.now, tags = [], json = {})
28
+ def configure_from_logging_progname(progname, channel_id, client_id, session_id, log_level, environment = Event.rails_env, ts = Time.now, tags = [], json = {})
27
29
  if progname.is_a?(Hash)
28
30
  self.client_id = progname[:client_id] || client_id
29
31
  self.session_id = progname[:session_id] || session_id
@@ -32,6 +34,7 @@ module Binnacle
32
34
  self.tags = progname[:tags] || tags
33
35
  self.json = json
34
36
  self.json.merge!(progname[:json]) if progname[:json]
37
+ self.environment = environment || Event.rails_env
35
38
  elsif progname.is_a?(String)
36
39
  self.client_id = client_id
37
40
  self.session_id = session_id
@@ -39,10 +42,12 @@ module Binnacle
39
42
  self.event_name = progname
40
43
  self.tags = tags
41
44
  self.json = json
45
+ self.environment = environment || Event.rails_env
42
46
  end
43
47
 
44
48
  self.timestamp = ts ? ts : Time.now
45
49
  self.log_level = log_level
50
+ self.environment = environment || Event.rails_env
46
51
  end
47
52
 
48
53
  def timestamp=(ts)
@@ -60,6 +65,7 @@ module Binnacle
60
65
  event.event_time = Time.at(h['eventTime']/1000)
61
66
  event.tags = h['tags']
62
67
  event.json = h['json']
68
+ event.environment = h['environment']
63
69
 
64
70
  event
65
71
  end
@@ -73,6 +79,7 @@ module Binnacle
73
79
  "clientId" => client_id,
74
80
  "logLevel" => log_level,
75
81
  "tags" => tags,
82
+ "environment" => environment,
76
83
  "json" => json
77
84
  }.to_json
78
85
  end
@@ -85,16 +92,22 @@ module Binnacle
85
92
  "/api/events/#{channel}"
86
93
  end
87
94
 
88
- def self.recents(connection, lines, since, channel)
89
- path = [route(channel), 'recents'].compact.join('/')
95
+ def self.recents(connection, lines, since, channel, environment = rails_env)
96
+ path = [route(channel), environment, 'recents'].compact.join('/')
90
97
 
91
98
  get(connection, path, {'limit' => lines, 'since' => since})
92
99
  end
93
100
 
94
- def self.events(connection, channel, date, start_hour, end_hour, lines)
95
- path = [route(channel), date].compact.join('/')
101
+ def self.events(connection, channel, date, start_hour, end_hour, lines, environment = rails_env)
102
+ path = [route(channel), environment, date].compact.join('/')
96
103
 
97
104
  get(connection, path, {'start_hour' => start_hour, 'end_hour' => end_hour, 'limit' => lines})
98
105
  end
106
+
107
+ protected
108
+
109
+ def self.rails_env
110
+ defined?(Rails) ? Rails.env : "production"
111
+ end
99
112
  end
100
113
  end
@@ -59,7 +59,9 @@ module Binnacle
59
59
  private
60
60
 
61
61
  def unwrap_exception(exception)
62
- if exception.respond_to?(:original_exception)
62
+ if exception.respond_to?(:cause)
63
+ exception.cause
64
+ elsif exception.respond_to?(:original_exception)
63
65
  exception.original_exception
64
66
  elsif exception.respond_to?(:continued_exception)
65
67
  exception.continued_exception
@@ -122,10 +124,6 @@ module Binnacle
122
124
  'UNKNOWN'
123
125
  end
124
126
 
125
- def extract_rails_environment_level
126
- defined?(Rails) ? Rails.env : "UNKNOWN"
127
- end
128
-
129
127
  def extract_libraries_loaded
130
128
  libraries = {}
131
129
  begin
@@ -157,7 +155,7 @@ module Binnacle
157
155
  message: @exception.message,
158
156
  component: @component,
159
157
  method: @method,
160
- environment_level: extract_rails_environment_level,
158
+ environment_level: Event.rails_env,
161
159
  hostname: extract_hostname,
162
160
  user_agent: @request.user_agent,
163
161
  ruby_version: extract_ruby_version,
@@ -1,3 +1,3 @@
1
1
  module Binnacle
2
- VERSION = "0.4.8"
2
+ VERSION = "0.4.9"
3
3
  end
@@ -1,12 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Binnacle::Client do
4
- before { reset_env }
4
+ before do
5
+ reset_env
6
+ Binnacle.configure do |config|
7
+ config.encrypted = false
8
+ end
9
+ end
5
10
  let(:client) { Binnacle::Client.new('vceth4xcwqfoowpz2esi', '1grttyb8ozbe9axt88ji', 'localhost') }
6
11
 
7
12
  describe 'signal' do
8
13
  it 'invokes the events api signal', :vcr do
9
- client.signal('icoc0tnol3obe8pas207', 'TEST_EVT', 'binnacle-rb', 'My Sess', 'INFO')
14
+ client.signal('icoc0tnol3obe8pas207', 'TEST_EVT', 'binnacle-rb', 'My Sess', 'INFO', 'development')
10
15
 
11
16
  expect(a_request(:get, 'http://localhost:8080/api/endpoints'))
12
17
  expect(
@@ -67,62 +72,31 @@ describe Binnacle::Client do
67
72
  it 'invokes the events api recents', :vcr do
68
73
  expect(a_request(:get, 'http://localhost:8080/api/endpoints'))
69
74
  expect(
70
- a_request(:get, "http://localhost:8080/api/events/icoc0tnol3obe8pas207/recents?limit=10&since=500")
75
+ a_request(:get, "http://localhost:8080/api/events/icoc0tnol3obe8pas207/production/recents?limit=10&since=500")
71
76
  ).to(have_been_made.times(1))
72
77
  end
73
78
 
74
79
  it 'returns a collection of event objects', :vcr do
75
- expect(@recents).to have(10).events
80
+ expect(@recents).to have(1).events
76
81
  end
77
82
  end
78
83
 
79
84
  describe 'events' do
80
- before { @events = client.events('icoc0tnol3obe8pas207', '2015-12-29', 8, 9, 500) }
85
+ before {
86
+ @events = client.events('icoc0tnol3obe8pas207', '2017-07-06', 11, 12, 500)
87
+ }
81
88
 
82
89
  it 'invokes the events api', :vcr do
83
90
  expect(a_request(:get, 'http://localhost:8080/api/endpoints'))
84
91
  expect(
85
- a_request(:get, "http://localhost:8080/api/events/icoc0tnol3obe8pas207/2015-12-29?end_hour=9&limit=500&start_hour=8")
92
+ a_request(:get, "http://localhost:8080/api/events/icoc0tnol3obe8pas207/production/2017-07-06?end_hour=12&limit=500&start_hour=11")
86
93
  ).to(have_been_made.times(1))
87
94
  end
88
95
 
89
96
  it 'returns a collection of event objects', :vcr do
90
- expect(@events).to have(40).events
91
- expect(@events).to all(satisfy { |e| e.event_time.strftime("%Y-%m-%d") == '2015-12-29' })
97
+ expect(@events).to have(1).events
98
+ expect(@events).to all(satisfy { |e| e.event_time.strftime("%Y-%m-%d") == '2017-07-06' })
92
99
  end
93
100
 
94
101
  end
95
-
96
- describe 'report_exception' do
97
- before { Binnacle.binnacle_logger.pause }
98
- after { Binnacle.binnacle_logger.continue }
99
-
100
- it 'invokes the events api signal', :vcr do
101
-
102
- Binnacle.configure do |config|
103
- config.error_channel = 'id0czm8eryfffcgp875c'
104
- config.encrypted = false
105
- end
106
-
107
- exception = ZeroDivisionError.new
108
- env = Rack::MockRequest.env_for(client.connection.active_url)
109
- client.report_exception(exception, env, false)
110
-
111
- expect(a_request(:get, 'http://localhost:8080/api/endpoints'))
112
- expect(
113
- a_request(:post, "http://localhost:8080/api/events/id0czm8eryfffcgp875c").
114
- with(body: hash_including({
115
- "channelId": "id0czm8eryfffcgp875c",
116
- "eventName":"ZeroDivisionError",
117
- "logLevel":"EXCEPTION"
118
- }))
119
- ).to(have_been_made.times(1))
120
-
121
- # TODO: need a way to check nested partial hash in the body for:
122
- # "json": hash_including({
123
- # "exception":"ZeroDivisionError",
124
- # "message":"ZeroDivisionError"
125
- # })
126
- end
127
- end
128
102
  end