appsignal 0.12.rc.13 → 0.12.rc.14

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: e677ddb14f503c22d8a2f3f3019ef8ae6d6a4b5d
4
- data.tar.gz: 5110ca959cf967f1d72c79a7fc3a3697f2d98f67
3
+ metadata.gz: d5d48a39d924257facf894b4a9c2e636936db173
4
+ data.tar.gz: 959db33de85929f774e51c1ac25120a5cfef3d12
5
5
  SHA512:
6
- metadata.gz: 76d9f7df0f21d98a33040c4c11e4c8295f8677ff720ba6dec322514917ba342a3ce69c07cbc94f08d0a2e84cf425fb85d2cf128fd30a045a850cedb2076a552d
7
- data.tar.gz: f5c1ff186860f7035d0c5127d9dd544fce3170dc17e047f2f7939df1d1bad60bac6abd59aa227561136a64ff97d63d0ab048343e1bae29ddba8e3227911e55aa
6
+ metadata.gz: 8908e5a4de9c5edb13d923e57c32358dca86e7582ce976dc046ccb62e6183c237a8d4c0469d66afd0852d08be1e162a633bc21af787c1b9783e8e965c6846655
7
+ data.tar.gz: 9c2b984abd3d0734885560f9bb8a94dfa8a5fc6bdd6edb7756bace964efff1265f6f6f17d494cff61a586ecd87713a2dab25cf51075fd2a0db578e8c598a2d3c
@@ -61,7 +61,7 @@ module Appsignal
61
61
  load_from_environment
62
62
 
63
63
  # Load the config file if it exists
64
- if File.exists?(config_file)
64
+ if config_file && File.exists?(config_file)
65
65
  load_from_disk
66
66
  end
67
67
 
@@ -108,7 +108,8 @@ module Appsignal
108
108
  protected
109
109
 
110
110
  def config_file
111
- @config_file ||= File.join(root_path, 'config', 'appsignal.yml')
111
+ @config_file ||=
112
+ root_path.nil? ? nil : File.join(root_path, 'config', 'appsignal.yml')
112
113
  end
113
114
 
114
115
  def load_from_disk
@@ -45,44 +45,6 @@ module Appsignal
45
45
  raise NotImplementedError
46
46
  end
47
47
  end
48
-
49
- module Helpers
50
-
51
- def self.included(base)
52
- base.extend(ClassMethods)
53
- end
54
-
55
- module ClassMethods
56
- def truncate(text)
57
- Appsignal::Hooks::Helpers.truncate(text)
58
- end
59
-
60
- def string_or_inspect(string_or_other)
61
- Appsignal::Hooks::Helpers.string_or_inspect(string_or_other)
62
- end
63
- end
64
-
65
- def string_or_inspect(string_or_other)
66
- Appsignal::Hooks::Helpers.string_or_inspect(string_or_other)
67
- end
68
-
69
- def truncate(text)
70
- Appsignal::Hooks::Helpers.truncate(text)
71
- end
72
-
73
- def self.string_or_inspect(string_or_other)
74
- if string_or_other.is_a?(String)
75
- string_or_other
76
- else
77
- string_or_other.inspect
78
- end
79
- end
80
-
81
- def self.truncate(text)
82
- text.size > 200 ? "#{text[0...197]}..." : text
83
- end
84
- end
85
-
86
48
  end
87
49
  end
88
50
 
@@ -1,8 +1,6 @@
1
1
  module Appsignal
2
2
  class Hooks
3
3
  class SidekiqPlugin
4
- include Appsignal::Hooks::Helpers
5
-
6
4
  def job_keys
