appsignal 2.8.4.beta.1 → 2.9.18.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +31 -0
- data/.github/ISSUE_TEMPLATE/chore.md +14 -0
- data/.gitignore +2 -3
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +7 -16
- data/.travis.yml +28 -27
- data/CHANGELOG.md +657 -533
- data/README.md +31 -3
- data/Rakefile +128 -129
- data/SUPPORT.md +16 -0
- data/appsignal.gemspec +17 -4
- data/build_matrix.yml +21 -9
- data/ext/Rakefile +23 -17
- data/ext/agent.yml +40 -37
- data/ext/base.rb +116 -31
- data/ext/extconf.rb +34 -28
- data/gemfiles/capistrano2.gemfile +5 -0
- data/gemfiles/capistrano3.gemfile +5 -0
- data/gemfiles/grape.gemfile +5 -0
- data/gemfiles/no_dependencies.gemfile +5 -0
- data/gemfiles/padrino.gemfile +5 -0
- data/gemfiles/que.gemfile +5 -0
- data/gemfiles/que_beta.gemfile +10 -0
- data/gemfiles/rails-3.2.gemfile +5 -0
- data/gemfiles/rails-4.0.gemfile +5 -0
- data/gemfiles/rails-4.1.gemfile +5 -0
- data/gemfiles/rails-4.2.gemfile +5 -0
- data/gemfiles/rails-6.0.gemfile +5 -0
- data/gemfiles/resque.gemfile +5 -0
- data/lib/appsignal.rb +14 -492
- data/lib/appsignal/cli/demo.rb +5 -2
- data/lib/appsignal/cli/diagnose.rb +84 -4
- data/lib/appsignal/cli/diagnose/paths.rb +0 -5
- data/lib/appsignal/cli/diagnose/utils.rb +19 -0
- data/lib/appsignal/cli/helpers.rb +6 -0
- data/lib/appsignal/cli/install.rb +45 -15
- data/lib/appsignal/cli/notify_of_deploy.rb +10 -0
- data/lib/appsignal/config.rb +1 -2
- data/lib/appsignal/event_formatter.rb +4 -5
- data/lib/appsignal/event_formatter/action_view/render_formatter.rb +10 -8
- data/lib/appsignal/event_formatter/moped/query_formatter.rb +60 -59
- data/lib/appsignal/extension.rb +2 -2
- data/lib/appsignal/helpers/instrumentation.rb +494 -0
- data/lib/appsignal/helpers/metrics.rb +54 -0
- data/lib/appsignal/hooks.rb +11 -8
- data/lib/appsignal/hooks/active_support_notifications.rb +2 -5
- data/lib/appsignal/hooks/puma.rb +74 -11
- data/lib/appsignal/hooks/sequel.rb +1 -1
- data/lib/appsignal/hooks/sidekiq.rb +115 -0
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +7 -0
- data/lib/appsignal/integrations/que.rb +9 -8
- data/lib/appsignal/integrations/railtie.rb +2 -1
- data/lib/appsignal/marker.rb +2 -3
- data/lib/appsignal/minutely.rb +188 -19
- data/lib/appsignal/rack/sinatra_instrumentation.rb +1 -1
- data/lib/appsignal/system.rb +16 -18
- data/lib/appsignal/transaction.rb +8 -0
- data/lib/appsignal/utils/rails_helper.rb +20 -0
- data/lib/appsignal/version.rb +1 -1
- data/lib/puma/plugin/appsignal.rb +26 -0
- data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +40 -0
- data/spec/lib/appsignal/cli/diagnose_spec.rb +129 -22
- data/spec/lib/appsignal/cli/install_spec.rb +57 -8
- data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +10 -0
- data/spec/lib/appsignal/config_spec.rb +13 -11
- data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +38 -28
- data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +6 -0
- data/spec/lib/appsignal/event_formatter_spec.rb +168 -69
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +104 -25
- data/spec/lib/appsignal/hooks/puma_spec.rb +251 -34
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +209 -0
- data/spec/lib/appsignal/hooks_spec.rb +4 -0
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +24 -1
- data/spec/lib/appsignal/minutely_spec.rb +318 -26
- data/spec/lib/appsignal/system_spec.rb +0 -35
- data/spec/lib/appsignal/transaction_spec.rb +68 -10
- data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +39 -31
- data/spec/lib/appsignal/utils/json_spec.rb +7 -3
- data/spec/lib/appsignal_spec.rb +98 -22
- data/spec/lib/puma/appsignal_spec.rb +91 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/{project_fixture → fixtures/projects/valid}/config/application.rb +0 -0
- data/spec/support/{project_fixture → fixtures/projects/valid}/config/appsignal.yml +1 -0
- data/spec/support/{project_fixture → fixtures/projects/valid}/config/environments/development.rb +0 -0
- data/spec/support/{project_fixture → fixtures/projects/valid}/config/environments/production.rb +0 -0
- data/spec/support/{project_fixture → fixtures/projects/valid}/config/environments/test.rb +0 -0
- data/spec/support/{project_fixture → fixtures/projects/valid}/log/.gitkeep +0 -0
- data/spec/support/helpers/config_helpers.rb +1 -1
- data/spec/support/helpers/log_helpers.rb +6 -0
- data/spec/support/helpers/wait_for_helper.rb +28 -0
- data/spec/support/mocks/mock_probe.rb +11 -0
- data/spec/support/stubs/sidekiq/api.rb +4 -0
- metadata +43 -31
- data/spec/support/fixtures/containers/cgroups/docker +0 -14
- data/spec/support/fixtures/containers/cgroups/docker_systemd +0 -8
- data/spec/support/fixtures/containers/cgroups/lxc +0 -10
- data/spec/support/fixtures/containers/cgroups/no_permission +0 -0
- data/spec/support/fixtures/containers/cgroups/none +0 -1
data/ext/Rakefile
CHANGED
@@ -1,28 +1,34 @@
|
|
1
|
-
require File.expand_path("../../lib/appsignal/version.rb", __FILE__)
|
2
1
|
require File.expand_path("../base.rb", __FILE__)
|
3
2
|
|
3
|
+
def local_build?
|
4
|
+
File.exist?(ext_path("appsignal-agent")) &&
|
5
|
+
(
|
6
|
+
File.exist?(ext_path("libappsignal.dylib")) ||
|
7
|
+
File.exist?(ext_path("libappsignal.so"))
|
8
|
+
) &&
|
9
|
+
File.exist?(ext_path("appsignal.h"))
|
10
|
+
end
|
11
|
+
|
4
12
|
task :default do
|
5
13
|
begin
|
6
|
-
|
7
|
-
|
14
|
+
library_type = "dynamic"
|
15
|
+
report["language"]["implementation"] = "jruby"
|
16
|
+
report["build"]["library_type"] = library_type
|
8
17
|
next unless check_architecture
|
9
|
-
arch_config = AGENT_CONFIG["triples"][ARCH]
|
10
18
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
) &&
|
16
|
-
File.exist?(ext_path("appsignal.h"))
|
17
|
-
archive = download_archive(arch_config, "dynamic")
|
19
|
+
if local_build?
|
20
|
+
report["build"]["source"] = "local"
|
21
|
+
else
|
22
|
+
archive = download_archive(library_type)
|
18
23
|
next unless archive
|
19
|
-
next unless verify_archive(archive,
|
24
|
+
next unless verify_archive(archive, library_type)
|
20
25
|
unarchive(archive)
|
21
26
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
+
successful_installation
|
28
|
+
rescue => error
|
29
|
+
fail_installation_with_error(error)
|
30
|
+
ensure
|
31
|
+
create_dummy_makefile unless installation_succeeded?
|
32
|
+
write_report
|
27
33
|
end
|
28
34
|
end
|
data/ext/agent.yml
CHANGED
@@ -1,67 +1,70 @@
|
|
1
1
|
---
|
2
|
-
version:
|
2
|
+
version: c348132
|
3
|
+
mirrors:
|
4
|
+
- https://appsignal-agent-releases.global.ssl.fastly.net
|
5
|
+
- https://d135dj0rjqvssy.cloudfront.net
|
3
6
|
triples:
|
4
7
|
x86_64-darwin:
|
5
8
|
static:
|
6
|
-
checksum:
|
7
|
-
|
9
|
+
checksum: cb287c8e2072fe5b8cf14449bd6892989c392d0c651ce339895ae0302cb69785
|
10
|
+
filename: appsignal-x86_64-darwin-all-static.tar.gz
|
8
11
|
dynamic:
|
9
|
-
checksum:
|
10
|
-
|
12
|
+
checksum: af1ed2e9d29859ffbfc8e6903e4c51764dee94d7b4877ca8d30270b6f133a10f
|
13
|
+
filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
|
11
14
|
universal-darwin:
|
12
15
|
static:
|
13
|
-
checksum:
|
14
|
-
|
16
|
+
checksum: cb287c8e2072fe5b8cf14449bd6892989c392d0c651ce339895ae0302cb69785
|
17
|
+
filename: appsignal-x86_64-darwin-all-static.tar.gz
|
15
18
|
dynamic:
|
16
|
-
checksum:
|
17
|
-
|
19
|
+
checksum: af1ed2e9d29859ffbfc8e6903e4c51764dee94d7b4877ca8d30270b6f133a10f
|
20
|
+
filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
|
18
21
|
i686-linux:
|
19
22
|
static:
|
20
|
-
checksum:
|
21
|
-
|
23
|
+
checksum: 2c3bcd102592bf38fbdb27e7c70502dccbe54a0dc2739a9d54aaa694fcfb41fb
|
24
|
+
filename: appsignal-i686-linux-all-static.tar.gz
|
22
25
|
dynamic:
|
23
|
-
checksum:
|
24
|
-
|
26
|
+
checksum: 1c037b8370b755d706340e25d3e4b2f4acb279dd03873cc53bcf0a6ec0832653
|
27
|
+
filename: appsignal-i686-linux-all-dynamic.tar.gz
|
25
28
|
x86-linux:
|
26
29
|
static:
|
27
|
-
checksum:
|
28
|
-
|
30
|
+
checksum: 2c3bcd102592bf38fbdb27e7c70502dccbe54a0dc2739a9d54aaa694fcfb41fb
|
31
|
+
filename: appsignal-i686-linux-all-static.tar.gz
|
29
32
|
dynamic:
|
30
|
-
checksum:
|
31
|
-
|
33
|
+
checksum: 1c037b8370b755d706340e25d3e4b2f4acb279dd03873cc53bcf0a6ec0832653
|
34
|
+
filename: appsignal-i686-linux-all-dynamic.tar.gz
|
32
35
|
i686-linux-musl:
|
33
36
|
static:
|
34
|
-
checksum:
|
35
|
-
|
37
|
+
checksum: 0add9eed4452feda7fc5e1bbd0acdff32c353e4ea0b5d527959df57deb1bdcb2
|
38
|
+
filename: appsignal-i686-linux-musl-all-static.tar.gz
|
36
39
|
x86-linux-musl:
|
37
40
|
static:
|
38
|
-
checksum:
|
39
|
-
|
41
|
+
checksum: 0add9eed4452feda7fc5e1bbd0acdff32c353e4ea0b5d527959df57deb1bdcb2
|
42
|
+
filename: appsignal-i686-linux-musl-all-static.tar.gz
|
40
43
|
x86_64-linux:
|
41
44
|
static:
|
42
|
-
checksum:
|
43
|
-
|
45
|
+
checksum: d11221c127c00128da16b419c503281407e429c0ea6f5bfe1691640b8e995e4e
|
46
|
+
filename: appsignal-x86_64-linux-all-static.tar.gz
|
44
47
|
dynamic:
|
45
|
-
checksum:
|
46
|
-
|
48
|
+
checksum: 6869ab461fde55487d55805c396d55f36cb881998556f44236035b949939b0af
|
49
|
+
filename: appsignal-x86_64-linux-all-dynamic.tar.gz
|
47
50
|
x86_64-linux-musl:
|
48
51
|
static:
|
49
|
-
checksum:
|
50
|
-
|
52
|
+
checksum: 7ce44dc23c578933ca37a79d244bc367fdc2438408c2a61558adb92bcfebb1fa
|
53
|
+
filename: appsignal-x86_64-linux-musl-all-static.tar.gz
|
51
54
|
dynamic:
|
52
|
-
checksum:
|
53
|
-
|
55
|
+
checksum: 78d98f468e3a12cc09baff9e68bc4d9cd3b79f4a3bbe744036bff685415546a4
|
56
|
+
filename: appsignal-x86_64-linux-musl-all-dynamic.tar.gz
|
54
57
|
x86_64-freebsd:
|
55
58
|
static:
|
56
|
-
checksum:
|
57
|
-
|
59
|
+
checksum: df5f8b61e6ecca40f349cf5c83d5f37f031850d367793dee90dc56f13974431d
|
60
|
+
filename: appsignal-x86_64-freebsd-all-static.tar.gz
|
58
61
|
dynamic:
|
59
|
-
checksum:
|
60
|
-
|
62
|
+
checksum: 30d0303e97386014640c5b8194b777a5741e08ab5497ba58a7d8229bd4890fc5
|
63
|
+
filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
61
64
|
amd64-freebsd:
|
62
65
|
static:
|
63
|
-
checksum:
|
64
|
-
|
66
|
+
checksum: df5f8b61e6ecca40f349cf5c83d5f37f031850d367793dee90dc56f13974431d
|
67
|
+
filename: appsignal-x86_64-freebsd-all-static.tar.gz
|
65
68
|
dynamic:
|
66
|
-
checksum:
|
67
|
-
|
69
|
+
checksum: 30d0303e97386014640c5b8194b777a5741e08ab5497ba58a7d8229bd4890fc5
|
70
|
+
filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
data/ext/base.rb
CHANGED
@@ -1,77 +1,156 @@
|
|
1
1
|
require "digest"
|
2
|
-
require "logger"
|
3
2
|
require "fileutils"
|
4
3
|
require "open-uri"
|
5
4
|
require "zlib"
|
6
5
|
require "yaml"
|
7
6
|
require "rubygems/package"
|
7
|
+
require File.expand_path("../../lib/appsignal/version.rb", __FILE__)
|
8
8
|
require File.expand_path("../../lib/appsignal/system.rb", __FILE__)
|
9
9
|
|
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
|
-
|
14
|
-
ARCH
|
13
|
+
AGENT_PLATFORM = Appsignal::System.agent_platform
|
14
|
+
ARCH = "#{RbConfig::CONFIG["host_cpu"]}-#{AGENT_PLATFORM}".freeze
|
15
|
+
ARCH_CONFIG = AGENT_CONFIG["triples"][ARCH].freeze
|
15
16
|
CA_CERT_PATH = File.join(EXT_PATH, "../resources/cacert.pem").freeze
|
16
17
|
|
17
18
|
def ext_path(path)
|
18
19
|
File.join(EXT_PATH, path)
|
19
20
|
end
|
20
21
|
|
21
|
-
def
|
22
|
-
@
|
22
|
+
def report
|
23
|
+
@report ||=
|
24
|
+
begin
|
25
|
+
rbconfig = RbConfig::CONFIG
|
26
|
+
{
|
27
|
+
"result" => {
|
28
|
+
"status" => "incomplete"
|
29
|
+
},
|
30
|
+
"language" => {
|
31
|
+
"name" => "ruby",
|
32
|
+
"version" => "#{rbconfig["ruby_version"]}-p#{rbconfig["PATCHLEVEL"]}"
|
33
|
+
},
|
34
|
+
"download" => {
|
35
|
+
"checksum" => "unverified"
|
36
|
+
},
|
37
|
+
"build" => {
|
38
|
+
"time" => Time.now.utc,
|
39
|
+
"package_path" => File.dirname(EXT_PATH),
|
40
|
+
"architecture" => rbconfig["host_cpu"],
|
41
|
+
"target" => AGENT_PLATFORM,
|
42
|
+
"musl_override" => Appsignal::System.force_musl_build?,
|
43
|
+
"dependencies" => {},
|
44
|
+
"flags" => {}
|
45
|
+
},
|
46
|
+
"host" => {
|
47
|
+
"root_user" => Process.uid.zero?,
|
48
|
+
"dependencies" => {}.tap do |d|
|
49
|
+
ldd_output = Appsignal::System.ldd_version_output
|
50
|
+
ldd_version = Appsignal::System.extract_ldd_version(ldd_output)
|
51
|
+
d["libc"] = ldd_version if ldd_version
|
52
|
+
end
|
53
|
+
}
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def write_report
|
59
|
+
File.open(File.join(EXT_PATH, "install.report"), "w") do |file|
|
60
|
+
file.write YAML.dump(report)
|
61
|
+
end
|
23
62
|
end
|
24
63
|
|
25
|
-
def
|
26
|
-
logger.error "Installation failed: #{reason}"
|
64
|
+
def create_dummy_makefile
|
27
65
|
File.open(File.join(EXT_PATH, "Makefile"), "w") do |file|
|
28
66
|
file.write "default:\nclean:\ninstall:"
|
29
67
|
end
|
30
68
|
end
|
31
69
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
70
|
+
def successful_installation
|
71
|
+
report["result"] = { "status" => "success" }
|
72
|
+
end
|
73
|
+
|
74
|
+
def abort_installation(reason)
|
75
|
+
report["result"] = {
|
76
|
+
"status" => "failed",
|
77
|
+
"message" => reason
|
78
|
+
}
|
79
|
+
false
|
80
|
+
end
|
81
|
+
|
82
|
+
def fail_installation_with_error(error)
|
83
|
+
report["result"] = {
|
84
|
+
"status" => "error",
|
85
|
+
"error" => "#{error.class}: #{error}",
|
86
|
+
"backtrace" => error.backtrace
|
87
|
+
}
|
88
|
+
false
|
89
|
+
end
|
90
|
+
|
91
|
+
def installation_succeeded?
|
92
|
+
report["result"]["status"] == "success"
|
36
93
|
end
|
37
94
|
|
38
95
|
def check_architecture
|
39
96
|
if AGENT_CONFIG["triples"].key?(ARCH)
|
40
97
|
true
|
41
98
|
else
|
42
|
-
|
99
|
+
abort_installation(
|
43
100
|
"AppSignal currently does not support your system architecture (#{ARCH})." \
|
44
|
-
|
101
|
+
"Please let us know at support@appsignal.com, we aim to support everything our customers run."
|
45
102
|
)
|
46
|
-
false
|
47
103
|
end
|
48
104
|
end
|
49
105
|
|
50
|
-
def download_archive(
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
installation_failed(
|
106
|
+
def download_archive(type)
|
107
|
+
report["build"]["source"] = "remote"
|
108
|
+
|
109
|
+
unless ARCH_CONFIG.key?(type)
|
110
|
+
abort_installation(
|
56
111
|
"AppSignal currently does not support your system. " \
|
57
|
-
|
58
|
-
|
59
|
-
|
112
|
+
"Expected config for architecture '#{arch}' and package type '#{type}', but none found. " \
|
113
|
+
"For a full list of supported systems visit: " \
|
114
|
+
"https://docs.appsignal.com/support/operating-systems.html"
|
60
115
|
)
|
61
|
-
|
116
|
+
return
|
117
|
+
end
|
118
|
+
|
119
|
+
version = AGENT_CONFIG["version"]
|
120
|
+
filename = ARCH_CONFIG[type]["filename"]
|
121
|
+
attempted_mirror_urls = []
|
122
|
+
|
123
|
+
AGENT_CONFIG["mirrors"].each do |mirror|
|
124
|
+
download_url = [mirror, version, filename].join("/")
|
125
|
+
attempted_mirror_urls << download_url
|
126
|
+
report["download"]["download_url"] = download_url
|
127
|
+
|
128
|
+
begin
|
129
|
+
return open(download_url, :ssl_ca_cert => CA_CERT_PATH)
|
130
|
+
rescue
|
131
|
+
next
|
132
|
+
end
|
62
133
|
end
|
134
|
+
|
135
|
+
attempted_mirror_urls_mapped = attempted_mirror_urls.map { |mirror| "- #{mirror}" }
|
136
|
+
abort_installation(
|
137
|
+
"Could not download archive from any of our mirrors. " \
|
138
|
+
"Attempted to download the archive from the following urls:\n" \
|
139
|
+
"#{attempted_mirror_urls_mapped.join("\n")}\n" \
|
140
|
+
"Please make sure your network allows access to any of these mirrors."
|
141
|
+
)
|
63
142
|
end
|
64
143
|
|
65
|
-
def verify_archive(archive,
|
66
|
-
if Digest::SHA256.hexdigest(archive.read) ==
|
67
|
-
|
144
|
+
def verify_archive(archive, type)
|
145
|
+
if Digest::SHA256.hexdigest(archive.read) == ARCH_CONFIG[type]["checksum"]
|
146
|
+
report["download"]["checksum"] = "verified"
|
68
147
|
true
|
69
148
|
else
|
70
|
-
|
71
|
-
|
72
|
-
"
|
149
|
+
report["download"]["checksum"] = "invalid"
|
150
|
+
abort_installation(
|
151
|
+
"Checksum of downloaded archive could not be verified: " \
|
152
|
+
"Expected '#{ARCH_CONFIG[type]["checksum"]}', got '#{checksum}'."
|
73
153
|
)
|
74
|
-
false
|
75
154
|
end
|
76
155
|
end
|
77
156
|
|
@@ -85,5 +164,11 @@ def unarchive(archive)
|
|
85
164
|
end
|
86
165
|
end
|
87
166
|
end
|
167
|
+
store_download_version_on_report
|
88
168
|
FileUtils.chmod(0o755, ext_path("appsignal-agent"))
|
89
169
|
end
|
170
|
+
|
171
|
+
def store_download_version_on_report
|
172
|
+
path = File.expand_path(File.join(File.dirname(__FILE__), "appsignal.version"))
|
173
|
+
report["build"]["agent_version"] = File.read(path).strip
|
174
|
+
end
|
data/ext/extconf.rb
CHANGED
@@ -1,35 +1,38 @@
|
|
1
|
-
require File.expand_path("../../lib/appsignal/version.rb", __FILE__)
|
2
1
|
require File.expand_path("../base.rb", __FILE__)
|
3
2
|
|
4
|
-
def
|
5
|
-
|
6
|
-
|
3
|
+
def local_build?
|
4
|
+
File.exist?(ext_path("appsignal-agent")) &&
|
5
|
+
File.exist?(ext_path("libappsignal.a")) &&
|
6
|
+
File.exist?(ext_path("appsignal.h"))
|
7
|
+
end
|
8
|
+
|
9
|
+
def install
|
10
|
+
library_type = "static"
|
11
|
+
report["language"]["implementation"] = "ruby"
|
12
|
+
report["build"]["library_type"] = library_type
|
7
13
|
return unless check_architecture
|
8
|
-
arch_config = AGENT_CONFIG["triples"][ARCH]
|
9
14
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
archive = download_archive(
|
15
|
+
if local_build?
|
16
|
+
report["build"]["source"] = "local"
|
17
|
+
else
|
18
|
+
archive = download_archive(library_type)
|
14
19
|
return unless archive
|
15
|
-
return unless verify_archive(archive,
|
20
|
+
return unless verify_archive(archive, library_type)
|
16
21
|
unarchive(archive)
|
17
22
|
end
|
18
23
|
|
19
24
|
is_linux_system = [
|
20
25
|
Appsignal::System::LINUX_TARGET,
|
21
26
|
Appsignal::System::MUSL_TARGET
|
22
|
-
].include?(
|
27
|
+
].include?(AGENT_PLATFORM)
|
23
28
|
|
24
|
-
logger.info "Creating makefile"
|
25
29
|
require "mkmf"
|
26
|
-
|
27
30
|
link_libraries if is_linux_system
|
28
31
|
|
29
32
|
if !have_library("appsignal", "appsignal_start", "appsignal.h")
|
30
|
-
|
33
|
+
abort_installation("Library libappsignal.a or appsignal.h not found")
|
31
34
|
elsif !find_executable("appsignal-agent", EXT_PATH)
|
32
|
-
|
35
|
+
abort_installation("File appsignal-agent not found")
|
33
36
|
else
|
34
37
|
if is_linux_system
|
35
38
|
# Statically link libgcc and libgcc_s libraries.
|
@@ -38,15 +41,16 @@ def install # rubocop:disable Metrics/CyclomaticComplexity
|
|
38
41
|
# run on one that isn't the missing libraries will cause the extension
|
39
42
|
# to fail on start.
|
40
43
|
$LDFLAGS += " -static-libgcc" # rubocop:disable Style/GlobalVars
|
44
|
+
report["build"]["flags"]["LDFLAGS"] = $LDFLAGS # rubocop:disable Style/GlobalVars
|
41
45
|
end
|
42
46
|
create_makefile "appsignal_extension"
|
43
|
-
|
44
|
-
end
|
45
|
-
rescue => ex
|
46
|
-
installation_failed "Exception while installing: #{ex}"
|
47
|
-
ex.backtrace.each do |line|
|
48
|
-
logger.error line
|
47
|
+
successful_installation
|
49
48
|
end
|
49
|
+
rescue => error
|
50
|
+
fail_installation_with_error(error)
|
51
|
+
ensure
|
52
|
+
create_dummy_makefile unless installation_succeeded?
|
53
|
+
write_report
|
50
54
|
end
|
51
55
|
|
52
56
|
# Ruby 2.6 requires us to statically link more libraries we use in our
|
@@ -54,26 +58,28 @@ end
|
|
54
58
|
# and musl builds.
|
55
59
|
def link_libraries
|
56
60
|
if RbConfig::CONFIG["THREAD_MODEL"] == "pthread"
|
57
|
-
logger.info "Linking extension against 'pthread' library"
|
58
61
|
# Link gem extension against pthread library
|
59
62
|
have_library "pthread"
|
60
|
-
have_required_function "pthread_create"
|
63
|
+
have_required_function "pthread", "pthread_create"
|
61
64
|
end
|
62
65
|
|
63
66
|
# Links gem extension against the `dl` library. This is needed when Ruby is
|
64
67
|
# not linked against `dl` itself, so link it on the gem extension.
|
65
|
-
logger.info "Linking extension against 'dl' library"
|
66
68
|
have_library "dl"
|
67
69
|
# Check if functions are available now from the linked library
|
68
70
|
%w[dlopen dlclose dlsym].each do |func|
|
69
|
-
have_required_function func
|
71
|
+
have_required_function "dl", func
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
73
|
-
def have_required_function(func) # rubocop:disable Naming/PredicateName
|
74
|
-
|
75
|
+
def have_required_function(library, func) # rubocop:disable Naming/PredicateName
|
76
|
+
if have_func(func)
|
77
|
+
report["build"]["dependencies"][library] = "linked"
|
78
|
+
return
|
79
|
+
end
|
75
80
|
|
76
|
-
|
81
|
+
report["build"]["dependencies"][library] = "not linked"
|
82
|
+
abort_installation("Missing function '#{func}'")
|
77
83
|
# Exit with true/0/success because the AppSignal installation should never
|
78
84
|
# break a build
|
79
85
|
exit
|