appsignal 2.9.4 → 2.9.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dc53bd1f7e43b84ca6dcdf5d53ff74ba0cd1d192e3ffc73e3ee1ea084af7bab
4
- data.tar.gz: 01144a912c4d90661741faf032456b2fd7d8eee48eafb8a019183f0871d94d28
3
+ metadata.gz: 5f7674897cc830c3cf14180a7dfd1caf9aff2a9c3e0f456307f351e45db82204
4
+ data.tar.gz: fb3f59242548e38bf840912624fd9c90bf62515854ac4cacbc13a522dfcb41ae
5
5
  SHA512:
6
- metadata.gz: a3acbb9a3fa50d0f7028efe4b272b9ed6d3c574cd3655abf400e35f21139804018f07c411c27be3b79001ba4495989880ab40e54c7772aae8095cd45b0eb8b55
7
- data.tar.gz: 0b78b8193b152bc0508bd359008ee5e0657b119ded48df92351d508e67807e66698b9147a483d1c2e5da6b3f5137f23a472af7b6f795461d0effaa3eb97005a3
6
+ metadata.gz: 36fe1323ed38f8623266e53d414e1e0d74a8148c6b8ebb4718a3b73a56aa41157ae082c85c3ff669d44ab3f1c22927f20b6cb2e23a6d9a46b952f1a2f991b7c9
7
+ data.tar.gz: c35d2fe3f0067f165627cbcb1d2ed40f50dfa723014e0a6268c9d2b7ef6ed8854cd0e0c0d1573ebe5b36e8f676881d07d34715db485cf422e430833bc0c9ec09
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.9.5
4
+ - Delay the first minutely probe for a bit, since it might take some
5
+ time for dependencies to initialize. PR #511
6
+
3
7
  ## 2.9.4
4
8
  - Log error backtraces in minutely probes as debug messages. PR #495
5
9
  - Don't add cluster behavior in Puma single mode. PR #504
@@ -33,6 +37,14 @@
33
37
  - Move instrumentation & metrics helpers to modules. PR #487
34
38
  - Add Puma minutely probe. PR #488
35
39
  - Log invalid EventFormatter registrations as errors. PR #491
40
+ - Support container CPU host metrics.
41
+ Commit f2fca1ec5a850cd84fbc8cefe63af8f039ebb155
42
+ - Support StatsD server in agent.
43
+ Commit f2fca1ec5a850cd84fbc8cefe63af8f039ebb155
44
+ - Fix samples being reported for multiple namespaces.
45
+ Commit f2fca1ec5a850cd84fbc8cefe63af8f039ebb155
46
+ - Report memory and swap usage in percent using the memory_usage and
47
+ swap_usage metrics. Commit f2fca1ec5a850cd84fbc8cefe63af8f039ebb155
36
48
 
37
49
  ## 2.8.4
38
50
  - Log memory usage of agent if high.
@@ -10,8 +10,8 @@ require File.expand_path("../../lib/appsignal/system.rb", __FILE__)
10
10
  EXT_PATH = File.expand_path("..", __FILE__).freeze
11
11
  AGENT_CONFIG = YAML.load(File.read(File.join(EXT_PATH, "agent.yml"))).freeze
12
12
 
13
- PLATFORM = Appsignal::System.agent_platform
14
- ARCH = "#{RbConfig::CONFIG["host_cpu"]}-#{PLATFORM}".freeze
13
+ AGENT_PLATFORM = Appsignal::System.agent_platform
14
+ ARCH = "#{RbConfig::CONFIG["host_cpu"]}-#{AGENT_PLATFORM}".freeze
15
15
  CA_CERT_PATH = File.join(EXT_PATH, "../resources/cacert.pem").freeze
16
16
 
17
17
  def ext_path(path)
@@ -37,7 +37,7 @@ def report
37
37
  "time" => Time.now.utc,
38
38
  "package_path" => File.dirname(__dir__),
39
39
  "architecture" => rbconfig["host_cpu"],
40
- "target" => PLATFORM,
40
+ "target" => AGENT_PLATFORM,
41
41
  "musl_override" => Appsignal::System.force_musl_build?,
42
42
  "dependencies" => {},
43
43
  "flags" => {}
@@ -25,7 +25,7 @@ def install
25
25
  is_linux_system = [
26
26
  Appsignal::System::LINUX_TARGET,
27
27
  Appsignal::System::MUSL_TARGET
28
- ].include?(PLATFORM)
28
+ ].include?(AGENT_PLATFORM)
29
29
 
30
30
  require "mkmf"
31
31
  link_libraries if is_linux_system
@@ -28,6 +28,8 @@ module Appsignal
28
28
  def initialize(config = {})
29
29
  @config = config
30
30
  @cache = {}
31
+ config_string = " with config: #{config}" unless config.empty?
32
+ Appsignal.logger.debug("Initializing Sidekiq probe#{config_string}")
31
33
  require "sidekiq/api"
32
34
  end
33
35
 
@@ -87,11 +89,15 @@ module Appsignal
87
89
  return @hostname if defined?(@hostname)
88
90
  if config.key?(:hostname)
89
91
  @hostname = config[:hostname]
92
+ Appsignal.logger.debug "Sidekiq probe: Using hostname config " \
93
+ "option #{@hostname.inspect} as hostname"
90
94
  return @hostname
91
95
  end
92
96
 
93
97
  host = nil
94
98
  ::Sidekiq.redis { |c| host = c.connection[:host] }
99
+ Appsignal.logger.debug "Sidekiq probe: Using Redis server hostname " \
100
+ "#{host.inspect} as hostname"
95
101
  @hostname = host
96
102
  end
97
103
  end
@@ -137,6 +137,7 @@ module Appsignal
137
137
  stop
138
138
  initialize_probes
139
139
  @@thread = Thread.new do
140
+ sleep initial_wait_time
140
141
  loop do
141
142
  logger = Appsignal.logger
142
143
  logger.debug("Gathering minutely metrics with #{probes.count} probes")
@@ -149,7 +150,7 @@ module Appsignal
149
150
  logger.debug ex.backtrace.join("\n")
150
151
  end
151
152
  end
152
- sleep(Appsignal::Minutely.wait_time)
153
+ sleep wait_time
153
154
  end
154
155
  end
155
156
  end
@@ -167,6 +168,12 @@ module Appsignal
167
168
 
168
169
  private
169
170
 
171
+ def initial_wait_time
172
+ remaining_seconds = 60 - Time.now.sec
173
+ return remaining_seconds if remaining_seconds > 30
174
+ remaining_seconds + 60
175
+ end
176
+
170
177
  def initialize_probes
171
178
  probes.each do |name, probe|
172
179
  instance = probe.respond_to?(:new) ? probe.new : probe
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "2.9.4".freeze
4
+ VERSION = "2.9.5".freeze
5
5
  end
@@ -202,14 +202,16 @@ describe Appsignal::Config do
202
202
  context "with a config file" do
203
203
  let(:config) { project_fixture_config("production") }
204
204
 
205
- it "is not valid or active" do
206
- expect(config.valid?).to be_truthy
207
- expect(config.active?).to be_truthy
208
- end
205
+ context "with valid config" do
206
+ it "is valid and active" do
207
+ expect(config.valid?).to be_truthy
208
+ expect(config.active?).to be_truthy
209
+ end
209
210
 
210
- it "does not log an error" do
211
- expect_any_instance_of(Logger).to_not receive(:error)
212
- config
211
+ it "does not log an error" do
212
+ log = capture_logs { config }
213
+ expect(log).to_not contains_log(:error)
214
+ end
213
215
  end
214
216
 
215
217
  it "sets the file_config" do
@@ -671,6 +671,22 @@ describe Appsignal::Hooks::SidekiqProbe do
671
671
  expect(defined?(Sidekiq::API)).to be_truthy
672
672
  end
673
673
 
674
+ it "logs config on initialize" do
675
+ log = capture_logs { probe }
676
+ expect(log).to contains_log(:debug, "Initializing Sidekiq probe\n")
677
+ end
678
+
679
+ it "logs used hostname on call once" do
680
+ log = capture_logs { probe.call }
681
+ expect(log).to contains_log(
682
+ :debug,
683
+ %(Sidekiq probe: Using Redis server hostname "localhost" as hostname)
684
+ )
685
+ log = capture_logs { probe.call }
686
+ # Match more logs with incompelete message
687
+ expect(log).to_not contains_log(:debug, %(Sidekiq probe: ))
688
+ end
689
+
674
690
  it "collects custom metrics" do
675
691
  expect_gauge("worker_count", 24).twice
676
692
  expect_gauge("process_count", 25).twice
@@ -698,7 +714,16 @@ describe Appsignal::Hooks::SidekiqProbe do
698
714
 
699
715
  it "uses the redis hostname for the hostname tag" do
700
716
  allow(Appsignal).to receive(:set_gauge).and_call_original
701
- probe.call
717
+ log = capture_logs { probe }
718
+ expect(log).to contains_log(
719
+ :debug,
720
+ %(Initializing Sidekiq probe with config: {:hostname=>"#{redis_hostname}"})
721
+ )
722
+ log = capture_logs { probe.call }
723
+ expect(log).to contains_log(
724
+ :debug,
725
+ "Sidekiq probe: Using hostname config option #{redis_hostname.inspect} as hostname"
726
+ )
702
727
  expect(Appsignal).to have_received(:set_gauge)
703
728
  .with(anything, anything, :hostname => redis_hostname).at_least(:once)
704
729
  end
@@ -31,7 +31,14 @@ describe Appsignal::Minutely do
31
31
  before do
32
32
  Appsignal.logger = test_logger(log_stream)
33
33
  # Speed up test time
34
- allow(Appsignal::Minutely).to receive(:wait_time).and_return(0.001)
34
+ expect(Appsignal::Minutely).to receive(:initial_wait_time)
35
+ .ordered
36
+ .once
37
+ .and_return(0.001)
38
+ expect(Appsignal::Minutely).to receive(:wait_time)
39
+ .ordered
40
+ .at_least(:once)
41
+ .and_return(0.001)
35
42
  end
36
43
 
37
44
  context "with an instance of a class" do
@@ -94,6 +101,9 @@ describe Appsignal::Minutely do
94
101
  end
95
102
 
96
103
  it "ensures only one minutely probes thread is active at a time" do
104
+ # Starting twice in this spec, so expecting it more than once
105
+ expect(Appsignal::Minutely).to receive(:initial_wait_time).at_least(:once).and_return(0.001)
106
+
97
107
  alive_thread_counter = proc { Thread.list.reject { |t| t.status == "dead" }.length }
98
108
  probe = Probe.new
99
109
  Appsignal::Minutely.probes.register :my_probe, probe
@@ -141,6 +151,10 @@ describe Appsignal::Minutely do
141
151
  end
142
152
 
143
153
  describe ".stop" do
154
+ before do
155
+ allow(Appsignal::Minutely).to receive(:initial_wait_time).and_return(0.001)
156
+ end
157
+
144
158
  it "stops the minutely thread" do
145
159
  Appsignal::Minutely.start
146
160
  thread = Appsignal::Minutely.class_variable_get(:@@thread)
@@ -163,8 +177,30 @@ describe Appsignal::Minutely do
163
177
 
164
178
  describe ".wait_time" do
165
179
  it "gets the time to the next minute" do
166
- allow_any_instance_of(Time).to receive(:sec).and_return(20)
167
- expect(Appsignal::Minutely.wait_time).to eq 40
180
+ time = Time.new(2019, 4, 9, 12, 0, 20)
181
+ Timecop.freeze time do
182
+ expect(Appsignal::Minutely.wait_time).to eq 40
183
+ end
184
+ end
185
+ end
186
+
187
+ describe ".initial_wait_time" do
188
+ context "when started in the last 30 seconds of a minute" do
189
+ it "waits for the number of seconds + 60" do
190
+ time = Time.new(2019, 4, 9, 12, 0, 31)
191
+ Timecop.freeze time do
192
+ expect(Appsignal::Minutely.send(:initial_wait_time)).to eql(29 + 60)
193
+ end
194
+ end
195
+ end
196
+
197
+ context "when started in the first 30 seconds of a minute" do
198
+ it "waits the remaining seconds in the minute" do
199
+ time = Time.new(2019, 4, 9, 12, 0, 29)
200
+ Timecop.freeze time do
201
+ expect(Appsignal::Minutely.send(:initial_wait_time)).to eql(31)
202
+ end
203
+ end
168
204
  end
169
205
  end
170
206
 
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.9.4
4
+ version: 2.9.5
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: 2019-04-02 00:00:00.000000000 Z
12
+ date: 2019-04-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -379,7 +379,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
379
379
  - !ruby/object:Gem::Version
380
380
  version: '0'
381
381
  requirements: []
382
- rubygems_version: 3.0.2
382
+ rubyforge_project:
383
+ rubygems_version: 2.7.6
383
384
  signing_key:
384
385
  specification_version: 4
385
386
  summary: Logs performance and exception data from your app to appsignal.com