7
5
  @job_keys ||= Set.new(%w(
8
6
  class args retried_at failed_at
@@ -32,11 +30,23 @@ module Appsignal
32
30
  end
33
31
  end
34
32
 
33
+ def string_or_inspect(string_or_other)
34
+ if string_or_other.is_a?(String)
35
+ string_or_other
36
+ else
37
+ string_or_other.inspect
38
+ end
39
+ end
40
+
35
41
  def format_args(args)
36
42
  args.map do |arg|
37
43
  truncate(string_or_inspect(arg))
38
44
  end
39
45
  end
46
+
47
+ def truncate(text)
48
+ text.size > 200 ? "#{text[0...197]}..." : text
49
+ end
40
50
  end
41
51
 
42
52
  class SidekiqHook < Appsignal::Hooks::Hook
@@ -1,8 +1,6 @@
1
1
  module Appsignal
2
2
  class Hooks
3
3
  class DelayedJobPlugin < ::Delayed::Plugin
4
- include Appsignal::Hooks::Helpers
5
-
6
4
  callbacks do |lifecycle|
7
5
  lifecycle.around(:invoke_job) do |job, &block|
8
6
  invoke_with_instrumentation(job, block)
@@ -31,18 +29,11 @@ module Appsignal
31
29
  :priority => job.priority || 0,
32
30
  :attempts => job.attempts || 0
33
31
  },
34
- :params => format_args(job.payload_object.args),
35
32
  :queue_start => job.created_at
36
33
  ) do
37
34
  block.call(job)
38
35
  end
39
36
  end
40
-
41
- def self.format_args(args)
42
- args.map do |arg|
43
- self.truncate(self.string_or_inspect(arg))
44
- end
45
- end
46
37
  end
47
38
  end
48
39
  end
@@ -1,5 +1,5 @@
1
1
  require 'yaml'
2
2
 
3
3
  module Appsignal
4
- VERSION = '0.12.rc.13'
4
+ VERSION = '0.12.rc.14'
5
5
  end
@@ -201,4 +201,12 @@ describe Appsignal::Config do
201
201
  its([:ignore_actions]) { should == ['action1', 'action2'] }
202
202
  end
203
203
  end
204
+
205
+ context "when a nil root path is passed" do
206
+ let(:initial_config) { {} }
207
+ let(:config) { Appsignal::Config.new(nil, 'production', initial_config) }
208
+
209
+ its(:valid?) { should be_false }
210
+ its(:active?) { should be_false }
211
+ end
204
212
  end
@@ -36,7 +36,7 @@ describe Appsignal::Hooks::DelayedJobHook do
36
36
  :attempts => 1,
37
37
  :queue => 'default',
38
38
  :created_at => time - 60_000,
39
- :payload_object => double(:args => ['argument']),
39
+ :payload_object => double
40
40
  )
41
41
  end
42
42
  let(:invoked_block) { Proc.new { } }
@@ -54,7 +54,6 @@ describe Appsignal::Hooks::DelayedJobHook do
54
54
  :queue => 'default',
55
55
  :id => 123
56
56
  },
57
- :params => ['argument'],
58
57
  :queue_start => time - 60_000,
59
58
  )
60
59
 
@@ -67,15 +66,14 @@ describe Appsignal::Hooks::DelayedJobHook do
67
66
  let(:job) do
68
67
  double(
69
68
  :payload_object => double(
70
- :appsignal_name => 'CustomClass#perform',
71
- :args => ['argument']
69
+ :appsignal_name => 'CustomClass#perform'
72
70
  ),
73
- :id => 123,
74
- :name => 'TestClass#perform',
75
- :priority => 1,
76
- :attempts => 1,
77
- :queue => 'default',
78
- :created_at => time - 60_000
71
+ :id => 123,
72
+ :name => 'TestClass#perform',
73
+ :priority => 1,
74
+ :attempts => 1,
75
+ :queue => 'default',
76
+ :created_at => time - 60_000
79
77
  )
80
78
  end
81
79
  it "should wrap in a transaction with the correct params" do
@@ -89,7 +87,6 @@ describe Appsignal::Hooks::DelayedJobHook do
89
87
  :queue => 'default',
90
88
  :id => 123
91
89
  },
92
- :params => ['argument'],
93
90
  :queue_start => time - 60_000
94
91
  )
95
92
 
