appsignal 2.0.4 → 2.0.5.beta.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: 1aa4703023302308a9af7c3133cbbb347bc03eaa
4
- data.tar.gz: 7c262a115fb2abeb53af582af27536b836e60475
3
+ metadata.gz: 329070b96ca1a7f2e2c9a77c5abc9e267783d83e
4
+ data.tar.gz: 36fae6abc5f7f03f9b12684adae1df0646adbec5
5
5
  SHA512:
6
- metadata.gz: 57f347f6c7d8a8fa9729fe7f20679437b737455155c45430c1d0532b1ea8b38aab5d7af35b0b02108110919606af60b33579fdf7c0ce4d3c00cae043dba3ae3c
7
- data.tar.gz: 1b74452af063d9299bd1040e98373ddfecae5a0de90a2a365bd7ba24d95fc2f78019b1e1675ff85d3bde8ad215ba10c63bcbbdb5296f91d87ed7f74027b9daf4
6
+ metadata.gz: cbbafdddb5fe71ee3f9616a19c92dc7c23da7e791a531fec1a636bb2cd2d9bf1e76d1876c44bad7247e3ab26ae5aeee3a2399b82a26db86245ea437ef5d89819
7
+ data.tar.gz: 71a422533810749f8379340e5760d71b01072ff3370d92ba3ab1de026008a54aebda4e8c28d953ad27bb074d9877b965f5813edc0f13c7a3d9a13496ecf593fb
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .sass-cache
4
4
  capybara-*.html
5
5
  *.log
6
+ /doc
6
7
  /.bundle
7
8
  /vendor/bundle
8
9
  /tmp/*
@@ -1,3 +1,7 @@
1
+ # 2.0.5
2
+ * Improved logging for agent connection issues
3
+ * Handle nil request/environments in transactions
4
+
1
5
  # 2.0.4
2
6
  * Use consistent log format for both file and STDOUT logs. PR #203
3
7
  * Fix log path in `appsignal diagnose` for Rails applications. PR #218, #222
@@ -1,18 +1,18 @@
1
1
  ---
2
- version: c18d324
2
+ version: a1cb32f
3
3
  triples:
4
4
  x86_64-linux:
5
- checksum: 67a21c8481684466b39a55a6b7418fa838d98e3e4570c9a082ba23e5147d5a64
6
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/c18d324/appsignal-x86_64-linux-all-static.tar.gz
5
+ checksum: 8905166cbd29ad3038d013438781118bb2fa4ea3fef2e7abfe3a4a4d90d7b40c
6
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/a1cb32f/appsignal-x86_64-linux-all-static.tar.gz
7
7
  i686-linux:
8
- checksum: 958cc0a742bea1e411bb6dbe0f7f124fe6ec273b8ae0d9b9317f306d60ee0b5d
9
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/c18d324/appsignal-i686-linux-all-static.tar.gz
8
+ checksum: 0ae5f06cf9fd516c7a33cbe29a78016b3b419717870d5fba793345fecb696950
9
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/a1cb32f/appsignal-i686-linux-all-static.tar.gz
10
10
  x86-linux:
11
- checksum: 958cc0a742bea1e411bb6dbe0f7f124fe6ec273b8ae0d9b9317f306d60ee0b5d
12
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/c18d324/appsignal-i686-linux-all-static.tar.gz
11
+ checksum: 0ae5f06cf9fd516c7a33cbe29a78016b3b419717870d5fba793345fecb696950
12
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/a1cb32f/appsignal-i686-linux-all-static.tar.gz
13
13
  x86_64-darwin:
14
- checksum: 89053389ddf816aaefc1580899eca8bcac9837dfdfabf6f333a853d17f2edec8
15
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/c18d324/appsignal-x86_64-darwin-all-static.tar.gz
14
+ checksum: 750e49e56c2024c82adc64471feb855ab7a5caff79cb37978a83e11e31a023ce
15
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/a1cb32f/appsignal-x86_64-darwin-all-static.tar.gz
16
16
  universal-darwin:
17
- checksum: 89053389ddf816aaefc1580899eca8bcac9837dfdfabf6f333a853d17f2edec8
18
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/c18d324/appsignal-x86_64-darwin-all-static.tar.gz
17
+ checksum: 750e49e56c2024c82adc64471feb855ab7a5caff79cb37978a83e11e31a023ce
18
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/a1cb32f/appsignal-x86_64-darwin-all-static.tar.gz
@@ -4,3 +4,7 @@ gem 'rails', '~> 4.2.0'
4
4
  gem 'mime-types', '~> 2.6'
5
5
 
6
6
  gemspec :path => '../'
7
+
8
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1.0")
9
+ gem 'nokogiri', '~> 1.6.0'
10
+ end
@@ -6,3 +6,7 @@ gem 'sinatra'
6
6
  gem 'mime-types', '~> 2.6'
7
7
 
8
8
  gemspec :path => '../'
9
+
10
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1.0")
11
+ gem 'nokogiri', '~> 1.6.0'
12
+ end
@@ -238,23 +238,40 @@ module Appsignal
238
238
 
239
239
  protected
240
240
 
241
+ # Returns calculated background queue start time in milliseconds, based on
242
+ # environment values.
243
+ #
244
+ # @return [nil] if no {#environment} is present.
245
+ # @return [nil] if there is no `:queue_start` in the {#environment}.
246
+ # @return [Integer]
241
247
  def background_queue_start
242
- return unless request.env
243
- return unless queue_start = request.env[:queue_start]
248
+ env = environment
249
+ return unless env
250
+ queue_start = env[:queue_start]
251
+ return unless queue_start
252
+
244
253
  (queue_start.to_f * 1000.0).to_i
245
254
  end
246
255
 
256
+ # Returns HTTP queue start time in milliseconds.
257
+ #
258
+ # @return [nil] if no queue start time is found.
259
+ # @return [nil] if begin time is too low to be plausible.
260
+ # @return [Integer] queue start in milliseconds.
247
261
  def http_queue_start
248
- return unless request.env
249
- return unless env_var = request.env['HTTP_X_QUEUE_START'.freeze] || request.env['HTTP_X_REQUEST_START'.freeze]
250
- cleaned_value = env_var.tr('^0-9'.freeze, ''.freeze)
262
+ env = environment
263
+ return unless env
264
+ env_var = env["HTTP_X_QUEUE_START".freeze] || env["HTTP_X_REQUEST_START".freeze]
265
+ return unless env_var
266
+ cleaned_value = env_var.tr("^0-9".freeze, "".freeze)
251
267
  return if cleaned_value.empty?
268
+
252
269
  value = cleaned_value.to_i
253
270
  if value > 4_102_441_200_000
254
- # Value is in microseconds
271
+ # Value is in microseconds. Transform to milliseconds.
255
272
  value / 1_000
256
273
  elsif value < 946_681_200_000
257
- # Value is to low to be plausible
274
+ # Value is too low to be plausible
258
275
  nil
259
276
  else
260
277
  # Value is in milliseconds
@@ -283,24 +300,62 @@ module Appsignal
283
300
  Appsignal::Utils::ParamsSanitizer.sanitize params, options
284
301
  end
285
302
 
303
+ # Returns sanitized environment for a transaction.
304
+ #
305
+ # The environment of a transaction can contain a lot of information, not
306
+ # all of it useful for debugging.
307
+ #
308
+ # Only the values from the keys specified in `ENV_METHODS` are returned.
309
+ #
310
+ # @return [nil] if no environment is present.
311
+ # @return [Hash<String, Object>]
286
312
  def sanitized_environment
287
- return unless request.env
313
+ env = environment
314
+ return if env.empty?
315
+
288
316
  {}.tap do |out|
289
317
  ENV_METHODS.each do |key|
290
- out[key] = request.env[key] if request.env[key]
318
+ out[key] = env[key] if env[key]
291
319
  end
292
320
  end
293
321
  end
294
322
 
323
+ # Returns sanitized session data.
324
+ #
325
+ # The session data is sanitized by the {Appsignal::Utils::ParamsSanitizer}.
326
+ #
327
+ # @return [nil] if `:skip_session_data` config is set to `true`.
328
+ # @return [nil] if the {#request} object doesn't respond to `#session`.
329
+ # @return [nil] if the {#request} session data is `nil`.
330
+ # @return [Hash<String, Object>]
295
331
  def sanitized_session_data
296
- return if Appsignal.config[:skip_session_data] || !request.respond_to?(:session)
297
- return unless session = request.session
332
+ return if Appsignal.config[:skip_session_data] ||
333
+ !request.respond_to?(:session)
334
+ session = request.session
335
+ return unless session
336
+
298
337
  Appsignal::Utils::ParamsSanitizer.sanitize(session.to_hash)
299
338
  end
300
339
 
340
+ # Returns metadata from the environment.
341
+ #
342
+ # @return [nil] if no `:metadata` key is present in the {#environment}.
343
+ # @return [Hash<String, Object>]
301
344
  def metadata
302
- return unless request.env
303
- request.env[:metadata]
345
+ environment[:metadata]
346
+ end
347
+
348
+ # Returns the environment for a transaction.
349
+ #
350
+ # Returns an empty Hash when the {#request} object doesn't listen to the
351
+ # `#env` method or the `#env` is nil.
352
+ #
353
+ # @return [Hash<String, Object>]
354
+ def environment
355
+ return {} unless request.respond_to?(:env)
356
+ return {} unless request.env
357
+
358
+ request.env
304
359
  end
305
360
 
306
361
  # Only keep tags if they meet the following criteria:
@@ -1,5 +1,5 @@
1
1
  require 'yaml'
2
2
 
3
3
  module Appsignal
4
- VERSION = '2.0.4'
4
+ VERSION = '2.0.5.beta.1'
5
5
  end
@@ -338,8 +338,8 @@ describe Appsignal::CLI::Diagnose, :api_stub => true do
338
338
 
339
339
  it "log files fall back on system tmp directory" do
340
340
  expect(output).to include \
341
- %(log_dir_path: "#{system_tmp_dir}"\n - Writable?: yes)
342
- %(log_file_path: "#{system_tmp_log_file}"\n - Exist?: false)
341
+ %(log_dir_path: "#{system_tmp_dir}"\n - Writable?: yes),
342
+ %(log_file_path: "#{system_tmp_log_file}"\n - Exists?: no)
343
343
  end
344
344
  end
345
345
 
@@ -22,7 +22,7 @@ describe Appsignal::Transaction do
22
22
  before { Timecop.freeze(time) }
23
23
  after { Timecop.return }
24
24
 
25
- context "class methods" do
25
+ describe "class methods" do
26
26
  describe ".create" do
27
27
  it "should add the transaction to thread local" do
28
28
  Appsignal::Extension.should_receive(:start_transaction).with('1', 'http_request', 0)
@@ -599,6 +599,18 @@ describe Appsignal::Transaction do
599
599
  describe "#background_queue_start" do
600
600
  subject { transaction.send(:background_queue_start) }
601
601
 
602
+ context "when request is nil" do
603
+ let(:request) { nil }
604
+
605
+ it { should eq nil }
606
+ end
607
+
608
+ context "when env is nil" do
609
+ before { expect(transaction.request).to receive(:env).and_return(nil) }
610
+
611
+ it { should eq nil }
612
+ end
613
+
602
614
  context "when queue start is nil" do
603
615
  it { should eq nil }
604
616
  end
@@ -616,8 +628,14 @@ describe Appsignal::Transaction do
616
628
  subject { transaction.send(:http_queue_start) }
617
629
 
618
630
  shared_examples "http queue start" do
631
+ context "when request is nil" do
632
+ let(:request) { nil }
633
+
634
+ it { should be_nil }
635
+ end
636
+
619
637
  context "when env is nil" do
620
- before { transaction.request.stub(:env => nil) }
638
+ before { expect(transaction.request).to receive(:env).and_return(nil) }
621
639
 
622
640
  it { should be_nil }
623
641
  end
@@ -751,8 +769,16 @@ describe Appsignal::Transaction do
751
769
 
752
770
  subject { transaction.send(:sanitized_environment) }
753
771
 
772
+ context "when request is nil" do
773
+ let(:request) { nil }
774
+
775
+ it "returns nil" do
776
+ expect(subject).to be_nil
777
+ end
778
+ end
779
+
754
780
  context "when env is nil" do
755
- before { transaction.request.stub(:env => nil) }
781
+ before { expect(transaction.request).to receive(:env).and_return(nil) }
756
782
 
757
783
  it { should be_nil }
758
784
  end
@@ -773,14 +799,22 @@ describe Appsignal::Transaction do
773
799
  describe '#sanitized_session_data' do
774
800
  subject { transaction.send(:sanitized_session_data) }
775
801
 
776
- context "when env is nil" do
777
- before { transaction.request.stub(:session => nil) }
802
+ context "when request is nil" do
803
+ let(:request) { nil }
804
+
805
+ it "returns nil" do
806
+ expect(subject).to be_nil
807
+ end
808
+ end
809
+
810
+ context "when session is nil" do
811
+ before { expect(transaction.request).to receive(:session).and_return(nil) }
778
812
 
779
813
  it { should be_nil }
780
814
  end
781
815
 
782
- context "when env is empty" do
783
- before { transaction.request.stub(:session => {}) }
816
+ context "when session is empty" do
817
+ before { expect(transaction.request).to receive(:session).and_return({}) }
784
818
 
785
819
  it { should eq({}) }
786
820
  end
@@ -844,8 +878,14 @@ describe Appsignal::Transaction do
844
878
  describe "#metadata" do
845
879
  subject { transaction.send(:metadata) }
846
880
 
881
+ context "when request is nil" do
882
+ let(:request) { nil }
883
+
884
+ it { should be_nil }
885
+ end
886
+
847
887
  context "when env is nil" do
848
- before { transaction.request.stub(:env => nil) }
888
+ before { expect(transaction.request).to receive(:env).and_return(nil) }
849
889
 
850
890
  it { should be_nil }
851
891
  end
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: 2.0.4
4
+ version: 2.0.5.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-12-15 00:00:00.000000000 Z
12
+ date: 2017-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -327,12 +327,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
327
327
  version: '1.9'
328
328
  required_rubygems_version: !ruby/object:Gem::Requirement
329
329
  requirements:
330
- - - ">="
330
+ - - ">"
331
331
  - !ruby/object:Gem::Version
332
- version: '0'
332
+ version: 1.3.1
333
333
  requirements: []
334
334
  rubyforge_project:
335
- rubygems_version: 2.5.1
335
+ rubygems_version: 2.4.5
336
336
  signing_key:
337
337
  specification_version: 4
338
338
  summary: Logs performance and exception data from your app to appsignal.com
@@ -432,3 +432,4 @@ test_files:
432
432
  - spec/support/project_fixture/log/.gitkeep
433
433
  - spec/support/rails/my_app.rb
434
434
  - spec/support/stubs/delayed_job.rb
435
+ has_rdoc: