appsignal 0.5.3 → 0.5.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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OGM1YThiMDUxODYwMmYxNzc3NGFhM2FkMzliNmM2NTAxY2FhMDA1Mw==
5
- data.tar.gz: !binary |-
6
- ZjljZWQ2YzBiMWUzNTc1ZThkYjAxYzIwZTA3YzBkZDliNDY5ZjhiZg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MmE4YWQ3MzNhYmQ4NGNlZTJlZDM5MDVkNGZlN2RjOWE5ODk3OTg5NDg3NzIw
10
- ZjUwYTAxYWI4OTkzMWUwNzMwYzMyMmFjZTVkYjRhMWUzZGU1OTY4Y2ExZjY1
11
- ZGFkYmQ1Zjg2ZWI2YmQ0OTgxZTk4YzBmYjcxZDcwNzE1Y2NmNjM=
12
- data.tar.gz: !binary |-
13
- OWFjYjM1MWM3NDgyNmFlZjk2MTE2NWNlZGZjNzkxOGY5ZGNiOTBkMzZhZGJj
14
- MDY0NmMwYTQ4ZmU2YjY3N2RhZDBkZDg4MzllZjczNTA4YzUyM2VkN2FkODMw
15
- NjZhYTA3ZTk3ZjY1NzUyOGY4NTEyOTcxMTI2ZDVkODg5Nzk2Mzc=
2
+ SHA1:
3
+ metadata.gz: ac8120b63e45fdea0861e414b1c64bff97abb942
4
+ data.tar.gz: 25b2c51d536d5dae8a637ff109c436776942df8a
5
+ SHA512:
6
+ metadata.gz: 6316bff3682062da20c389a3b875f06f9a91e3e9e078380ec61d57ad1b01cdbe7ae4d6668b491000b7f1b563c0e959b486ef513bc66e621cbc88578cba0d873d
7
+ data.tar.gz: ab0be93d7752313f9970c1c9c91955a1b55d8cbadc13003d90e1f89fa70b1f03daf8922404ca49a45cd9b1a36d034deae36c5a8ac5b28f29f9d6c36c8a8695bf
@@ -1,14 +1,14 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- # - 1.9.2
5
- - 1.9.3
6
4
  - 1.8.7
5
+ - 1.9.2
6
+ - 1.9.3
7
7
  - ree
8
- # - ruby-head
9
- # - jruby-18mode
8
+ - ruby-head
9
+ - jruby-18mode
10
10
  - jruby-19mode
11
- # - jruby-head
11
+ - jruby-head
12
12
 
13
13
  gemfile:
14
14
  - gemfiles/3.0.gemfile
File without changes
data/Rakefile CHANGED
@@ -17,7 +17,9 @@ task :publish do
17
17
  puts "# Creating tag #{version}"
18
18
  puts `git tag #{version}`
19
19
  puts `git push origin #{version}`
20
+ puts `git push appsignal #{version}`
20
21
  puts `git push origin master`
22
+ puts `git push appsignal master`
21
23
  rescue
22
24
  raise "Tag: '#{version}' already exists"
23
25
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.description = 'The official appsignal.com gem'
14
14
  gem.summary = 'Logs performance and exception data from your app to'\
15
15
  'appsignal.com'
16
- gem.homepage = 'http://github.com/80beans/appsignal'
16
+ gem.homepage = 'http://github.com/appsignal/appsignal'
17
17
 
18
18
  gem.files = `git ls-files`.split($\)
19
19
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -27,6 +27,7 @@ module Appsignal
27
27
  @in_memory_log = StringIO.new unless @in_memory_log
28
28
  @logger ||= Logger.new(@in_memory_log).tap do |l|
29
29
  l.level = Logger::INFO
30
+ l.formatter = Logger::Formatter.new
30
31
  end
31
32
  end
32
33
 
@@ -12,7 +12,7 @@ module Appsignal
12
12
  @thread = Thread.new do
13
13
  while true do
14
14
  send_queue if aggregator.has_transactions?
15
- Appsignal.logger.debug("[#{$$}] Sleeping #{sleep_time}")
15
+ Appsignal.logger.debug("Sleeping #{sleep_time}")
16
16
  sleep(sleep_time)