@@ -107,6 +107,38 @@ describe Appsignal::Hooks::SidekiqPlugin do
107
107
  plugin.format_args(args).should == ['Model', '1', object.inspect]
108
108
  end
109
109
  end
110
+
111
+ describe "#truncate" do
112
+ let(:very_long_text) do
113
+ "a" * 400
114
+ end
115
+
116
+ it "should truncate the text to 200 chars max" do
117
+ plugin.truncate(very_long_text).should == "#{'a' * 197}..."
118
+ end
119
+ end
120
+
121
+ describe "#string_or_inspect" do
122
+ context "when string" do
123
+ it "should return the string" do
124
+ plugin.string_or_inspect('foo').should == 'foo'
125
+ end
126
+ end
127
+
128
+ context "when integer" do
129
+ it "should return the string" do
130
+ plugin.string_or_inspect(1).should == '1'
131
+ end
132
+ end
133
+
134
+ context "when object" do
135
+ let(:object) { Object.new }
136
+
137
+ it "should return the string" do
138
+ plugin.string_or_inspect(object).should == object.inspect
139
+ end
140
+ end
141
+ end
110
142
  end
111
143
 
112
144
  describe Appsignal::Hooks::SidekiqHook do
@@ -74,79 +74,3 @@ describe Appsignal::Hooks do
74
74
  Appsignal::Hooks.hooks[:mock_error_hook].installed?.should be_false
75
75
  end
76
76
  end
77
-
78
- describe Appsignal::Hooks::Helpers do
79
- class ClassWithHelpers
80
- include Appsignal::Hooks::Helpers
81
- end
82
-
83
- let(:class_with_helpers) { ClassWithHelpers.new }
84
-
85
- describe "#truncate" do
86
- it "should call the class method helper" do
87
- expect( Appsignal::Hooks::Helpers ).to receive(:truncate).with('text')
88
-
89
- class_with_helpers.truncate('text')
90
- end
91
- end
92
-
93
- describe "#string_or_inspect" do
94
- it "should call the class method helper" do
95
- expect( Appsignal::Hooks::Helpers ).to receive(:string_or_inspect)
96
- .with('string')
97
-
98
- class_with_helpers.string_or_inspect('string')
99
- end
100
- end
101
-
102
- describe Appsignal::Hooks::Helpers::ClassMethods do
103
- describe "#truncate" do
104
- it "should call the class method helper" do
105
- expect( Appsignal::Hooks::Helpers ).to receive(:truncate).with('text')
106
-
107
- ClassWithHelpers.truncate('text')
108
- end
109
- end
110
-
111
- describe "#string_or_inspect" do
112
- it "should call the class method helper" do
113
- expect( Appsignal::Hooks::Helpers ).to receive(:string_or_inspect)
114
- .with('string')
115
-
116
- ClassWithHelpers.string_or_inspect('string')
117
- end
118
- end
119
- end
120
-
121
- describe ".truncate" do
122
- let(:very_long_text) do
123
- "a" * 400
124
- end
125
-
126
- it "should truncate the text to 200 chars max" do
127
- Appsignal::Hooks::Helpers.truncate(very_long_text).should == "#{'a' * 197}..."
128
- end
129
- end
130
-
131
- describe ".string_or_inspect" do
132
- context "when string" do
133
- it "should return the string" do
134
- Appsignal::Hooks::Helpers.string_or_inspect('foo').should == 'foo'
135
- end
136
- end
137
-
138
- context "when integer" do
139
- it "should return the string" do
140
- Appsignal::Hooks::Helpers.string_or_inspect(1).should == '1'
141
- end
142
- end
143
-
144
- context "when object" do
145
- let(:object) { Object.new }
146
-
147
- it "should return the string" do
148
- Appsignal::Hooks::Helpers.string_or_inspect(object).should == object.inspect
149
- end
150
- end
151
- end
152
- 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: 0.12.rc.13
4
+ version: 0.12.rc.14
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: 2015-12-30 00:00:00.000000000 Z
12
+ date: 2016-01-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack