appsignal 2.10.6 → 2.11.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.semaphore/semaphore.yml +6 -0
- data/CHANGELOG.md +20 -0
- data/build_matrix.yml +5 -0
- data/ext/agent.yml +19 -19
- data/ext/appsignal_extension.c +10 -1
- data/ext/base.rb +15 -4
- data/lib/appsignal.rb +21 -1
- data/lib/appsignal/capistrano.rb +2 -0
- data/lib/appsignal/config.rb +6 -2
- data/lib/appsignal/environment.rb +126 -0
- data/lib/appsignal/extension/jruby.rb +10 -0
- data/lib/appsignal/hooks/net_http.rb +10 -13
- data/lib/appsignal/hooks/redis.rb +2 -0
- data/lib/appsignal/hooks/sequel.rb +2 -0
- data/lib/appsignal/integrations/delayed_job_plugin.rb +16 -3
- data/lib/appsignal/integrations/object.rb +4 -0
- data/lib/appsignal/integrations/resque_active_job.rb +12 -4
- data/lib/appsignal/system.rb +0 -6
- data/lib/appsignal/transaction.rb +22 -7
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/cli/diagnose_spec.rb +2 -1
- data/spec/lib/appsignal/config_spec.rb +6 -1
- data/spec/lib/appsignal/environment_spec.rb +167 -0
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +198 -166
- data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +55 -13
- data/spec/lib/appsignal/system_spec.rb +0 -36
- data/spec/lib/appsignal/transaction_spec.rb +30 -13
- data/spec/lib/appsignal_spec.rb +22 -0
- data/spec/support/helpers/dependency_helper.rb +5 -0
- data/spec/support/helpers/env_helpers.rb +1 -1
- data/spec/support/helpers/environment_metdata_helper.rb +16 -0
- metadata +13 -9
- data/lib/appsignal/integrations/net_http.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 250f9ca7d702af9daaafbbced86a9122fea07296841c65c41d64a2a9a594fded
|
4
|
+
data.tar.gz: 1753bb37eaeadc98397573098a3b9cf1d718c072074ff3a2d45d3251e75db5f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bd72bf03e824a48fff4be825ce0ecab592f10f77a0163505a7c3f71bde0f8fbafd12642fc232f0528036416ac890ca3d29a44e84efce12a086959a6dcf1178a
|
7
|
+
data.tar.gz: e82a5e2dee87442a90ab2a67b0627f4d4d787243bde54d0ee78420f8286c97f53ca97c97e0283f6991ad123180ab6303564a610159d862e2a1ffbd5921d534f8
|
data/.semaphore/semaphore.yml
CHANGED
@@ -36,6 +36,7 @@ global_job_config:
|
|
36
36
|
- cache restore $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE),$_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET,$_BUNDLER_CACHE-bundler-$RUBY_VERSION
|
37
37
|
- cache restore $_GEMS_CACHE-gems-$RUBY_VERSION-$(checksum $BUNDLE_GEMFILE),$_GEMS_CACHE-gems-$RUBY_VERSION
|
38
38
|
- "./support/install_deps"
|
39
|
+
- bundle config set clean 'true'
|
39
40
|
- "./support/bundler_wrapper install --jobs=3 --retry=3"
|
40
41
|
epilogue:
|
41
42
|
on_pass:
|
@@ -43,6 +44,11 @@ global_job_config:
|
|
43
44
|
- cache store $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)
|
44
45
|
.bundle
|
45
46
|
- cache store $_GEMS_CACHE-gems-$RUBY_VERSION-$(checksum $BUNDLE_GEMFILE) $HOME/.gem
|
47
|
+
on_fail:
|
48
|
+
commands:
|
49
|
+
- "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report
|
50
|
+
file found'"
|
51
|
+
- "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file found'"
|
46
52
|
blocks:
|
47
53
|
- name: Validation
|
48
54
|
dependencies: []
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
# 2.11.0
|
4
|
+
- Track queue time regardless of namespace. Support custom namespaces. PR #602
|
5
|
+
- Report Ruby environment metadata. PR #621
|
6
|
+
|
7
|
+
# 2.10.9
|
8
|
+
- Use http proxy if configured when downloading agent. PR #606
|
9
|
+
- Clear event details cache every 48 hours.
|
10
|
+
Commit eb5e899db69fcd7cfa221567bfd6ac04f2654c9c
|
11
|
+
- Add support for Resque ActiveJob queue time reporting. PR #616
|
12
|
+
|
13
|
+
## 2.10.8
|
14
|
+
- Fix failed checksum error log. PR #609
|
15
|
+
- Fix DelayedJob action name detection for objects that listen to the `[]`
|
16
|
+
method and return a non-String value. #611
|
17
|
+
- CI test build improvements. PR #607, #608, #614
|
18
|
+
|
19
|
+
## 2.10.7
|
20
|
+
- Revert fix for compatibility with the `http_logger` gem. PR #604.
|
21
|
+
For more information, see issue #603 about our reasoning and discussion.
|
22
|
+
|
3
23
|
## 2.10.6
|
4
24
|
- Check if queued payloads are for correct app and not expired
|
5
25
|
|
data/build_matrix.yml
CHANGED
@@ -37,12 +37,17 @@ semaphore: # Default `.semaphore/semaphore.yml` contents
|
|
37
37
|
- cache restore $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE),$_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET,$_BUNDLER_CACHE-bundler-$RUBY_VERSION
|
38
38
|
- cache restore $_GEMS_CACHE-gems-$RUBY_VERSION-$(checksum $BUNDLE_GEMFILE),$_GEMS_CACHE-gems-$RUBY_VERSION
|
39
39
|
- ./support/install_deps
|
40
|
+
- bundle config set clean 'true'
|
40
41
|
- ./support/bundler_wrapper install --jobs=3 --retry=3
|
41
42
|
epilogue:
|
42
43
|
on_pass:
|
43
44
|
commands:
|
44
45
|
- cache store $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE) .bundle
|
45
46
|
- cache store $_GEMS_CACHE-gems-$RUBY_VERSION-$(checksum $BUNDLE_GEMFILE) $HOME/.gem
|
47
|
+
on_fail:
|
48
|
+
commands:
|
49
|
+
- "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report file found'"
|
50
|
+
- "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file found'"
|
46
51
|
|
47
52
|
blocks:
|
48
53
|
- name: Validation
|
data/ext/agent.yml
CHANGED
@@ -1,70 +1,70 @@
|
|
1
1
|
---
|
2
|
-
version:
|
2
|
+
version: 38a8a6f
|
3
3
|
mirrors:
|
4
4
|
- https://appsignal-agent-releases.global.ssl.fastly.net
|
5
5
|
- https://d135dj0rjqvssy.cloudfront.net
|
6
6
|
triples:
|
7
7
|
x86_64-darwin:
|
8
8
|
static:
|
9
|
-
checksum:
|
9
|
+
checksum: 47f24cd09ab00fe3419a313c52d97170c9555d3ea85c8bd98cbb295df29456dd
|
10
10
|
filename: appsignal-x86_64-darwin-all-static.tar.gz
|
11
11
|
dynamic:
|
12
|
-
checksum:
|
12
|
+
checksum: a26437fbd4c97ff0b69bf42e83d968647532648313227224df1bbbd0ed105104
|
13
13
|
filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
|
14
14
|
universal-darwin:
|
15
15
|
static:
|
16
|
-
checksum:
|
16
|
+
checksum: 47f24cd09ab00fe3419a313c52d97170c9555d3ea85c8bd98cbb295df29456dd
|
17
17
|
filename: appsignal-x86_64-darwin-all-static.tar.gz
|
18
18
|
dynamic:
|
19
|
-
checksum:
|
19
|
+
checksum: a26437fbd4c97ff0b69bf42e83d968647532648313227224df1bbbd0ed105104
|
20
20
|
filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
|
21
21
|
i686-linux:
|
22
22
|
static:
|
23
|
-
checksum:
|
23
|
+
checksum: ae37b329907cead537cf2a87a562ee92120add6c8874bc2e9235e5c537bca692
|
24
24
|
filename: appsignal-i686-linux-all-static.tar.gz
|
25
25
|
dynamic:
|
26
|
-
checksum:
|
26
|
+
checksum: ee5da14c7b5d2cc2dc2ae345d19c33a08c7e4861975e34878c1c295e57b2d8bc
|
27
27
|
filename: appsignal-i686-linux-all-dynamic.tar.gz
|
28
28
|
x86-linux:
|
29
29
|
static:
|
30
|
-
checksum:
|
30
|
+
checksum: ae37b329907cead537cf2a87a562ee92120add6c8874bc2e9235e5c537bca692
|
31
31
|
filename: appsignal-i686-linux-all-static.tar.gz
|
32
32
|
dynamic:
|
33
|
-
checksum:
|
33
|
+
checksum: ee5da14c7b5d2cc2dc2ae345d19c33a08c7e4861975e34878c1c295e57b2d8bc
|
34
34
|
filename: appsignal-i686-linux-all-dynamic.tar.gz
|
35
35
|
i686-linux-musl:
|
36
36
|
static:
|
37
|
-
checksum:
|
37
|
+
checksum: d2d6dfd5d86b229449c73c74ac6b922eeff981f451dd599cbc8b9f2b7a715931
|
38
38
|
filename: appsignal-i686-linux-musl-all-static.tar.gz
|
39
39
|
x86-linux-musl:
|
40
40
|
static:
|
41
|
-
checksum:
|
41
|
+
checksum: d2d6dfd5d86b229449c73c74ac6b922eeff981f451dd599cbc8b9f2b7a715931
|
42
42
|
filename: appsignal-i686-linux-musl-all-static.tar.gz
|
43
43
|
x86_64-linux:
|
44
44
|
static:
|
45
|
-
checksum:
|
45
|
+
checksum: 6b05c04df7de65be742942926c79e4d322a02dd3b18552b4eb42b420b67df214
|
46
46
|
filename: appsignal-x86_64-linux-all-static.tar.gz
|
47
47
|
dynamic:
|
48
|
-
checksum:
|
48
|
+
checksum: de2f7325d2d7d01632abe9eb135f51376ed3769167e0675b7e7c6de9702c057c
|
49
49
|
filename: appsignal-x86_64-linux-all-dynamic.tar.gz
|
50
50
|
x86_64-linux-musl:
|
51
51
|
static:
|
52
|
-
checksum:
|
52
|
+
checksum: 2a852991c740f93d83dbd3b34daaef45f2ebb02a921200734a6f715790d44968
|
53
53
|
filename: appsignal-x86_64-linux-musl-all-static.tar.gz
|
54
54
|
dynamic:
|
55
|
-
checksum:
|
55
|
+
checksum: 03fc01d09698b95a5686fc08e4cd1f35913a53413e0ae8ced877c0e7f8ca260e
|
56
56
|
filename: appsignal-x86_64-linux-musl-all-dynamic.tar.gz
|
57
57
|
x86_64-freebsd:
|
58
58
|
static:
|
59
|
-
checksum:
|
59
|
+
checksum: 3a26b9a4a1c7e412f6602f4bbae8dd95ad248b41e033b967163bae2f6fac0e96
|
60
60
|
filename: appsignal-x86_64-freebsd-all-static.tar.gz
|
61
61
|
dynamic:
|
62
|
-
checksum:
|
62
|
+
checksum: 4eda2bdb88670854abb07ad716e2d46de298dd8549835468c4a778f74c6a7b0e
|
63
63
|
filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
64
64
|
amd64-freebsd:
|
65
65
|
static:
|
66
|
-
checksum:
|
66
|
+
checksum: 3a26b9a4a1c7e412f6602f4bbae8dd95ad248b41e033b967163bae2f6fac0e96
|
67
67
|
filename: appsignal-x86_64-freebsd-all-static.tar.gz
|
68
68
|
dynamic:
|
69
|
-
checksum:
|
69
|
+
checksum: 4eda2bdb88670854abb07ad716e2d46de298dd8549835468c4a778f74c6a7b0e
|
70
70
|
filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
data/ext/appsignal_extension.c
CHANGED
@@ -639,6 +639,14 @@ static VALUE running_in_container() {
|
|
639
639
|
return appsignal_running_in_container() == 1 ? Qtrue : Qfalse;
|
640
640
|
}
|
641
641
|
|
642
|
+
static VALUE set_environment_metadata(VALUE self, VALUE key, VALUE value) {
|
643
|
+
appsignal_set_environment_metadata(
|
644
|
+
make_appsignal_string(key),
|
645
|
+
make_appsignal_string(value)
|
646
|
+
);
|
647
|
+
return Qnil;
|
648
|
+
}
|
649
|
+
|
642
650
|
void Init_appsignal_extension(void) {
|
643
651
|
Appsignal = rb_define_module("Appsignal");
|
644
652
|
Extension = rb_define_class_under(Appsignal, "Extension", rb_cObject);
|
@@ -697,9 +705,10 @@ void Init_appsignal_extension(void) {
|
|
697
705
|
// Get JSON content of a data
|
698
706
|
rb_define_method(Data, "to_s", data_to_s, 0);
|
699
707
|
|
700
|
-
//
|
708
|
+
// Other helper methods
|
701
709
|
rb_define_singleton_method(Extension, "install_allocation_event_hook", install_allocation_event_hook, 0);
|
702
710
|
rb_define_singleton_method(Extension, "running_in_container?", running_in_container, 0);
|
711
|
+
rb_define_singleton_method(Extension, "set_environment_metadata", set_environment_metadata, 2);
|
703
712
|
|
704
713
|
// Metrics
|
705
714
|
rb_define_singleton_method(Extension, "set_gauge", set_gauge, 3);
|
data/ext/base.rb
CHANGED
@@ -32,7 +32,8 @@ def report
|
|
32
32
|
"version" => "#{rbconfig["ruby_version"]}-p#{rbconfig["PATCHLEVEL"]}"
|
33
33
|
},
|
34
34
|
"download" => {
|
35
|
-
"checksum" => "unverified"
|
35
|
+
"checksum" => "unverified",
|
36
|
+
"http_proxy" => http_proxy
|
36
37
|
},
|
37
38
|
"build" => {
|
38
39
|
"time" => Time.now.utc,
|
@@ -126,7 +127,11 @@ def download_archive(type)
|
|
126
127
|
report["download"]["download_url"] = download_url
|
127
128
|
|
128
129
|
begin
|
129
|
-
return open(
|
130
|
+
return open(
|
131
|
+
download_url,
|
132
|
+
:ssl_ca_cert => CA_CERT_PATH,
|
133
|
+
:proxy => http_proxy
|
134
|
+
)
|
130
135
|
rescue
|
131
136
|
next
|
132
137
|
end
|
@@ -142,14 +147,16 @@ def download_archive(type)
|
|
142
147
|
end
|
143
148
|
|
144
149
|
def verify_archive(archive, type)
|
145
|
-
|
150
|
+
expected_checksum = ARCH_CONFIG[type]["checksum"]
|
151
|
+
actual_checksum = Digest::SHA256.hexdigest(archive.read)
|
152
|
+
if actual_checksum == expected_checksum
|
146
153
|
report["download"]["checksum"] = "verified"
|
147
154
|
true
|
148
155
|
else
|
149
156
|
report["download"]["checksum"] = "invalid"
|
150
157
|
abort_installation(
|
151
158
|
"Checksum of downloaded archive could not be verified: " \
|
152
|
-
"Expected '#{
|
159
|
+
"Expected '#{expected_checksum}', got '#{actual_checksum}'."
|
153
160
|
)
|
154
161
|
end
|
155
162
|
end
|
@@ -172,3 +179,7 @@ def store_download_version_on_report
|
|
172
179
|
path = File.expand_path(File.join(File.dirname(__FILE__), "appsignal.version"))
|
173
180
|
report["build"]["agent_version"] = File.read(path).strip
|
174
181
|
end
|
182
|
+
|
183
|
+
def http_proxy
|
184
|
+
Gem.configuration[:http_proxy] || ENV["http_proxy"] || ENV["HTTP_PROXY"]
|
185
|
+
end
|
data/lib/appsignal.rb
CHANGED
@@ -134,11 +134,17 @@ module Appsignal
|
|
134
134
|
|
135
135
|
if config[:enable_allocation_tracking] && !Appsignal::System.jruby?
|
136
136
|
Appsignal::Extension.install_allocation_event_hook
|
137
|
+
Appsignal::Environment.report_enabled("allocation_tracking")
|
137
138
|
end
|
138
139
|
|
139
|
-
|
140
|
+
if config[:enable_gc_instrumentation]
|
141
|
+
GC::Profiler.enable
|
142
|
+
Appsignal::Environment.report_enabled("gc_instrumentation")
|
143
|
+
end
|
140
144
|
|
141
145
|
Appsignal::Minutely.start if config[:enable_minutely_probes]
|
146
|
+
|
147
|
+
collect_environment_metadata
|
142
148
|
else
|
143
149
|
logger.info("Not starting, not active for #{config.env}")
|
144
150
|
end
|
@@ -309,9 +315,23 @@ module Appsignal
|
|
309
315
|
logger.warn "Unable to start logger with log path '#{path}'."
|
310
316
|
logger.warn error
|
311
317
|
end
|
318
|
+
|
319
|
+
def collect_environment_metadata
|
320
|
+
Appsignal::Environment.report("ruby_version") do
|
321
|
+
"#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
|
322
|
+
end
|
323
|
+
Appsignal::Environment.report("ruby_engine") { RUBY_ENGINE }
|
324
|
+
if defined?(RUBY_ENGINE_VERSION)
|
325
|
+
Appsignal::Environment.report("ruby_engine_version") do
|
326
|
+
RUBY_ENGINE_VERSION
|
327
|
+
end
|
328
|
+
end
|
329
|
+
Appsignal::Environment.report_supported_gems
|
330
|
+
end
|
312
331
|
end
|
313
332
|
end
|
314
333
|
|
334
|
+
require "appsignal/environment"
|
315
335
|
require "appsignal/system"
|
316
336
|
require "appsignal/utils"
|
317
337
|
require "appsignal/extension"
|
data/lib/appsignal/capistrano.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require "appsignal"
|
4
4
|
require "capistrano/version"
|
5
5
|
|
6
|
+
Appsignal::Environment.report_enabled("capistrano")
|
7
|
+
|
6
8
|
if defined?(Capistrano::VERSION) && Gem::Version.new(Capistrano::VERSION) >= Gem::Version.new(3)
|
7
9
|
# Capistrano 3+
|
8
10
|
load File.expand_path("../integrations/capistrano/appsignal.cap", __FILE__)
|
data/lib/appsignal/config.rb
CHANGED
@@ -18,6 +18,7 @@ module Appsignal
|
|
18
18
|
:ignore_namespaces => [],
|
19
19
|
:filter_parameters => [],
|
20
20
|
:filter_session_data => [],
|
21
|
+
:send_environment_metadata => true,
|
21
22
|
:send_params => true,
|
22
23
|
:request_headers => %w[
|
23
24
|
HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
|
@@ -62,6 +63,7 @@ module Appsignal
|
|
62
63
|
"APPSIGNAL_IGNORE_NAMESPACES" => :ignore_namespaces,
|
63
64
|
"APPSIGNAL_FILTER_PARAMETERS" => :filter_parameters,
|
64
65
|
"APPSIGNAL_FILTER_SESSION_DATA" => :filter_session_data,
|
66
|
+
"APPSIGNAL_SEND_ENVIRONMENT_METADATA" => :send_environment_metadata,
|
65
67
|
"APPSIGNAL_SEND_PARAMS" => :send_params,
|
66
68
|
"APPSIGNAL_HTTP_PROXY" => :http_proxy,
|
67
69
|
"APPSIGNAL_ENABLE_ALLOCATION_TRACKING" => :enable_allocation_tracking,
|
@@ -222,6 +224,7 @@ module Appsignal
|
|
222
224
|
ENV["_APPSIGNAL_DNS_SERVERS"] = config_hash[:dns_servers].join(",")
|
223
225
|
ENV["_APPSIGNAL_FILES_WORLD_ACCESSIBLE"] = config_hash[:files_world_accessible].to_s
|
224
226
|
ENV["_APPSIGNAL_TRANSACTION_DEBUG_MODE"] = config_hash[:transaction_debug_mode].to_s
|
227
|
+
ENV["_APPSIGNAL_SEND_ENVIRONMENT_METADATA"] = config_hash[:send_environment_metadata].to_s
|
225
228
|
ENV["_APP_REVISION"] = config_hash[:revision].to_s
|
226
229
|
end
|
227
230
|
|
@@ -337,8 +340,9 @@ module Appsignal
|
|
337
340
|
APPSIGNAL_SKIP_SESSION_DATA APPSIGNAL_ENABLE_FRONTEND_ERROR_CATCHING
|
338
341
|
APPSIGNAL_ENABLE_ALLOCATION_TRACKING APPSIGNAL_ENABLE_GC_INSTRUMENTATION
|
339
342
|
APPSIGNAL_RUNNING_IN_CONTAINER APPSIGNAL_ENABLE_HOST_METRICS
|
340
|
-
APPSIGNAL_SEND_PARAMS
|
341
|
-
APPSIGNAL_FILES_WORLD_ACCESSIBLE
|
343
|
+
APPSIGNAL_SEND_ENVIRONMENT_METADATA APPSIGNAL_SEND_PARAMS
|
344
|
+
APPSIGNAL_ENABLE_MINUTELY_PROBES APPSIGNAL_FILES_WORLD_ACCESSIBLE
|
345
|
+
APPSIGNAL_TRANSACTION_DEBUG_MODE].each do |var|
|
342
346
|
env_var = ENV[var]
|
343
347
|
next unless env_var
|
344
348
|
config[ENV_TO_KEY_MAPPING[var]] = env_var.casecmp("true").zero?
|
@@ -0,0 +1,126 @@
|
|
1
|
+
module Appsignal
|
2
|
+
# @api private
|
3
|
+
class Environment
|
4
|
+
# Add environment metadata.
|
5
|
+
#
|
6
|
+
# The key and value of the environment metadata must be a String, even if
|
7
|
+
# it's actually of another type.
|
8
|
+
#
|
9
|
+
# The value of the environment metadata is given as a block that captures
|
10
|
+
# errors that might be raised while fetching the value. It will not
|
11
|
+
# re-raise errors, but instead log them using the {Appsignal.logger}. This
|
12
|
+
# ensures AppSignal will not cause an error in the application when
|
13
|
+
# collecting this metadata.
|
14
|
+
#
|
15
|
+
# @example Reporting a key and value
|
16
|
+
# Appsignal::Environment.report("ruby_version") { RUBY_VERSION }
|
17
|
+
#
|
18
|
+
# @example When a value is nil
|
19
|
+
# Appsignal::Environment.report("ruby_version") { nil }
|
20
|
+
# # Key and value do not get reported. A warning gets logged instead.
|
21
|
+
#
|
22
|
+
# @example When an error occurs
|
23
|
+
# Appsignal::Environment.report("ruby_version") { raise "uh oh" }
|
24
|
+
# # Error does not get reraised. A warning gets logged instead.
|
25
|
+
#
|
26
|
+
# @param key [String] The name of the key of the environment metadata value.
|
27
|
+
# @yieldreturn [String] The value of the key of the environment metadata.
|
28
|
+
# @return [void]
|
29
|
+
def self.report(key)
|
30
|
+
key =
|
31
|
+
case key
|
32
|
+
when String
|
33
|
+
key
|
34
|
+
else
|
35
|
+
Appsignal.logger.error "Unable to report on environment metadata: " \
|
36
|
+
"Unsupported value type for #{key.inspect}"
|
37
|
+
return
|
38
|
+
end
|
39
|
+
|
40
|
+
yielded_value =
|
41
|
+
begin
|
42
|
+
yield
|
43
|
+
rescue => e
|
44
|
+
Appsignal.logger.error \
|
45
|
+
"Unable to report on environment metadata #{key.inspect}:\n" \
|
46
|
+
"#{e.class}: #{e}"
|
47
|
+
return
|
48
|
+
end
|
49
|
+
|
50
|
+
value =
|
51
|
+
case yielded_value
|
52
|
+
when TrueClass, FalseClass
|
53
|
+
yielded_value.to_s
|
54
|
+
when String
|
55
|
+
yielded_value
|
56
|
+
else
|
57
|
+
Appsignal.logger.error "Unable to report on environment metadata " \
|
58
|
+
"#{key.inspect}: Unsupported value type for " \
|
59
|
+
"#{yielded_value.inspect}"
|
60
|
+
return
|
61
|
+
end
|
62
|
+
|
63
|
+
Appsignal::Extension.set_environment_metadata(key, value)
|
64
|
+
rescue => e
|
65
|
+
Appsignal.logger.error "Unable to report on environment metadata:\n" \
|
66
|
+
"#{e.class}: #{e}"
|
67
|
+
end
|
68
|
+
|
69
|
+
# @see report_supported_gems
|
70
|
+
SUPPORTED_GEMS = %w[
|
71
|
+
actioncable
|
72
|
+
activejob
|
73
|
+
capistrano
|
74
|
+
celluloid
|
75
|
+
data_mapper
|
76
|
+
delayed_job
|
77
|
+
mongo_ruby_driver
|
78
|
+
padrino
|
79
|
+
passenger
|
80
|
+
puma
|
81
|
+
que
|
82
|
+
rack
|
83
|
+
rails
|
84
|
+
rake
|
85
|
+
redis
|
86
|
+
resque
|
87
|
+
sequel
|
88
|
+
shoryuken
|
89
|
+
sidekiq
|
90
|
+
sinatra
|
91
|
+
unicorn
|
92
|
+
webmachine
|
93
|
+
].freeze
|
94
|
+
|
95
|
+
# Report on the list of AppSignal supported gems
|
96
|
+
#
|
97
|
+
# This list is used to report if which AppSignal supported gems are present
|
98
|
+
# in this app and what version. This data will help AppSignal improve its
|
99
|
+
# support by knowing what gems and versions of gems it still needs to
|
100
|
+
# support or can drop support for.
|
101
|
+
#
|
102
|
+
# It will ask Bundler to report name and version information from the gems
|
103
|
+
# that are present in the app bundle.
|
104
|
+
def self.report_supported_gems
|
105
|
+
return unless defined?(Bundler) # Do nothing if Bundler is not present
|
106
|
+
|
107
|
+
bundle_gem_specs = ::Bundler.rubygems.all_specs
|
108
|
+
SUPPORTED_GEMS.each do |gem_name|
|
109
|
+
gem_spec = bundle_gem_specs.find { |spec| spec.name == gem_name }
|
110
|
+
next unless gem_spec
|
111
|
+
|
112
|
+
report("ruby_#{gem_name}_version") { gem_spec.version.to_s }
|
113
|
+
end
|
114
|
+
rescue => e
|
115
|
+
Appsignal.logger.error "Unable to report supported gems:\n" \
|
116
|
+
"#{e.class}: #{e}"
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.report_enabled(feature)
|
120
|
+
Appsignal::Environment.report("ruby_#{feature}_enabled") { true }
|
121
|
+
rescue => e
|
122
|
+
Appsignal.logger.error "Unable to report integration enabled:\n" \
|
123
|
+
"#{e.class}: #{e}"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|