appsignal 3.1.0-java → 3.1.1-java

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: c5b5a232369f0d030bf17e1397dc12e7f5b9cce53b2469468a65cde362ef7903
4
- data.tar.gz: eb490806ae18a93d7ec24eb071c63b22c1f599b62fbd82e5a47d0f00ebeee50c
3
+ metadata.gz: be534a2bce153240d9a00c15ee4f177cec58a0a40df738ddd66e7afba50a1d0c
4
+ data.tar.gz: 0d9c3820cfe794ccabbcc1cda65fafec925cda36690b4caa179170e07a38a25c
5
5
  SHA512:
6
- metadata.gz: a3f0c5ed5ab18b10c70145c748b674c33b0e70ec67715b800f05da4b2f829268ef1d7d9aa3173afa55927c746d11cebc6bd2571438ead0074a141b0fa168b32a
7
- data.tar.gz: 130d790bd57b4e39ee9011e56a11c60ff72dda6e266aa7335ceea0f63e1e41093c815a9c4286c5db2129198acf169c9d65a6b025eb15e4b930ac905e62439d8c
6
+ metadata.gz: 4dd0efe8930f19068dbf54ab0709f3bed422ac67bd2974b348f5d6eddcb054da09df59fb992a41802ddb0e7ed0de986a6b67f484779409d7b227c32451f3b6f0
7
+ data.tar.gz: 0167fd0f1bfa054e46f20ab12680529913da7b5b702fc119cbdb43e78e2e8cf3f459e7b4236413f394e51a0ed935e597806b8836b20d702ede7d0f26780f2590
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 3.1.1
4
+
5
+ ### Changed
6
+
7
+ - [e225c798](https://github.com/appsignal/appsignal-ruby/commit/e225c798c65aef6085bb689597b7f3359fe138f7) patch - Report all Ruby VM metrics as gauges. We previously reported some metrics as distributions, but all fields for those distributions would report the same values.
8
+
9
+ ### Fixed
10
+
11
+ - [31fd19c6](https://github.com/appsignal/appsignal-ruby/commit/31fd19c6019db2c68b359f1fc4ed3d5e4843e349) patch - Add hostname tag for Ruby VM metrics. This allows us to graph every host separately and multiple hosts won't overwrite each other metrics.
12
+
3
13
  ## 3.1.0
4
14
 
5
15
  ### Added
@@ -21,20 +21,20 @@ module Appsignal
21
21
  def call
22
22
  stat = RubyVM.stat
23
23
 
24
- @appsignal.add_distribution_value(
24
+ set_gauge(
25
25
  "ruby_vm",
26
26
  stat[:class_serial],
27
27
  :metric => :class_serial
28
28
  )
29
29
 
30
- @appsignal.add_distribution_value(
30
+ set_gauge(
31
31
  "ruby_vm",
32
32
  stat[:constant_cache] ? stat[:constant_cache].values.sum : stat[:global_constant_state],
33
33
  :metric => :global_constant_state
34
34
  )
35
35
 
36
- @appsignal.set_gauge("thread_count", Thread.list.size)
37
- @appsignal.set_gauge("gc_total_time", MriProbe.garbage_collection_profiler.total_time)
36
+ set_gauge("thread_count", Thread.list.size)
37
+ set_gauge("gc_total_time", MriProbe.garbage_collection_profiler.total_time)
38
38
 
39
39
  gc_stats = GC.stat
40
40
  allocated_objects =
@@ -42,25 +42,44 @@ module Appsignal
42
42
  :allocated_objects,
43
43
  gc_stats[:total_allocated_objects] || gc_stats[:total_allocated_object]
44
44
  )
45
- if allocated_objects
46
- @appsignal.set_gauge("allocated_objects", allocated_objects)
47
- end
45
+ set_gauge("allocated_objects", allocated_objects) if allocated_objects
48
46
 
49
47
  gc_count = gauge_delta(:gc_count, GC.count)
50
- if gc_count
51
- @appsignal.add_distribution_value("gc_count", gc_count, :metric => :gc_count)
52
- end
48
+ set_gauge("gc_count", gc_count, :metric => :gc_count) if gc_count
53
49
  minor_gc_count = gauge_delta(:minor_gc_count, gc_stats[:minor_gc_count])
54
50
  if minor_gc_count
55
- @appsignal.add_distribution_value("gc_count", minor_gc_count, :metric => :minor_gc_count)
51
+ set_gauge("gc_count", minor_gc_count, :metric => :minor_gc_count)
56
52
  end
57
53
  major_gc_count = gauge_delta(:major_gc_count, gc_stats[:major_gc_count])
58
54
  if major_gc_count
59
- @appsignal.add_distribution_value("gc_count", major_gc_count, :metric => :major_gc_count)
55
+ set_gauge("gc_count", major_gc_count, :metric => :major_gc_count)
60
56
  end
61
57
 
62
- @appsignal.add_distribution_value("heap_slots", gc_stats[:heap_live_slots] || gc_stats[:heap_live_slot], :metric => :heap_live)
63
- @appsignal.add_distribution_value("heap_slots", gc_stats[:heap_free_slots] || gc_stats[:heap_free_slot], :metric => :heap_free)
58
+ set_gauge("heap_slots", gc_stats[:heap_live_slots] || gc_stats[:heap_live_slot], :metric => :heap_live)
59
+ set_gauge("heap_slots", gc_stats[:heap_free_slots] || gc_stats[:heap_free_slot], :metric => :heap_free)
60
+ end
61
+
62
+ private
63
+
64
+ def set_gauge(metric, value, tags = {})
65
+ @appsignal.set_gauge(metric, value, { :hostname => hostname }.merge(tags))
66
+ end
67
+
68
+ def hostname
69
+ return @hostname if defined?(@hostname)
70
+
71
+ config = @appsignal.config
72
+ @hostname =
73
+ if config[:hostname]
74
+ config[:hostname]
75
+ else
76
+ # Auto detect hostname as fallback. May be inaccurate.
77
+ Socket.gethostname
78
+ end
79
+ Appsignal.logger.debug "MRI probe: Using hostname config " \
80
+ "option '#{@hostname.inspect}' as hostname"
81
+
82
+ @hostname
64
83
  end
65
84
  end
66
85
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "3.1.0".freeze
4
+ VERSION = "3.1.1".freeze
5
5
  end
@@ -1,13 +1,15 @@
1
1
  class AppsignalMock
2
- attr_reader :distribution_values, :gauges
2
+ attr_reader :gauges
3
3
 
4
- def initialize
5
- @distribution_values = []
4
+ def initialize(hostname: nil)
5
+ @hostname = hostname
6
6
  @gauges = []
7
7
  end
8
8
 
9
- def add_distribution_value(*args)
10
- @distribution_values << args
9
+ def config
10
+ ConfigHelpers.project_fixture_config.tap do |conf|
11
+ conf[:hostname] = @hostname if @hostname
12
+ end
11
13
  end
12
14
 
13
15
  def set_gauge(*args) # rubocop:disable Naming/AccessorMethodName
@@ -16,7 +18,7 @@ class AppsignalMock
16
18
  end
17
19
 
18
20
  describe Appsignal::Probes::MriProbe do
19
- let(:appsignal_mock) { AppsignalMock.new }
21
+ let(:appsignal_mock) { AppsignalMock.new(:hostname => hostname) }
20
22
  let(:probe) { described_class.new(appsignal_mock) }
21
23
 
22
24
  describe ".dependencies_present?" do
@@ -33,10 +35,12 @@ describe Appsignal::Probes::MriProbe do
33
35
 
34
36
  unless DependencyHelper.running_jruby? || DependencyHelper.running_ruby_2_0?
35
37
  describe "#call" do
38
+ let(:hostname) { nil }
39
+
36
40
  it "should track vm metrics" do
37
41
  probe.call
38
- expect_distribution_value("ruby_vm", :class_serial)
39
- expect_distribution_value("ruby_vm", :global_constant_state)
42
+ expect_gauge_value("ruby_vm", :tags => { :metric => :class_serial })
43
+ expect_gauge_value("ruby_vm", :tags => { :metric => :global_constant_state })
40
44
  end
41
45
 
42
46
  it "tracks thread counts" do
@@ -57,9 +61,9 @@ describe Appsignal::Probes::MriProbe do
57
61
  )
58
62
  probe.call
59
63
  probe.call
60
- expect_distribution_value("gc_count", :gc_count, 5)
61
- expect_distribution_value("gc_count", :minor_gc_count, 6)
62
- expect_distribution_value("gc_count", :major_gc_count, 7)
64
+ expect_gauge_value("gc_count", 5, :tags => { :metric => :gc_count })
65
+ expect_gauge_value("gc_count", 6, :tags => { :metric => :minor_gc_count })
66
+ expect_gauge_value("gc_count", 7, :tags => { :metric => :major_gc_count })
63
67
  end
64
68
 
65
69
  it "tracks object allocation" do
@@ -75,29 +79,31 @@ describe Appsignal::Probes::MriProbe do
75
79
 
76
80
  it "tracks heap slots" do
77
81
  probe.call
78
- expect_distribution_value("heap_slots", :heap_live)
79
- expect_distribution_value("heap_slots", :heap_free)
82
+ expect_gauge_value("heap_slots", :tags => { :metric => :heap_live })
83
+ expect_gauge_value("heap_slots", :tags => { :metric => :heap_free })
80
84
  end
81
- end
82
- end
83
85
 
84
- def expect_distribution_value(expected_key, metric, expected_value = nil)
85
- expect(appsignal_mock.distribution_values).to satisfy do |distribution_values|
86
- distribution_values.any? do |distribution_value|
87
- key, value, metadata = distribution_value
88
- next unless key == expected_key
89
- next unless expected_value ? expected_value == value : !value.nil?
90
- next unless metadata == { :metric => metric }
86
+ context "with custom hostname" do
87
+ let(:hostname) { "my hostname" }
91
88
 
92
- true
89
+ it "reports custom hostname tag value" do
90
+ probe.call
91
+ expect_gauge_value("heap_slots", :tags => { :metric => :heap_live, :hostname => hostname })
92
+ end
93
93
  end
94
94
  end
95
95
  end
96
96
 
97
- def expect_gauge_value(expected_key, expected_value = nil)
97
+ def expect_gauge_value(expected_key, expected_value = nil, tags: {})
98
+ expected_tags = { :hostname => Socket.gethostname }.merge(tags)
98
99
  expect(appsignal_mock.gauges).to satisfy do |gauges|
99
- gauges.any? do |(key, value)|
100
- expected_key == key && expected_value ? expected_value == value : !value.nil?
100
+ gauges.any? do |distribution_value|
101
+ key, value, tags = distribution_value
102
+ next unless key == expected_key
103
+ next unless expected_value ? expected_value == value : !value.nil?
104
+ next unless tags == expected_tags
105
+
106
+ true
101
107
  end
102
108
  end
103
109
  end
@@ -14,6 +14,7 @@ module ConfigHelpers
14
14
  config_file
15
15
  )
16
16
  end
17
+ module_function :project_fixture_config, :project_fixture_path
17
18
 
18
19
  def start_agent(env = "production")
19
20
  Appsignal.config = project_fixture_config(env)
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: 3.1.0
4
+ version: 3.1.1
5
5
  platform: java
6
6
  authors:
7
7
  - Robert Beekman