17
17
  end
18
18
  end
@@ -21,7 +21,7 @@ module Appsignal
21
21
  ACTION,
22
22
  Appsignal.config.fetch(:api_key)
23
23
  )
24
- Appsignal.logger.info("[#{$$}] Started the Appsignal agent")
24
+ Appsignal.logger.info("Started the Appsignal agent")
25
25
  end
26
26
 
27
27
  def enqueue(transaction)
@@ -29,7 +29,7 @@ module Appsignal
29
29
  end
30
30
 
31
31
  def send_queue
32
- Appsignal.logger.debug("[#{$$}] Sending queue")
32
+ Appsignal.logger.debug("Sending queue")
33
33
  current_aggregator = aggregator
34
34
  @aggregator = Aggregator.new
35
35
  begin
@@ -43,7 +43,7 @@ module Appsignal
43
43
  def forked!
44
44
  @forked = true
45
45
  @aggregator = Aggregator.new
46
- Appsignal.logger.info("[#{$$}] Forked the Appsignal agent")
46
+ Appsignal.logger.info("Forked the Appsignal agent")
47
47
  end
48
48
 
49
49
  def forked?
@@ -51,7 +51,7 @@ module Appsignal
51
51
  end
52
52
 
53
53
  def shutdown(send_current_queue=false)
54
- Appsignal.logger.info("[#{$$}] Shutting down the agent")
54
+ Appsignal.logger.info("Shutting down the agent")
55
55
  ActiveSupport::Notifications.unsubscribe(Appsignal.subscriber)
56
56
  Thread.kill(thread) if thread
57
57
  send_queue if send_current_queue && @aggregator.has_transactions?
@@ -60,7 +60,7 @@ module Appsignal
60
60
  protected
61
61
 
62
62
  def handle_result(code)
63
- Appsignal.logger.debug "[#{$$}] Queue sent, response code: #{code}"
63
+ Appsignal.logger.debug "Queue sent, response code: #{code}"
64
64
  case code.to_i
65
65
  when 200 # ok
66
66
  when 420 # Enhance Your Calm
@@ -68,20 +68,20 @@ module Appsignal
68
68
  when 413 # Request Entity Too Large
69
69
  @sleep_time = sleep_time / 1.5
70
70
  when 429
71
- Appsignal.logger.error "[#{$$}] Too many requests sent"
71
+ Appsignal.logger.error "Too many requests sent"
72
72
  shutdown
73
73
  when 406
74
- Appsignal.logger.error "[#{$$}] Your appsignal gem cannot "\
74
+ Appsignal.logger.error "Your appsignal gem cannot "\
75
75
  "communicate with the API anymore, please upgrade."
76
76
  shutdown
77
77
  when 402
78
- Appsignal.logger.error "[#{$$}] Payment required"
78
+ Appsignal.logger.error "Payment required"
79
79
  shutdown
80
80
  when 401
81
- Appsignal.logger.error "[#{$$}] API token cannot be authorized"
81
+ Appsignal.logger.error "API token cannot be authorized"
82
82
  shutdown
83
83
  else
84
- Appsignal.logger.error "[#{$$}] Unknown Appsignal response code: "\
84
+ Appsignal.logger.error "Unknown Appsignal response code: "\
85
85
  "'#{code}'"
86
86
  end
87
87
  end
@@ -1,10 +1,11 @@
1
1
  module Appsignal
2
2
  class Aggregator
3
- attr_reader :queue, :slowness_index
3
+ attr_reader :queue, :slowness_index, :counts
4
4
 
5
5
  def initialize(queue = [], slowness_index = {})
6
6
  @queue = queue
7
7
  @slowness_index = slowness_index
8
+ @counts = {:regular_request => 0, :slow_request => 0, :exception => 0}
8
9
  end
9
10
 
10
11
  # truncates or reduces the size of event values of the transaction, and
@@ -20,6 +21,7 @@ module Appsignal
20
21
  when :exception
21
22
  transaction.convert_values_to_primitives!
22
23
  end
24
+ counts[transaction.type] += 1
23
25
  queue << transaction
24
26
  end
25
27
 
@@ -34,6 +36,7 @@ module Appsignal
34
36
  #
35
37
  # @returns [ Array ] Array of post processed Appsignal::Transaction objects
36
38
  def post_processed_queue!
39
+ Appsignal.logger.debug("Post processing queue: #{counts.inspect}")
37
40
  Appsignal::PostProcessor.new(queue).post_processed_queue!
38
41
  end
39
42
 
@@ -25,7 +25,7 @@ module Appsignal
25
25
 
26
26
  marker = Marker.new(marker_data, ENV['PWD'], rails_env, logger)
27
27
  if config.dry_run
28
- logger.info "Dry run: Deploy marker not actually sent."
28
+ logger.info("Dry run: Deploy marker not actually sent.")
29
29
  else
30
30
  marker.transmit
31
31
  end
@@ -11,11 +11,11 @@ require 'appsignal/transmitter'
11
11
  module Appsignal
12
12
  class CLI
13
13
  AVAILABLE_COMMANDS = %w(notify_of_deploy api_check).freeze
14
- PROJECT_ROOT = File.join(File.dirname(__FILE__), '..', '..').freeze
14
+ PROJECT_ROOT = ENV['PWD']
15
15
 
16
16
  class << self
17
17
  def run(argv=ARGV)
18
- unless File.exists?(File.join(ENV['PWD'], 'config/appsignal.yml'))
18
+ unless File.exists?(File.join(PROJECT_ROOT, 'config/appsignal.yml'))
19
19
  puts 'No config file present at config/appsignal.yml'
20
20
  puts 'Log in to https://appsignal.com to get instructions on how to generate the config file.'
21
21
  exit(1)
@@ -108,7 +108,7 @@ module Appsignal
108
108
  :repository => options[:repository],
109
109
  :user => options[:user]
110
110
  },
111
- ENV['PWD'],
111
+ PROJECT_ROOT,
112
112
  options[:environment],
113
113
  logger
114
114
  ).transmit
@@ -16,22 +16,25 @@ module Appsignal
16
16
  attr_reader :configurations, :project_path, :env
17
17
 
18
18
  def initialize(project_path, env, logger=Appsignal.logger)
19
- @project_path = project_path
19
+ @project_path = project_path || ENV['PWD']
20
20
  @env = env.to_sym
21
21
  @logger = logger
22
22
  @configurations = {}
23
23
  end
24
24
 
25
25
  def load
26
- return unless load_configurations_from_disk
26
+ return unless load_configurations
27
27
  return unless used_unique_api_keys
28
28
  return unless current_environment_present
29
29
 
30
+ if Appsignal.respond_to?(:logger) && @logger == Appsignal.logger
31
+ @logger.level = Logger::DEBUG if configurations[env][:debug]
32
+ end
30
33
  DEFAULT_CONFIG.merge(configurations[env])
31
34
  end
32
35
 
33
36
  def load_all
34
- return unless load_configurations_from_disk
37
+ return unless load_configurations
35
38
  return unless used_unique_api_keys
36
39
 
37
40
  {}.tap do |result|
@@ -43,10 +46,22 @@ module Appsignal
43
46
 
44
47
  protected
45
48
 
49
+ def config_file
50
+ File.join(project_path, 'config', 'appsignal.yml')
51
+ end
52
+
53
+ def load_configurations
54
+ unless load_configurations_from_disk || load_configurations_from_env
55
+ carefully_log_error "no config file found at '#{config_file}'
56
+ and no APPSIGNAL_API_KEY found in ENV"
57
+ return false
58
+ end
59
+ true
60
+ end
61
+
46
62
  def load_configurations_from_disk
47
- file = File.join(project_path, 'config', 'appsignal.yml')
63
+ file = config_file
48
64
  unless File.exists?(file)
49
- carefully_log_error "config not found at: '#{file}'"
50
65
  return false
51
66
  end
52
67
  @configurations = YAML.load(ERB.new(IO.read(file)).result)
@@ -55,6 +70,17 @@ module Appsignal
55
70
  true
56
71
  end
57
72
 
73
+ def load_configurations_from_env
74
+ api_key = ENV['APPSIGNAL_API_KEY']
75
+ env = ENV['RAILS_ENV'] || :production
76
+ if api_key.present?
77
+ @configurations = {env.to_sym => {:api_key => api_key, :active => true}}
78
+ true
79
+ else
80
+ false
81
+ end
82
+ end
83
+
58
84
  def used_unique_api_keys
59
85
  keys = configurations.each_value.map { |config| config[:api_key] }.compact
60
86
  if keys.uniq.count < keys.count
@@ -1,11 +1,13 @@
1
1
  if defined?(PhusionPassenger)
2
+ Appsignal.logger.info("Using Passenger")
3
+
2
4
  PhusionPassenger.on_event(:starting_worker_process) do |forked|
3
- Appsignal.logger.debug("[#{$$}] starting worker process")
5
+ Appsignal.logger.debug("starting worker process")
4
6
  Appsignal.agent.forked!
5
7
  end
6
8
 
7
9
  PhusionPassenger.on_event(:stopping_worker_process) do
8
- Appsignal.logger.debug("[#{$$}] stopping worker process")
10
+ Appsignal.logger.debug("stopping worker process")
9
11
  Appsignal.agent.shutdown(true)
10
12
  end
11
13
  end
@@ -18,10 +18,10 @@ module Appsignal
18
18
  transmitter = Transmitter.new(
19
19
  @config[:endpoint], ACTION, @config[:api_key]
20
20
  )
21
- @logger.info "Notifying Appsignal of deploy..."
21
+ @logger.info("Notifying Appsignal of deploy...")
22
22
  result = transmitter.transmit(marker_data)
23
23
  if result == '200'
24
- @logger.info "Appsignal has been notified of this deploy!"
24
+ @logger.info("Appsignal has been notified of this deploy!")
25
25
  else
26
26
  raise "#{result} at #{transmitter.uri}"
27
27
  end
@@ -24,11 +24,11 @@ module Appsignal
24
24
  Appsignal.transactions[Thread.current[:appsignal_transaction_id]]
25
25
  end
26
26
 
27
- attr_reader :id, :events, :process_action_event, :action, :exception, :env,
28
- :fullpath, :time
27
+ attr_reader :request_id, :events, :process_action_event, :action, :exception,
28
+ :env, :fullpath, :time
29
29
 
30
- def initialize(id, env)
31
- @id = id
30
+ def initialize(request_id, env)
31
+ @request_id = request_id
32
32
  @events = []
33
33
  @process_action_event = nil
34
34
  @exception = nil
@@ -103,7 +103,7 @@ module Appsignal
103
103
 
104
104
  def complete!
105
105
  Thread.current[:appsignal_transaction_id] = nil
106
- current_transaction = Appsignal.transactions.delete(@id)
106
+ current_transaction = Appsignal.transactions.delete(@request_id)
107
107
  if process_action_event || exception?
108
108
  Appsignal.enqueue(current_transaction)
109
109
  end
@@ -2,6 +2,7 @@ require 'delegate'
2
2
 
3
3
  module Appsignal
4
4
  class TransactionFormatter < SimpleDelegator
5
+
5
6
  def initialize(transaction)
6
7
  super(transaction)
7
8
  end
@@ -21,7 +22,7 @@ module Appsignal
21
22
 
22
23
  def default_hash
23
24
  {
24
- :request_id => id,
25
+ :request_id => request_id,
25
26
  :log_entry => {
26
27
  :path => fullpath,
27
28
  :kind => 'http_request',
@@ -1,3 +1,3 @@
1
1
  module Appsignal
2
- VERSION = '0.5.3'
2
+ VERSION = '0.5.5'
3
3
  end
@@ -17,7 +17,7 @@ class AppsignalGenerator < Rails::Generators::Base
17
17
  say_status(:error, "#{environment}:", :red)
18
18
  say_status(:error, " api_key: #{push_key}\n\n", :red)
19
19
  say_status(:info, "Then run:\n\n", :red)
20
- say_status(:info, " rake appsignal:check", :red)
20
+ say_status(:info, " appsignal api_check", :red)
21
21
  else
22
22
  template template_file, appsignal_file
23
23
  capyistrano_install
@@ -54,6 +54,62 @@ describe Appsignal::CLI do
54
54
  "appsignal -h to see the help"
55
55
  end
56
56
 
57
+ describe "#notify_of_deploy" do
58
+ it "should validate that all options have been supplied" do
59
+ options = {}
60
+ cli.should_receive(:validate_required_options).with(
61
+ [:revision, :repository, :user, :environment],
62
+ options
63
+ )
64
+ Appsignal::Marker.should_receive(:new).
65
+ and_return(mock(:transmit => true))
66
+ cli.notify_of_deploy(options)
67
+ end
68
+
69
+ it "should notify of a deploy" do
70
+ transmitter = double
71
+ Appsignal::Transmitter.should_receive(:new).with(
72
+ 'http://localhost:3000/1',
73
+ 'markers',
74
+ 'def'
75
+ ).and_return(transmitter)
76
+ transmitter.should_receive(:transmit).with(
77
+ :revision => 'aaaaa',
78
+ :repository => 'git@github.com:our/project.git',
79
+ :user => 'thijs'
80
+ )
81
+
82
+ cli.run([
83
+ 'notify_of_deploy',
84
+ '--revision=aaaaa',
85
+ '--repository=git@github.com:our/project.git',
86
+ '--user=thijs',
87
+ '--environment=production'
88
+ ])
89
+ end
90
+ end
91
+
92
+ describe "api_check" do
93
+ it "should detect configured environments" do
94
+ authcheck = double
95
+ Appsignal::AuthCheck.should_receive(:new).with(
96
+ :development,
97
+ kind_of(Hash)
98
+ ).and_return(authcheck)
99
+ Appsignal::AuthCheck.should_receive(:new).with(
100
+ :production,
101
+ kind_of(Hash)
102
+ ).and_return(authcheck)
103
+ Appsignal::AuthCheck.should_receive(:new).with(
104
+ :test,
105
+ kind_of(Hash)
106
+ ).and_return(authcheck)
107
+
108
+ authcheck.should_receive(:perform).exactly(3).times.and_return('200')
109
+ cli.api_check
110
+ end
111
+ end
112
+
57
113
  # protected
58
114
 
59
115
  describe "#validate_required_options" do
@@ -94,39 +150,4 @@ describe Appsignal::CLI do
94
150
  out_stream.string.should include("Missing options: option_2, option_3")
95
151
  end
96
152
  end
97
-
98
- describe "#notify_of_deploy" do
99
- it "should validate that all options have been supplied" do
100
- options = {}
101
- cli.should_receive(:validate_required_options).with(
102
- [:revision, :repository, :user, :environment],
103
- options
104
- )
105
- Appsignal::Marker.should_receive(:new).
106
- and_return(mock(:transmit => true))
107
- cli.notify_of_deploy(options)
108
- end
109
-
110
- it "should notify of a deploy" do
111
- transmitter = double
112
- Appsignal::Transmitter.should_receive(:new).with(
113
- 'http://localhost:3000/1',
114
- 'markers',
115
- 'def'
116
- ).and_return(transmitter)
117
- transmitter.should_receive(:transmit).with(
118
- :revision => 'aaaaa',
119
- :repository => 'git@github.com:our/project.git',
120
- :user => 'thijs'
121
- )
122
-
123
- cli.run([
124
- 'notify_of_deploy',
125
- '--revision=aaaaa',
126
- '--repository=git@github.com:our/project.git',
127
- '--user=thijs',
128
- '--environment=production'
129
- ])
130
- end
131
- end
132
153
  end
@@ -24,11 +24,25 @@ describe Appsignal::Config do
24
24
  }
25
25
 
26
26
  context 'when there is no config file' do
27
- before { Dir.stub(:pwd => '/not/existing') }
27
+ before { config.stub(:config_file => '/not/existing') }
28
28
 
29
29
  it { should be_nil }
30
30
  end
31
31
 
32
+ context "the current env is in debug mode" do
33
+ context "using the Appsignal logger" do
34
+ specify { Appsignal.logger.should_not_receive(:level=) }
35
+ end
36
+
37
+ context "using another logger" do
38
+ let(:logger_parameter) { [Appsignal.logger.clone] }
39
+
40
+ specify { Appsignal.logger.should_not_receive(:level=) }
41
+ end
42
+
43
+ after { subject }
44
+ end
45
+
32
46
  context "the env is not in the config" do
33
47
  before { config.stub(:current_environment_present => false) }
34
48
 
@@ -44,6 +58,37 @@ describe Appsignal::Config do
44
58
 
45
59
  # protected
46
60
 
61
+ describe "#load_configurations" do
62
+ subject { config.send(:load_configurations) }
63
+
64
+ context "when there is a config file" do
65
+ before do
66
+ config.should_receive(:load_configurations_from_disk).and_return(true)
67
+ end
68
+
69
+ it { should be_true }
70
+ end
71
+
72
+ context "when there is no config file" do
73
+ before do
74
+ config.should_receive(:load_configurations_from_disk).and_return(false)
75
+ config.should_receive(:load_configurations_from_env).and_return(true)
76
+ end
77
+
78
+ it { should be_true }
79
+ end
80
+
81
+ context "when there is no env api_key" do
82
+ before do
83
+ config.should_receive(:load_configurations_from_disk).and_return(false)
84
+ config.should_receive(:load_configurations_from_env).and_return(false)
85
+ config.should_receive(:carefully_log_error)
86
+ end
87
+
88
+ it { should be_false }
89
+ end
90
+ end
91
+
47
92
  describe "#load_configurations_from_disk" do
48
93
  subject do
49
94
  config.send(:load_configurations_from_disk)
@@ -57,12 +102,37 @@ describe Appsignal::Config do
57
102
  end
58
103
 
59
104
  context "when the file is not present" do
105
+ before { config.stub(:project_path => '/non/existing') }
106
+
107
+ it { should be_empty }
108
+ end
109
+ end
110
+
111
+ describe "#load_configurations_from_env" do
112
+ subject do
113
+ config.send(:load_configurations_from_env)
114
+ config.configurations
115
+ end
116
+
117
+ context "when the ENV api_key variable is present" do
118
+ before { ENV['APPSIGNAL_API_KEY'] = 'ghi' }
119
+
120
+ it { should == {:test => {:api_key => "ghi", :active => true}} }
121
+ end
122
+
123
+ context "when the ENV api_key variable is not present" do
124
+ before { ENV['APPSIGNAL_API_KEY'] = nil }
125
+
126
+ it { should be_empty }
127
+ end
128
+
129
+ context "when the RAILS env is not present" do
60
130
  before do
61
- config.should_receive(:carefully_log_error)
62
- config.stub(:project_path => '/non/existing')
131
+ ENV['APPSIGNAL_API_KEY'] = 'ghi'
132
+ ENV['RAILS_ENV'] = nil
63
133
  end
64
134
 
65
- it { should be_empty }
135
+ it { should == {:production => {:api_key => "ghi", :active => true}} }
66
136
  end
67
137
  end
68
138
 
@@ -11,7 +11,7 @@ describe Appsignal::ToAppsignalHash do
11
11
 
12
12
  it { should == {
13
13
  :time => 978364860.0,
14
- :duration => 100.0,
14
+ :duration => be_within(0.01).of(100.0),
15
15
  :end => 978364860.1,
16
16
  :name => "process_action.action_controller",
17
17
  :payload => {
@@ -13,12 +13,12 @@ describe Appsignal::TransactionFormatter do
13
13
  context "with a regular request" do
14
14
  let(:transaction) { regular_transaction }
15
15
 
16
- its(:keys) { should == [:request_id, :log_entry, :failed] }
16
+ its(:keys) { should =~ [:request_id, :log_entry, :failed] }
17
17
  its([:request_id]) { should == '1' }
18
18
  its([:log_entry]) { should == {
19
19
  :action => "BlogPostsController#show",
20
20
  :db_runtime => 500,
21
- :duration => 100.0,
21
+ :duration => be_within(0.01).of(100.0),
22
22
  :end => 978364860.1,
23
23
  :environment => {},
24
24
  :kind => "http_request",
@@ -36,14 +36,14 @@ describe Appsignal::TransactionFormatter do
36
36
  context "with an exception request" do
37
37
  let(:transaction) { transaction_with_exception }
38
38
 
39
- its(:keys) { should == [:request_id, :log_entry, :failed, :exception] }
39
+ its(:keys) { should =~ [:request_id, :log_entry, :failed, :exception] }
40
40
  its([:request_id]) { should == '1' }
41
41
  its([:failed]) { should be_true }
42
42
 
43
43
  context "exception content" do
44
44
  subject { formatter.hash[:exception] }
45
45
 
46
- its(:keys) { should == [:backtrace, :exception, :message] }
46
+ its(:keys) { should =~ [:backtrace, :exception, :message] }
47
47
  its([:backtrace]) { should be_instance_of Array }
48
48
  its([:exception]) { should == 'ArgumentError' }
49
49
  its([:message]) { should == 'oh no' }
@@ -53,7 +53,7 @@ describe Appsignal::TransactionFormatter do
53
53
  context "with a slow request" do
54
54
  let(:transaction) { slow_transaction }
55
55
 
56
- its(:keys) { should == [:request_id, :log_entry, :failed, :events] }
56
+ its(:keys) { should =~ [:request_id, :log_entry, :failed, :events] }
57
57
  its([:request_id]) { should == '1' }
58
58
  its([:failed]) { should be_false }
59
59
 
@@ -63,7 +63,7 @@ describe Appsignal::TransactionFormatter do
63
63
  its(:length) { should == 1 }
64
64
  its(:first) { should == {
65
65
  :name => "query.mongoid",
66
- :duration => 100.0,
66
+ :duration => be_within(0.01).of(100.0),
67
67
  :time => 978364860.0,
68
68
  :end => 978364860.1,
69
69
  :payload => {
@@ -102,7 +102,7 @@ describe Appsignal::Transaction do
102
102
  end
103
103
 
104
104
  context "when the request took too long" do
105
- let(:duration) { 0.200 } # in seconds
105
+ let(:duration) { 0.201 } # in seconds
106
106
 
107
107
  it { should be_true }
108
108
  end
@@ -298,7 +298,7 @@ describe Appsignal::Transaction do
298
298
  subject { transaction.sanitized_environment }
299
299
  before { transaction.send(:sanitize_environment!) }
300
300
 
301
- its(:keys) { should == whitelisted_keys }
301
+ its(:keys) { should =~ whitelisted_keys }
302
302
  end
303
303
 
304
304
  describe '#sanitize_session_data!' do
@@ -10,10 +10,11 @@ describe Appsignal::Transmitter do
10
10
  describe "#uri" do
11
11
  it "returns the uri" do
12
12
  Socket.stub(:gethostname => 'app1.local')
13
- subject.uri.should == URI(
14
- "http://www.80beans.com/action?api_key=the_api_key&"\
15
- "hostname=app1.local&gem_version=#{Appsignal::VERSION}"
16
- )
13
+ uri = subject.uri.to_s
14
+ uri.should include "http://www.80beans.com/action?"
15
+ uri.should include "api_key=the_api_key"
16
+ uri.should include "hostname=app1.local"
17
+ uri.should include "gem_version=#{Appsignal::VERSION}"
17
18
  end
18
19
  end
19
20
 
@@ -36,8 +37,7 @@ describe Appsignal::Transmitter do
36
37
  Socket.stub(:gethostname => 'app1.local')
37
38
 
38
39
  Net::HTTP::Post.should_receive(:new).with(
39
- "/action?api_key=the_api_key&hostname=app1.local&"\
40
- "gem_version=#{Appsignal::VERSION}"
40
+ instance.uri.request_uri
41
41
  ).and_return(post)
42
42
  instance.send(:http_post, :the => :payload)
43
43
  end
@@ -41,7 +41,7 @@ describe Appsignal do
41
41
  end
42
42
 
43
43
  it 'should return the api key' do
44
- subject[:api_key].should eq 'abc'
44
+ subject[:api_key].should eq 'ghi'
45
45
  end
46
46
 
47
47
  it 'should return ignored exceptions' do
@@ -1,5 +1,5 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
1
2
  require 'rspec'
2
- require 'pry'
3
3
  require 'rails'
4
4
  require 'action_controller/railtie'
5
5
 
@@ -26,7 +26,7 @@ module TransactionHelpers
26
26
  {
27
27
  :process_action_event => notification_event(
28
28
  :start => fixed_time,
29
- :ending => fixed_time + Appsignal.config[:slow_request_threshold] / 1000.0
29
+ :ending => fixed_time + Appsignal.config[:slow_request_threshold] / 999.99
30
30
  )
31
31
  }.merge(args)
32
32
  )
@@ -37,7 +37,7 @@ module TransactionHelpers
37
37
  {
38
38
  :process_action_event => notification_event(
39
39
  :start => fixed_time,
40
- :ending => fixed_time + Appsignal.config[:slow_request_threshold] / 500.0
40
+ :ending => fixed_time + Appsignal.config[:slow_request_threshold] / 499.99
41
41
  )
42
42
  }.merge(args)
43
43
  )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-05-16 00:00:00.000000000 Z
15
+ date: 2013-06-09 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rails
@@ -32,84 +32,84 @@ dependencies:
32
32
  name: rake
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  requirements:
35
- - - ! '>='
35
+ - - '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - ! '>='
42
+ - - '>='
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: json
47
47
  requirement: !ruby/object:Gem::Requirement
48
48
  requirements:
49
- - - ! '>='
49
+ - - '>='
50
50
  - !ruby/object:Gem::Version
51
51
  version: '0'
52
52
  type: :runtime
53
53
  prerelease: false
54
54
  version_requirements: !ruby/object:Gem::Requirement
55
55
  requirements:
56
- - - ! '>='
56
+ - - '>='
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rspec
61
61
  requirement: !ruby/object:Gem::Requirement
62
62
  requirements:
63
- - - ! '>='
63
+ - - '>='
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - ! '>='
70
+ - - '>='
71
71
  - !ruby/object:Gem::Version
72
72
  version: '0'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: capistrano
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - ! '>='
77
+ - - '>='
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  type: :development
81
81
  prerelease: false
82
82
  version_requirements: !ruby/object:Gem::Requirement
83
83
  requirements:
84
- - - ! '>='
84
+ - - '>='
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: generator_spec
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - ! '>='
91
+ - - '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  type: :development
95
95
  prerelease: false
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - ! '>='
98
+ - - '>='
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: pry
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - ! '>='
105
+ - - '>='
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  type: :development
109
109
  prerelease: false
110
110
  version_requirements: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - ! '>='
112
+ - - '>='
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  description: The official appsignal.com gem
@@ -125,7 +125,7 @@ files:
125
125
  - .travis.yml
126
126
  - CHANGELOG.md
127
127
  - Gemfile
128
- - LICENCE
128
+ - LICENSE
129
129
  - README.md
130
130
  - Rakefile
131
131
  - appsignal.gemspec
@@ -193,7 +193,7 @@ files:
193
193
  - spec/support/delegate_matcher.rb
194
194
  - spec/support/helpers/notification_helpers.rb
195
195
  - spec/support/helpers/transaction_helpers.rb
196
- homepage: http://github.com/80beans/appsignal
196
+ homepage: http://github.com/appsignal/appsignal
197
197
  licenses: []
198
198
  metadata: {}
199
199
  post_install_message:
@@ -202,12 +202,12 @@ require_paths:
202
202
  - lib
203
203
  required_ruby_version: !ruby/object:Gem::Requirement
204
204
  requirements:
205
- - - ! '>='
205
+ - - '>='
206
206
  - !ruby/object:Gem::Version
207
207
  version: '0'
208
208
  required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  requirements:
210
- - - ! '>='
210
+ - - '>='
211
211
  - !ruby/object:Gem::Version
212
212
  version: '0'
213
213
  requirements: []