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 +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/appsignal/probes/mri.rb +33 -14
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/probes/mri_spec.rb +32 -26
- data/spec/support/helpers/config_helpers.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be534a2bce153240d9a00c15ee4f177cec58a0a40df738ddd66e7afba50a1d0c
|
4
|
+
data.tar.gz: 0d9c3820cfe794ccabbcc1cda65fafec925cda36690b4caa179170e07a38a25c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/appsignal/probes/mri.rb
CHANGED
@@ -21,20 +21,20 @@ module Appsignal
|
|
21
21
|
def call
|
22
22
|
stat = RubyVM.stat
|
23
23
|
|
24
|
-
|
24
|
+
set_gauge(
|
25
25
|
"ruby_vm",
|
26
26
|
stat[:class_serial],
|
27
27
|
:metric => :class_serial
|
28
28
|
)
|
29
29
|
|
30
|
-
|
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
|
-
|
37
|
-
|
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
|
-
|
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
|
-
|
55
|
+
set_gauge("gc_count", major_gc_count, :metric => :major_gc_count)
|
60
56
|
end
|
61
57
|
|
62
|
-
|
63
|
-
|
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
|
data/lib/appsignal/version.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
class AppsignalMock
|
2
|
-
attr_reader :
|
2
|
+
attr_reader :gauges
|
3
3
|
|
4
|
-
def initialize
|
5
|
-
@
|
4
|
+
def initialize(hostname: nil)
|
5
|
+
@hostname = hostname
|
6
6
|
@gauges = []
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
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
|
-
|
39
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
79
|
-
|
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
|
-
|
85
|
-
|
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
|
-
|
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 |
|
100
|
-
|
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
|