appsignal 3.4.13 → 3.6.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 +4 -4
- data/.semaphore/semaphore.yml +180 -14
- data/CHANGELOG.md +164 -0
- data/README.md +2 -0
- data/Rakefile +3 -1
- data/build_matrix.yml +7 -13
- data/ext/Rakefile +8 -1
- data/ext/agent.rb +27 -27
- data/ext/appsignal_extension.c +0 -24
- data/ext/base.rb +4 -1
- data/gemfiles/redis-4.gemfile +5 -0
- data/gemfiles/redis-5.gemfile +6 -0
- data/lib/appsignal/cli/diagnose/paths.rb +33 -10
- data/lib/appsignal/cli/diagnose.rb +6 -1
- data/lib/appsignal/config.rb +19 -5
- data/lib/appsignal/demo.rb +1 -1
- data/lib/appsignal/environment.rb +24 -13
- data/lib/appsignal/event_formatter.rb +1 -1
- data/lib/appsignal/extension/jruby.rb +4 -17
- data/lib/appsignal/extension.rb +1 -1
- data/lib/appsignal/helpers/instrumentation.rb +10 -10
- data/lib/appsignal/helpers/metrics.rb +15 -13
- data/lib/appsignal/hooks/active_job.rb +9 -1
- data/lib/appsignal/hooks/redis.rb +1 -0
- data/lib/appsignal/hooks/redis_client.rb +27 -0
- data/lib/appsignal/hooks.rb +3 -2
- data/lib/appsignal/integrations/hanami.rb +1 -1
- data/lib/appsignal/integrations/padrino.rb +1 -1
- data/lib/appsignal/integrations/railtie.rb +1 -1
- data/lib/appsignal/integrations/redis_client.rb +20 -0
- data/lib/appsignal/integrations/sidekiq.rb +2 -2
- data/lib/appsignal/integrations/sinatra.rb +1 -1
- data/lib/appsignal/logger.rb +2 -0
- data/lib/appsignal/minutely.rb +4 -4
- data/lib/appsignal/probes/gvl.rb +1 -1
- data/lib/appsignal/probes/helpers.rb +1 -1
- data/lib/appsignal/probes/mri.rb +1 -1
- data/lib/appsignal/probes/sidekiq.rb +10 -8
- data/lib/appsignal/rack/body_wrapper.rb +161 -0
- data/lib/appsignal/rack/generic_instrumentation.rb +18 -5
- data/lib/appsignal/rack/rails_instrumentation.rb +17 -5
- data/lib/appsignal/rack/sinatra_instrumentation.rb +17 -5
- data/lib/appsignal/rack/streaming_listener.rb +27 -36
- data/lib/appsignal/span.rb +2 -2
- data/lib/appsignal/transaction.rb +46 -10
- data/lib/appsignal/utils/deprecation_message.rb +2 -2
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +38 -31
- data/resources/cacert.pem +321 -159
- data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +11 -0
- data/spec/lib/appsignal/cli/diagnose_spec.rb +38 -12
- data/spec/lib/appsignal/config_spec.rb +3 -2
- data/spec/lib/appsignal/hooks/activejob_spec.rb +26 -1
- data/spec/lib/appsignal/hooks/redis_client_spec.rb +222 -0
- data/spec/lib/appsignal/hooks/redis_spec.rb +98 -76
- data/spec/lib/appsignal/hooks_spec.rb +4 -4
- data/spec/lib/appsignal/integrations/railtie_spec.rb +2 -2
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +3 -3
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +2 -2
- data/spec/lib/appsignal/minutely_spec.rb +2 -2
- data/spec/lib/appsignal/probes/sidekiq_spec.rb +29 -6
- data/spec/lib/appsignal/rack/body_wrapper_spec.rb +220 -0
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +3 -2
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +5 -3
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +3 -1
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +9 -53
- data/spec/lib/appsignal/transaction_spec.rb +95 -2
- data/spec/lib/appsignal_spec.rb +62 -60
- data/spec/spec_helper.rb +1 -1
- data/spec/support/fixtures/projects/valid/config/appsignal.yml +3 -3
- data/spec/support/helpers/config_helpers.rb +6 -2
- data/spec/support/helpers/dependency_helper.rb +9 -1
- data/spec/support/helpers/log_helpers.rb +2 -2
- metadata +9 -2
data/ext/agent.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Modifications to this file will be overwritten with the next agent release.
|
7
7
|
|
8
8
|
APPSIGNAL_AGENT_CONFIG = {
|
9
|
-
"version" => "
|
9
|
+
"version" => "0.33.2",
|
10
10
|
"mirrors" => [
|
11
11
|
"https://appsignal-agent-releases.global.ssl.fastly.net",
|
12
12
|
"https://d135dj0rjqvssy.cloudfront.net"
|
@@ -14,131 +14,131 @@ APPSIGNAL_AGENT_CONFIG = {
|
|
14
14
|
"triples" => {
|
15
15
|
"x86_64-darwin" => {
|
16
16
|
"static" => {
|
17
|
-
"checksum" => "
|
17
|
+
"checksum" => "0864691f001133fa479b34b00a682e76f374c40c161e7715756a3c036e3c8798",
|
18
18
|
"filename" => "appsignal-x86_64-darwin-all-static.tar.gz"
|
19
19
|
},
|
20
20
|
"dynamic" => {
|
21
|
-
"checksum" => "
|
21
|
+
"checksum" => "5141528c4293e4bd619107ae79afc8e07fdc8b33835899c5cf3f82ab3d31de8f",
|
22
22
|
"filename" => "appsignal-x86_64-darwin-all-dynamic.tar.gz"
|
23
23
|
}
|
24
24
|
},
|
25
25
|
"universal-darwin" => {
|
26
26
|
"static" => {
|
27
|
-
"checksum" => "
|
27
|
+
"checksum" => "0864691f001133fa479b34b00a682e76f374c40c161e7715756a3c036e3c8798",
|
28
28
|
"filename" => "appsignal-x86_64-darwin-all-static.tar.gz"
|
29
29
|
},
|
30
30
|
"dynamic" => {
|
31
|
-
"checksum" => "
|
31
|
+
"checksum" => "5141528c4293e4bd619107ae79afc8e07fdc8b33835899c5cf3f82ab3d31de8f",
|
32
32
|
"filename" => "appsignal-x86_64-darwin-all-dynamic.tar.gz"
|
33
33
|
}
|
34
34
|
},
|
35
35
|
"aarch64-darwin" => {
|
36
36
|
"static" => {
|
37
|
-
"checksum" => "
|
37
|
+
"checksum" => "13506e5911523e7107a8cb714e18b3bcb690f3eeef88bf9aff54777ba540fdc4",
|
38
38
|
"filename" => "appsignal-aarch64-darwin-all-static.tar.gz"
|
39
39
|
},
|
40
40
|
"dynamic" => {
|
41
|
-
"checksum" => "
|
41
|
+
"checksum" => "9d4deef17f42dc54981344a5af6b872e06dbd3d317be68b6abeb2403ffd65e23",
|
42
42
|
"filename" => "appsignal-aarch64-darwin-all-dynamic.tar.gz"
|
43
43
|
}
|
44
44
|
},
|
45
45
|
"arm64-darwin" => {
|
46
46
|
"static" => {
|
47
|
-
"checksum" => "
|
47
|
+
"checksum" => "13506e5911523e7107a8cb714e18b3bcb690f3eeef88bf9aff54777ba540fdc4",
|
48
48
|
"filename" => "appsignal-aarch64-darwin-all-static.tar.gz"
|
49
49
|
},
|
50
50
|
"dynamic" => {
|
51
|
-
"checksum" => "
|
51
|
+
"checksum" => "9d4deef17f42dc54981344a5af6b872e06dbd3d317be68b6abeb2403ffd65e23",
|
52
52
|
"filename" => "appsignal-aarch64-darwin-all-dynamic.tar.gz"
|
53
53
|
}
|
54
54
|
},
|
55
55
|
"arm-darwin" => {
|
56
56
|
"static" => {
|
57
|
-
"checksum" => "
|
57
|
+
"checksum" => "13506e5911523e7107a8cb714e18b3bcb690f3eeef88bf9aff54777ba540fdc4",
|
58
58
|
"filename" => "appsignal-aarch64-darwin-all-static.tar.gz"
|
59
59
|
},
|
60
60
|
"dynamic" => {
|
61
|
-
"checksum" => "
|
61
|
+
"checksum" => "9d4deef17f42dc54981344a5af6b872e06dbd3d317be68b6abeb2403ffd65e23",
|
62
62
|
"filename" => "appsignal-aarch64-darwin-all-dynamic.tar.gz"
|
63
63
|
}
|
64
64
|
},
|
65
65
|
"aarch64-linux" => {
|
66
66
|
"static" => {
|
67
|
-
"checksum" => "
|
67
|
+
"checksum" => "76702b5755d5bb45cc05df17dd38389b7e20e105a52324120a45ae1b481c7881",
|
68
68
|
"filename" => "appsignal-aarch64-linux-all-static.tar.gz"
|
69
69
|
},
|
70
70
|
"dynamic" => {
|
71
|
-
"checksum" => "
|
71
|
+
"checksum" => "bf518ce2cb4a9041fe819b6bf43e1bc793fe52b3e73527687d7812618c8e7407",
|
72
72
|
"filename" => "appsignal-aarch64-linux-all-dynamic.tar.gz"
|
73
73
|
}
|
74
74
|
},
|
75
75
|
"i686-linux" => {
|
76
76
|
"static" => {
|
77
|
-
"checksum" => "
|
77
|
+
"checksum" => "22cbda11a8d801d75e9394033f5cf28f0ddcff66a2138720f827441bdcf919c2",
|
78
78
|
"filename" => "appsignal-i686-linux-all-static.tar.gz"
|
79
79
|
},
|
80
80
|
"dynamic" => {
|
81
|
-
"checksum" => "
|
81
|
+
"checksum" => "157492663e434421499f9cc0b510178387c8968e53bdc6e216db374b86d5c3dc",
|
82
82
|
"filename" => "appsignal-i686-linux-all-dynamic.tar.gz"
|
83
83
|
}
|
84
84
|
},
|
85
85
|
"x86-linux" => {
|
86
86
|
"static" => {
|
87
|
-
"checksum" => "
|
87
|
+
"checksum" => "22cbda11a8d801d75e9394033f5cf28f0ddcff66a2138720f827441bdcf919c2",
|
88
88
|
"filename" => "appsignal-i686-linux-all-static.tar.gz"
|
89
89
|
},
|
90
90
|
"dynamic" => {
|
91
|
-
"checksum" => "
|
91
|
+
"checksum" => "157492663e434421499f9cc0b510178387c8968e53bdc6e216db374b86d5c3dc",
|
92
92
|
"filename" => "appsignal-i686-linux-all-dynamic.tar.gz"
|
93
93
|
}
|
94
94
|
},
|
95
95
|
"x86_64-linux" => {
|
96
96
|
"static" => {
|
97
|
-
"checksum" => "
|
97
|
+
"checksum" => "8ff0b1d7bf0cfc1c66e918545a9ab5c29be35c371cde48f64a01c725290599ed",
|
98
98
|
"filename" => "appsignal-x86_64-linux-all-static.tar.gz"
|
99
99
|
},
|
100
100
|
"dynamic" => {
|
101
|
-
"checksum" => "
|
101
|
+
"checksum" => "a186c18536c3b7ec4802e852a62154cc976dcb5f554c3d0d8472d5cd7131b02b",
|
102
102
|
"filename" => "appsignal-x86_64-linux-all-dynamic.tar.gz"
|
103
103
|
}
|
104
104
|
},
|
105
105
|
"x86_64-linux-musl" => {
|
106
106
|
"static" => {
|
107
|
-
"checksum" => "
|
107
|
+
"checksum" => "a5e0af3e5e1ad908792e79c7c46b59119272e9836e5ea96791c78e3cb12ed132",
|
108
108
|
"filename" => "appsignal-x86_64-linux-musl-all-static.tar.gz"
|
109
109
|
},
|
110
110
|
"dynamic" => {
|
111
|
-
"checksum" => "
|
111
|
+
"checksum" => "17c108a83dff86b2531bf7f348481bb31ece53b4cc62615ca0a34332c0df2970",
|
112
112
|
"filename" => "appsignal-x86_64-linux-musl-all-dynamic.tar.gz"
|
113
113
|
}
|
114
114
|
},
|
115
115
|
"aarch64-linux-musl" => {
|
116
116
|
"static" => {
|
117
|
-
"checksum" => "
|
117
|
+
"checksum" => "92460560115d540a8140cbc360bd98beba8477e8a73eafd20ee611543b4528df",
|
118
118
|
"filename" => "appsignal-aarch64-linux-musl-all-static.tar.gz"
|
119
119
|
},
|
120
120
|
"dynamic" => {
|
121
|
-
"checksum" => "
|
121
|
+
"checksum" => "d4749b10a1803080e0b1b0d8f95ef9d1fef0aa694fa0fc405df97812937d8e7c",
|
122
122
|
"filename" => "appsignal-aarch64-linux-musl-all-dynamic.tar.gz"
|
123
123
|
}
|
124
124
|
},
|
125
125
|
"x86_64-freebsd" => {
|
126
126
|
"static" => {
|
127
|
-
"checksum" => "
|
127
|
+
"checksum" => "8d8733c2adc0f750553be11b5e54fd614b13207be67863d95c57e4739021a92f",
|
128
128
|
"filename" => "appsignal-x86_64-freebsd-all-static.tar.gz"
|
129
129
|
},
|
130
130
|
"dynamic" => {
|
131
|
-
"checksum" => "
|
131
|
+
"checksum" => "8a9cbdc645b3833766458a252c2a8fefda76c62fceee8be795b286d65cc513c6",
|
132
132
|
"filename" => "appsignal-x86_64-freebsd-all-dynamic.tar.gz"
|
133
133
|
}
|
134
134
|
},
|
135
135
|
"amd64-freebsd" => {
|
136
136
|
"static" => {
|
137
|
-
"checksum" => "
|
137
|
+
"checksum" => "8d8733c2adc0f750553be11b5e54fd614b13207be67863d95c57e4739021a92f",
|
138
138
|
"filename" => "appsignal-x86_64-freebsd-all-static.tar.gz"
|
139
139
|
},
|
140
140
|
"dynamic" => {
|
141
|
-
"checksum" => "
|
141
|
+
"checksum" => "8a9cbdc645b3833766458a252c2a8fefda76c62fceee8be795b286d65cc513c6",
|
142
142
|
"filename" => "appsignal-x86_64-freebsd-all-dynamic.tar.gz"
|
143
143
|
}
|
144
144
|
}
|
data/ext/appsignal_extension.c
CHANGED
@@ -759,28 +759,6 @@ static VALUE set_gauge(VALUE self, VALUE key, VALUE value, VALUE tags) {
|
|
759
759
|
return Qnil;
|
760
760
|
}
|
761
761
|
|
762
|
-
static VALUE set_host_gauge(VALUE self, VALUE key, VALUE value) {
|
763
|
-
Check_Type(key, T_STRING);
|
764
|
-
Check_Type(value, T_FLOAT);
|
765
|
-
|
766
|
-
appsignal_set_host_gauge(
|
767
|
-
make_appsignal_string(key),
|
768
|
-
NUM2DBL(value)
|
769
|
-
);
|
770
|
-
return Qnil;
|
771
|
-
}
|
772
|
-
|
773
|
-
static VALUE set_process_gauge(VALUE self, VALUE key, VALUE value) {
|
774
|
-
Check_Type(key, T_STRING);
|
775
|
-
Check_Type(value, T_FLOAT);
|
776
|
-
|
777
|
-
appsignal_set_process_gauge(
|
778
|
-
make_appsignal_string(key),
|
779
|
-
NUM2DBL(value)
|
780
|
-
);
|
781
|
-
return Qnil;
|
782
|
-
}
|
783
|
-
|
784
762
|
static VALUE increment_counter(VALUE self, VALUE key, VALUE count, VALUE tags) {
|
785
763
|
appsignal_data_t* tags_data;
|
786
764
|
|
@@ -941,8 +919,6 @@ void Init_appsignal_extension(void) {
|
|
941
919
|
|
942
920
|
// Metrics
|
943
921
|
rb_define_singleton_method(Extension, "set_gauge", set_gauge, 3);
|
944
|
-
rb_define_singleton_method(Extension, "set_host_gauge", set_host_gauge, 2);
|
945
|
-
rb_define_singleton_method(Extension, "set_process_gauge", set_process_gauge, 2);
|
946
922
|
rb_define_singleton_method(Extension, "increment_counter", increment_counter, 3);
|
947
923
|
rb_define_singleton_method(Extension, "add_distribution_value", add_distribution_value, 3);
|
948
924
|
}
|
data/ext/base.rb
CHANGED
@@ -26,13 +26,16 @@ def report
|
|
26
26
|
@report ||=
|
27
27
|
begin
|
28
28
|
rbconfig = RbConfig::CONFIG
|
29
|
+
patchlevel = rbconfig["PATCHLEVEL"]
|
30
|
+
patchlevel_label = "-p#{patchlevel}" if patchlevel
|
31
|
+
ruby_version = "#{RUBY_VERSION}#{patchlevel_label}"
|
29
32
|
{
|
30
33
|
"result" => {
|
31
34
|
"status" => "incomplete"
|
32
35
|
},
|
33
36
|
"language" => {
|
34
37
|
"name" => "ruby",
|
35
|
-
"version" =>
|
38
|
+
"version" => ruby_version
|
36
39
|
},
|
37
40
|
"download" => {
|
38
41
|
"checksum" => "unverified"
|
@@ -19,7 +19,6 @@ module Appsignal
|
|
19
19
|
begin
|
20
20
|
config = Appsignal.config
|
21
21
|
log_file_path = config.log_file_path
|
22
|
-
makefile_log_path = File.join("ext", "mkmf.log")
|
23
22
|
{
|
24
23
|
:package_install_path => {
|
25
24
|
:label => "AppSignal gem path",
|
@@ -37,9 +36,9 @@ module Appsignal
|
|
37
36
|
:label => "Log directory",
|
38
37
|
:path => log_file_path ? File.dirname(log_file_path) : ""
|
39
38
|
},
|
40
|
-
|
39
|
+
"ext/mkmf.log" => {
|
41
40
|
:label => "Makefile install log",
|
42
|
-
:path =>
|
41
|
+
:path => makefile_install_log_path
|
43
42
|
},
|
44
43
|
"appsignal.log" => {
|
45
44
|
:label => "AppSignal log",
|
@@ -54,8 +53,11 @@ module Appsignal
|
|
54
53
|
def path_stat(path)
|
55
54
|
{
|
56
55
|
:path => path,
|
57
|
-
:exists =>
|
56
|
+
:exists => false
|
58
57
|
}.tap do |info|
|
58
|
+
next unless info[:path]
|
59
|
+
|
60
|
+
info[:exists] = File.exist?(path)
|
59
61
|
next unless info[:exists]
|
60
62
|
|
61
63
|
stat = File.stat(path)
|
@@ -71,18 +73,39 @@ module Appsignal
|
|
71
73
|
:group => Utils.group_for_gid(path_gid)
|
72
74
|
}
|
73
75
|
if info[:type] == "file"
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
76
|
+
begin
|
77
|
+
info[:content] = Utils.read_file_content(
|
78
|
+
path,
|
79
|
+
BYTES_TO_READ_FOR_FILES
|
80
|
+
).split("\n")
|
81
|
+
rescue => error
|
82
|
+
info[:read_error] = "#{error.class}: #{error.message}"
|
83
|
+
end
|
78
84
|
end
|
79
85
|
end
|
80
86
|
end
|
81
87
|
|
82
88
|
# Returns the AppSignal gem installation path. The root directory of
|
83
|
-
# this gem.
|
89
|
+
# this gem when installed.
|
84
90
|
def gem_path
|
85
|
-
|
91
|
+
gemspec.full_gem_path
|
92
|
+
end
|
93
|
+
|
94
|
+
# Returns the AppSignal gem's Makefile log path, if it exists.
|
95
|
+
def makefile_install_log_path
|
96
|
+
possible_locations = [
|
97
|
+
# Installed gem location
|
98
|
+
File.join(gemspec.extension_dir, "mkmf.log"),
|
99
|
+
# Local development location
|
100
|
+
File.join(gem_path, "ext", "mkmf.log")
|
101
|
+
]
|
102
|
+
possible_locations.find do |location|
|
103
|
+
File.exist?(location)
|
104
|
+
end || possible_locations.first
|
105
|
+
end
|
106
|
+
|
107
|
+
def gemspec
|
108
|
+
Gem.loaded_specs["appsignal"]
|
86
109
|
end
|
87
110
|
end
|
88
111
|
end
|
@@ -201,7 +201,7 @@ module Appsignal
|
|
201
201
|
)
|
202
202
|
Appsignal.config.write_to_environment
|
203
203
|
Appsignal.start_logger
|
204
|
-
Appsignal.
|
204
|
+
Appsignal.internal_logger.info("Starting AppSignal diagnose")
|
205
205
|
end
|
206
206
|
|
207
207
|
def run_agent_diagnose_mode
|
@@ -631,6 +631,11 @@ module Appsignal
|
|
631
631
|
else
|
632
632
|
print_empty_line
|
633
633
|
end
|
634
|
+
|
635
|
+
return unless path.key?(:read_error)
|
636
|
+
|
637
|
+
puts " Read error: #{path[:read_error]}"
|
638
|
+
print_empty_line
|
634
639
|
end
|
635
640
|
|
636
641
|
def print_empty_line
|
data/lib/appsignal/config.rb
CHANGED
@@ -11,6 +11,7 @@ module Appsignal
|
|
11
11
|
include Appsignal::Utils::DeprecationMessage
|
12
12
|
|
13
13
|
DEFAULT_CONFIG = {
|
14
|
+
:activejob_report_errors => "all",
|
14
15
|
:ca_file_path => File.expand_path(File.join("../../../resources/cacert.pem"), __FILE__),
|
15
16
|
:debug => false,
|
16
17
|
:dns_servers => [],
|
@@ -40,7 +41,7 @@ module Appsignal
|
|
40
41
|
HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
|
41
42
|
HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_CONNECTION
|
42
43
|
CONTENT_LENGTH PATH_INFO HTTP_RANGE
|
43
|
-
REQUEST_METHOD
|
44
|
+
REQUEST_METHOD REQUEST_PATH SERVER_NAME SERVER_PORT
|
44
45
|
SERVER_PROTOCOL
|
45
46
|
],
|
46
47
|
:send_environment_metadata => true,
|
@@ -65,6 +66,7 @@ module Appsignal
|
|
65
66
|
|
66
67
|
ENV_TO_KEY_MAPPING = {
|
67
68
|
"APPSIGNAL_ACTIVE" => :active,
|
69
|
+
"APPSIGNAL_ACTIVE_JOB_REPORT_ERRORS" => :activejob_report_errors,
|
68
70
|
"APPSIGNAL_APP_NAME" => :name,
|
69
71
|
"APPSIGNAL_BIND_ADDRESS" => :bind_address,
|
70
72
|
"APPSIGNAL_CA_FILE_PATH" => :ca_file_path,
|
@@ -112,6 +114,7 @@ module Appsignal
|
|
112
114
|
}.freeze
|
113
115
|
# @api private
|
114
116
|
ENV_STRING_KEYS = %w[
|
117
|
+
APPSIGNAL_ACTIVE_JOB_REPORT_ERRORS
|
115
118
|
APPSIGNAL_APP_NAME
|
116
119
|
APPSIGNAL_BIND_ADDRESS
|
117
120
|
APPSIGNAL_CA_FILE_PATH
|
@@ -219,8 +222,8 @@ module Appsignal
|
|
219
222
|
# use. This will be overwritten by the file config and environment
|
220
223
|
# variables config.
|
221
224
|
# @param logger [Logger] The logger to use for the AppSignal gem. This is
|
222
|
-
# used by the configuration class only. Default:
|
223
|
-
# also {Appsignal.start_logger}.
|
225
|
+
# used by the configuration class only. Default:
|
226
|
+
# {Appsignal.internal_logger}. See also {Appsignal.start_logger}.
|
224
227
|
# @param config_file [String] Custom config file location. Default
|
225
228
|
# `config/appsignal.yml`.
|
226
229
|
#
|
@@ -230,8 +233,13 @@ module Appsignal
|
|
230
233
|
# Configuration load order
|
231
234
|
# @see https://docs.appsignal.com/ruby/instrumentation/integrating-appsignal.html
|
232
235
|
# How to integrate AppSignal manually
|
233
|
-
def initialize(
|
234
|
-
|
236
|
+
def initialize(
|
237
|
+
root_path,
|
238
|
+
env,
|
239
|
+
initial_config = {},
|
240
|
+
logger = Appsignal.internal_logger,
|
241
|
+
config_file = nil
|
242
|
+
)
|
235
243
|
@config_file_error = false
|
236
244
|
@root_path = root_path
|
237
245
|
@config_file = config_file
|
@@ -284,6 +292,12 @@ module Appsignal
|
|
284
292
|
config_hash[key]
|
285
293
|
end
|
286
294
|
|
295
|
+
# Update the internal config hash.
|
296
|
+
#
|
297
|
+
# This method does not update the config in the extension and agent. It
|
298
|
+
# should not be used to update the config after AppSignal has started.
|
299
|
+
#
|
300
|
+
# @api private
|
287
301
|
def []=(key, value)
|
288
302
|
config_hash[key] = value
|
289
303
|
end
|
data/lib/appsignal/demo.rb
CHANGED
@@ -93,7 +93,7 @@ module Appsignal
|
|
93
93
|
"SERVER_NAME" => "localhost",
|
94
94
|
"SERVER_PORT" => "80",
|
95
95
|
"SERVER_PROTOCOL" => "HTTP/1.1",
|
96
|
-
"
|
96
|
+
"REQUEST_PATH" => "/hello",
|
97
97
|
"PATH_INFO" => "/hello",
|
98
98
|
"HTTP_ACCEPT" => "text/html,application/xhtml+xml",
|
99
99
|
"HTTP_ACCEPT_ENCODING" => "gzip, deflate, sdch",
|
@@ -10,9 +10,9 @@ module Appsignal
|
|
10
10
|
#
|
11
11
|
# The value of the environment metadata is given as a block that captures
|
12
12
|
# errors that might be raised while fetching the value. It will not
|
13
|
-
# re-raise errors, but instead log them using the
|
14
|
-
# ensures AppSignal will not cause an
|
15
|
-
# collecting this metadata.
|
13
|
+
# re-raise errors, but instead log them using the
|
14
|
+
# {Appsignal.internal_logger}. This ensures AppSignal will not cause an
|
15
|
+
# error in the application when collecting this metadata.
|
16
16
|
#
|
17
17
|
# @example Reporting a key and value
|
18
18
|
# Appsignal::Environment.report("ruby_version") { RUBY_VERSION }
|
@@ -34,8 +34,8 @@ module Appsignal
|
|
34
34
|
when String
|
35
35
|
key
|
36
36
|
else
|
37
|
-
Appsignal.
|
38
|
-
"Unsupported value type for #{key.inspect}"
|
37
|
+
Appsignal.internal_logger.error "Unable to report on environment " \
|
38
|
+
"metadata: Unsupported value type for #{key.inspect}"
|
39
39
|
return
|
40
40
|
end
|
41
41
|
|
@@ -43,7 +43,7 @@ module Appsignal
|
|
43
43
|
begin
|
44
44
|
yield
|
45
45
|
rescue => e
|
46
|
-
Appsignal.
|
46
|
+
Appsignal.internal_logger.error \
|
47
47
|
"Unable to report on environment metadata #{key.inspect}:\n" \
|
48
48
|
"#{e.class}: #{e}"
|
49
49
|
return
|
@@ -56,26 +56,35 @@ module Appsignal
|
|
56
56
|
when String
|
57
57
|
yielded_value
|
58
58
|
else
|
59
|
-
Appsignal.
|
60
|
-
"#{key.inspect}: Unsupported value type for " \
|
59
|
+
Appsignal.internal_logger.error "Unable to report on environment " \
|
60
|
+
"metadata #{key.inspect}: Unsupported value type for " \
|
61
61
|
"#{yielded_value.inspect}"
|
62
62
|
return
|
63
63
|
end
|
64
64
|
|
65
65
|
Appsignal::Extension.set_environment_metadata(key, value)
|
66
66
|
rescue => e
|
67
|
-
Appsignal.
|
68
|
-
"#{e.class}: #{e}"
|
67
|
+
Appsignal.internal_logger.error "Unable to report on environment " \
|
68
|
+
"metadata:\n#{e.class}: #{e}"
|
69
69
|
end
|
70
70
|
|
71
71
|
# @see report_supported_gems
|
72
72
|
SUPPORTED_GEMS = %w[
|
73
73
|
actioncable
|
74
|
+
actionmailer
|
74
75
|
activejob
|
76
|
+
activerecord
|
75
77
|
capistrano
|
76
78
|
celluloid
|
77
79
|
data_mapper
|
78
80
|
delayed_job
|
81
|
+
dry-monitor
|
82
|
+
elasticsearch
|
83
|
+
excon
|
84
|
+
faraday
|
85
|
+
gvltools
|
86
|
+
hanami
|
87
|
+
hiredis
|
79
88
|
mongo_ruby_driver
|
80
89
|
padrino
|
81
90
|
passenger
|
@@ -85,7 +94,9 @@ module Appsignal
|
|
85
94
|
rails
|
86
95
|
rake
|
87
96
|
redis
|
97
|
+
redis-client
|
88
98
|
resque
|
99
|
+
rom
|
89
100
|
sequel
|
90
101
|
shoryuken
|
91
102
|
sidekiq
|
@@ -114,15 +125,15 @@ module Appsignal
|
|
114
125
|
report("ruby_#{gem_name}_version") { gem_spec.version.to_s }
|
115
126
|
end
|
116
127
|
rescue => e
|
117
|
-
Appsignal.
|
128
|
+
Appsignal.internal_logger.error "Unable to report supported gems:\n" \
|
118
129
|
"#{e.class}: #{e}"
|
119
130
|
end
|
120
131
|
|
121
132
|
def self.report_enabled(feature)
|
122
133
|
Appsignal::Environment.report("ruby_#{feature}_enabled") { true }
|
123
134
|
rescue => e
|
124
|
-
Appsignal.
|
125
|
-
"#{e.class}: #{e}"
|
135
|
+
Appsignal.internal_logger.error "Unable to report integration " \
|
136
|
+
"enabled:\n#{e.class}: #{e}"
|
126
137
|
end
|
127
138
|
end
|
128
139
|
end
|
@@ -71,12 +71,6 @@ module Appsignal
|
|
71
71
|
attach_function :appsignal_set_gauge,
|
72
72
|
[:appsignal_string, :double, :pointer],
|
73
73
|
:void
|
74
|
-
attach_function :appsignal_set_host_gauge,
|
75
|
-
[:appsignal_string, :double],
|
76
|
-
:void
|
77
|
-
attach_function :appsignal_set_process_gauge,
|
78
|
-
[:appsignal_string, :double],
|
79
|
-
:void
|
80
74
|
attach_function :appsignal_increment_counter,
|
81
75
|
[:appsignal_string, :double, :pointer],
|
82
76
|
:void
|
@@ -248,14 +242,15 @@ module Appsignal
|
|
248
242
|
[:pointer],
|
249
243
|
:appsignal_string
|
250
244
|
|
251
|
-
Appsignal.extension_loaded = true
|
245
|
+
Appsignal.extension_loaded = true if Appsignal.respond_to? :extension_loaded=
|
252
246
|
rescue LoadError => error
|
253
247
|
error_message = "ERROR: AppSignal failed to load extension. " \
|
254
248
|
"Please run `appsignal diagnose` and email us at support@appsignal.com\n" \
|
255
249
|
"#{error.class}: #{error.message}"
|
256
|
-
Appsignal.
|
250
|
+
Appsignal.internal_logger.error(error_message) if Appsignal.respond_to? :internal_logger
|
257
251
|
Kernel.warn error_message
|
258
|
-
Appsignal.extension_loaded = false
|
252
|
+
Appsignal.extension_loaded = false if Appsignal.respond_to? :extension_loaded=
|
253
|
+
raise error if ENV["_APPSIGNAL_EXTENSION_INSTALL"] == "true"
|
259
254
|
end
|
260
255
|
|
261
256
|
def start
|
@@ -319,14 +314,6 @@ module Appsignal
|
|
319
314
|
appsignal_set_gauge(make_appsignal_string(key), value, tags.pointer)
|
320
315
|
end
|
321
316
|
|
322
|
-
def set_host_gauge(key, value)
|
323
|
-
appsignal_set_host_gauge(make_appsignal_string(key), value)
|
324
|
-
end
|
325
|
-
|
326
|
-
def set_process_gauge(key, value)
|
327
|
-
appsignal_set_process_gauge(make_appsignal_string(key), value)
|
328
|
-
end
|
329
|
-
|
330
317
|
def increment_counter(key, value, tags)
|
331
318
|
appsignal_increment_counter(make_appsignal_string(key), value, tags.pointer)
|
332
319
|
end
|
data/lib/appsignal/extension.rb
CHANGED
@@ -12,7 +12,7 @@ rescue LoadError => error
|
|
12
12
|
error_message = "ERROR: AppSignal failed to load extension. " \
|
13
13
|
"Please run `appsignal diagnose` and email us at support@appsignal.com\n" \
|
14
14
|
"#{error.class}: #{error.message}"
|
15
|
-
Appsignal.
|
15
|
+
Appsignal.internal_logger.error(error_message)
|
16
16
|
Kernel.warn error_message
|
17
17
|
Appsignal.extension_loaded = false
|
18
18
|
end
|
@@ -7,8 +7,8 @@ module Appsignal
|
|
7
7
|
|
8
8
|
# Creates an AppSignal transaction for the given block.
|
9
9
|
#
|
10
|
-
# If AppSignal is not {.active?} it will still execute the
|
11
|
-
# create a transaction for it.
|
10
|
+
# If AppSignal is not {Appsignal.active?} it will still execute the
|
11
|
+
# block, but not create a transaction for it.
|
12
12
|
#
|
13
13
|
# A event is created for this transaction with the name given in the
|
14
14
|
# `name` argument. The event name must start with either `perform_job` or
|
@@ -68,9 +68,9 @@ module Appsignal
|
|
68
68
|
namespace = Appsignal::Transaction::HTTP_REQUEST
|
69
69
|
request = ::Rack::Request.new(env)
|
70
70
|
else
|
71
|
-
|
72
|
-
"either 'perform_job' (for jobs and tasks) or
|
73
|
-
"(for HTTP requests)"
|
71
|
+
internal_logger.error "Unrecognized name '#{name}': names must " \
|
72
|
+
"start with either 'perform_job' (for jobs and tasks) or " \
|
73
|
+
"'process_action' (for HTTP requests)"
|
74
74
|
return yield
|
75
75
|
end
|
76
76
|
|
@@ -112,7 +112,7 @@ module Appsignal
|
|
112
112
|
# transaction. Does not add the error to the current transaction.
|
113
113
|
#
|
114
114
|
# Make sure that AppSignal is integrated in your application beforehand.
|
115
|
-
# AppSignal won't record errors unless {
|
115
|
+
# AppSignal won't record errors unless {Appsignal.active?} is `true`.
|
116
116
|
#
|
117
117
|
# @example
|
118
118
|
# # my_app.rb
|
@@ -228,8 +228,8 @@ module Appsignal
|
|
228
228
|
return unless active?
|
229
229
|
|
230
230
|
unless error.is_a?(Exception)
|
231
|
-
|
232
|
-
"value is not an exception: #{error.inspect}"
|
231
|
+
internal_logger.error "Appsignal.send_error: Cannot send error. " \
|
232
|
+
"The given value is not an exception: #{error.inspect}"
|
233
233
|
return
|
234
234
|
end
|
235
235
|
transaction = Appsignal::Transaction.new(
|
@@ -319,8 +319,8 @@ module Appsignal
|
|
319
319
|
"Appsignal.set_error called on location: #{call_location}"
|
320
320
|
end
|
321
321
|
unless exception.is_a?(Exception)
|
322
|
-
|
323
|
-
"value is not an exception: #{exception.inspect}"
|
322
|
+
internal_logger.error "Appsignal.set_error: Cannot set error. " \
|
323
|
+
"The given value is not an exception: #{exception.inspect}"
|
324
324
|
return
|
325
325
|
end
|
326
326
|
return if !active? || !Appsignal::Transaction.current?
|