appsignal 0.12.beta.34 → 0.12.beta.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/appsignal.gemspec +1 -12
- data/ext/agent.yml +11 -0
- data/ext/extconf.rb +60 -14
- data/lib/appsignal.rb +7 -3
- data/lib/appsignal/config.rb +1 -1
- data/lib/appsignal/extension.rb +60 -0
- data/lib/appsignal/version.rb +3 -2
- data/spec/lib/appsignal/config_spec.rb +1 -1
- data/spec/lib/appsignal/extension_spec.rb +44 -2
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfdb043df76d74ac83f045edd351aa8901330cdf
|
4
|
+
data.tar.gz: 7d67e984a04d00605f4e8bf53f2d47e70f81d963
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0611964579b4ee0c3dc5f31b5bcc13bf880390f328dee6c01de1cdc6715da9fde171ece1e31a505991a6dc0f7b0daee7eebe917243e657622b0b86faa6c96699
|
7
|
+
data.tar.gz: 0c95d1f4a335a979b9dae2e2f03cd6e18f3a5affca8ab1728e3a3ba96bea2143be0953a6c1d74d876654245e906eb66e82c6ea7e12bcadcd94cbfee8dd0bc106
|
data/appsignal.gemspec
CHANGED
@@ -4,10 +4,7 @@ require File.expand_path('../lib/appsignal/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = [
|
6
6
|
'Robert Beekman',
|
7
|
-
'
|
8
|
-
'Thijs Cadier',
|
9
|
-
'Ron Cadier',
|
10
|
-
'Jacob Vosmaer'
|
7
|
+
'Thijs Cadier'
|
11
8
|
]
|
12
9
|
gem.email = ['support@appsignal.com']
|
13
10
|
gem.description = 'The official appsignal.com gem'
|
@@ -34,12 +31,4 @@ Gem::Specification.new do |gem|
|
|
34
31
|
gem.add_development_dependency 'pry'
|
35
32
|
gem.add_development_dependency 'timecop'
|
36
33
|
gem.add_development_dependency 'webmock'
|
37
|
-
|
38
|
-
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
39
|
-
gem.add_development_dependency 'racc'
|
40
|
-
gem.add_development_dependency 'rubysl-enumerator'
|
41
|
-
gem.add_development_dependency 'rubysl-net-http'
|
42
|
-
gem.add_development_dependency 'rubysl-rexml'
|
43
|
-
gem.add_development_dependency 'rubysl-test-unit'
|
44
|
-
end
|
45
34
|
end
|
data/ext/agent.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
---
|
2
|
+
:version: c0f342f
|
3
|
+
:triples:
|
4
|
+
x86_64-linux:
|
5
|
+
:checksum: 34ec5169c4ed863a36c113a4bb78609ad77b8bd262d1607cc34ef0b809b6f7b4
|
6
|
+
:download_url: https://appsignal-agent-releases.global.ssl.fastly.net/c0f342f/appsignal-agent-x86_64-linux.tar.gz
|
7
|
+
:lib_filename: libappsignal.so
|
8
|
+
x86_64-darwin:
|
9
|
+
:checksum: 0ff18e87ea16c40cceda3677fee48e912ea9eeaca81c407935ea59e0fb45eeb4
|
10
|
+
:download_url: https://appsignal-agent-releases.global.ssl.fastly.net/c0f342f/appsignal-agent-x86_64-darwin.tar.gz
|
11
|
+
:lib_filename: libappsignal.dylib
|
data/ext/extconf.rb
CHANGED
@@ -1,23 +1,62 @@
|
|
1
|
+
require 'digest'
|
2
|
+
require 'logger'
|
1
3
|
require 'mkmf'
|
2
4
|
require 'fileutils'
|
3
5
|
require 'open-uri'
|
4
6
|
require 'zlib'
|
5
7
|
require 'rubygems/package'
|
8
|
+
require 'yaml'
|
6
9
|
require File.expand_path('../../lib/appsignal/version.rb', __FILE__)
|
7
10
|
|
8
|
-
|
9
|
-
|
11
|
+
EXT_PATH = File.expand_path('..', __FILE__)
|
12
|
+
AGENT_CONFIG = YAML.load(File.read(File.join(EXT_PATH, 'agent.yml')))
|
13
|
+
ARCH = "#{Gem::Platform.local.cpu}-#{Gem::Platform.local.os}"
|
10
14
|
|
11
15
|
def ext_path(path)
|
12
|
-
File.join(
|
16
|
+
File.join(EXT_PATH, path)
|
13
17
|
end
|
14
18
|
|
15
|
-
|
19
|
+
def logger
|
20
|
+
@logger ||= Logger.new(File.join(EXT_PATH, 'install.log'))
|
21
|
+
end
|
22
|
+
|
23
|
+
def installation_failed(reason)
|
24
|
+
logger.error "Installation failed: #{reason}"
|
25
|
+
File.open(File.join(EXT_PATH, 'Makefile'), 'w') do |file|
|
26
|
+
file.write "default:\nclean:\ninstall:"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def install
|
31
|
+
logger.info "Installing appsignal agent for Ruby #{RUBY_VERSION} on #{RUBY_PLATFORM}"
|
32
|
+
|
33
|
+
unless AGENT_CONFIG[:triples].keys.include?(ARCH)
|
34
|
+
installation_failed(
|
35
|
+
"AppSignal currently does not support your system architecture (#{ARCH})." \
|
36
|
+
"Please let us know at support@appsignal.com, we aim to support everything our customers run."
|
37
|
+
)
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
arch_config = AGENT_CONFIG[:triples][ARCH]
|
42
|
+
|
43
|
+
unless File.exists?(ext_path('appsignal-agent')) &&
|
44
|
+
File.exists?(ext_path(arch_config[:lib_filename])) &&
|
45
|
+
File.exists?(ext_path('appsignal_extension.h'))
|
46
|
+
logger.info "Downloading agent release from #{arch_config[:download_url]}"
|
47
|
+
|
48
|
+
archive = open(arch_config[:download_url])
|
49
|
+
|
50
|
+
if Digest::SHA256.hexdigest(archive.read) == arch_config[:checksum]
|
51
|
+
logger.info 'Checksum of downloaded archive verified, extracting archive'
|
52
|
+
else
|
53
|
+
installation_failed(
|
54
|
+
"Aborting installation, checksum of downloaded archive could not be verified: " \
|
55
|
+
"Expected '#{arch_config[:checksum]}', got '#{checksum}'."
|
56
|
+
)
|
57
|
+
return
|
58
|
+
end
|
16
59
|
|
17
|
-
if SUPPORTED_ARCHS.include?(arch)
|
18
|
-
if !File.exists?(ext_path('appsignal-agent')) || !File.exists?(ext_path('libappsignal.a'))
|
19
|
-
archive_url = "https://#{HOST}/#{Appsignal::AGENT_VERSION}/appsignal-agent-#{arch}.tar.gz"
|
20
|
-
archive = open(archive_url)
|
21
60
|
Gem::Package::TarReader.new(Zlib::GzipReader.open(archive)) do |tar|
|
22
61
|
tar.each do |entry|
|
23
62
|
if entry.file?
|
@@ -30,10 +69,17 @@ if SUPPORTED_ARCHS.include?(arch)
|
|
30
69
|
FileUtils.chmod(0755, ext_path('appsignal-agent'))
|
31
70
|
end
|
32
71
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
72
|
+
logger.info "Creating makefile"
|
73
|
+
if find_library('appsignal', 'appsignal_start', EXT_PATH) &&
|
74
|
+
find_executable('appsignal-agent', EXT_PATH) &&
|
75
|
+
find_header('appsignal_extension.h', EXT_PATH)
|
76
|
+
create_makefile 'appsignal_extension'
|
77
|
+
logger.info 'Successfully installed appsignal extension'
|
78
|
+
else
|
79
|
+
installation_failed "Aborting installation, extension files were not present"
|
80
|
+
end
|
81
|
+
rescue => ex
|
82
|
+
installation_failed "Exception while installing: #{ex}"
|
39
83
|
end
|
84
|
+
|
85
|
+
install
|
data/lib/appsignal.rb
CHANGED
@@ -10,7 +10,7 @@ end
|
|
10
10
|
|
11
11
|
module Appsignal
|
12
12
|
class << self
|
13
|
-
attr_accessor :config, :subscriber, :logger, :agent, :in_memory_log
|
13
|
+
attr_accessor :config, :subscriber, :logger, :agent, :in_memory_log, :extension_loaded
|
14
14
|
|
15
15
|
def load_integrations
|
16
16
|
require 'appsignal/integrations/celluloid'
|
@@ -198,8 +198,12 @@ module Appsignal
|
|
198
198
|
@logger << @in_memory_log.string if @in_memory_log
|
199
199
|
end
|
200
200
|
|
201
|
+
def extension_loaded?
|
202
|
+
!!@extension_loaded
|
203
|
+
end
|
204
|
+
|
201
205
|
def active?
|
202
|
-
config && config.active?
|
206
|
+
config && config.active? && extension_loaded?
|
203
207
|
end
|
204
208
|
|
205
209
|
def is_ignored_error?(error)
|
@@ -223,7 +227,7 @@ module Appsignal
|
|
223
227
|
end
|
224
228
|
end
|
225
229
|
|
226
|
-
require '
|
230
|
+
require 'appsignal/extension'
|
227
231
|
require 'appsignal/auth_check'
|
228
232
|
require 'appsignal/config'
|
229
233
|
require 'appsignal/event_formatter'
|
data/lib/appsignal/config.rb
CHANGED
@@ -75,7 +75,7 @@ module Appsignal
|
|
75
75
|
ENV['APPSIGNAL_AGENT_PATH'] = File.expand_path('../../../ext', __FILE__).to_s
|
76
76
|
ENV['APPSIGNAL_LOG_PATH'] = File.join(root_path, 'log')
|
77
77
|
ENV['APPSIGNAL_ENVIRONMENT'] = env
|
78
|
-
ENV['APPSIGNAL_AGENT_VERSION'] = Appsignal::
|
78
|
+
ENV['APPSIGNAL_AGENT_VERSION'] = Appsignal::ExtensionLoader.agent_version
|
79
79
|
ENV['APPSIGNAL_DEBUG_LOGGING'] = config_hash[:debug].to_s
|
80
80
|
ENV['APPSIGNAL_PUSH_API_ENDPOINT'] = config_hash[:endpoint]
|
81
81
|
ENV['APPSIGNAL_PUSH_API_KEY'] = config_hash[:push_api_key]
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Appsignal
|
2
|
+
module ExtensionLoader
|
3
|
+
def self.agent_config
|
4
|
+
@agent_config ||= YAML.load(
|
5
|
+
File.read(File.join(File.dirname(__FILE__), '../../ext/agent.yml'))
|
6
|
+
)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.arch
|
10
|
+
"#{Gem::Platform.local.cpu}-#{Gem::Platform.local.os}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.lib_path
|
14
|
+
File.join(
|
15
|
+
File.dirname(__FILE__),
|
16
|
+
'../../ext/',
|
17
|
+
agent_config[:triples][arch][:lib_filename]
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.agent_version
|
22
|
+
agent_config[:version]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.failed(exception)
|
26
|
+
Appsignal.logger.error(
|
27
|
+
"Failed to load extension (#{exception}), please check the install.log file in " \
|
28
|
+
"the ext directory of the gem and e-mail us at support@appsignal.com"
|
29
|
+
)
|
30
|
+
Appsignal.extension_loaded = false
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.load_extension
|
34
|
+
begin
|
35
|
+
require 'fiddle'
|
36
|
+
begin
|
37
|
+
Fiddle.dlopen(lib_path)
|
38
|
+
rescue => ex
|
39
|
+
failed(ex)
|
40
|
+
return
|
41
|
+
end
|
42
|
+
rescue LoadError
|
43
|
+
# This is Ruby 2.1 or older
|
44
|
+
require 'dl'
|
45
|
+
begin
|
46
|
+
DL.dlopen(lib_path)
|
47
|
+
rescue => ex
|
48
|
+
failed(ex)
|
49
|
+
return
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
require 'appsignal_extension'
|
54
|
+
|
55
|
+
Appsignal.extension_loaded = true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
Appsignal::ExtensionLoader.load_extension
|
data/lib/appsignal/version.rb
CHANGED
@@ -58,7 +58,7 @@ describe Appsignal::Config do
|
|
58
58
|
ENV['APPSIGNAL_PUSH_API_KEY'].should == 'abc'
|
59
59
|
ENV['APPSIGNAL_APP_NAME'].should == 'TestApp'
|
60
60
|
ENV['APPSIGNAL_ENVIRONMENT'].should == 'production'
|
61
|
-
ENV['APPSIGNAL_AGENT_VERSION'].should == Appsignal::
|
61
|
+
ENV['APPSIGNAL_AGENT_VERSION'].should == Appsignal::ExtensionLoader.agent_version
|
62
62
|
ENV['APPSIGNAL_HTTP_PROXY'].should == 'http://localhost'
|
63
63
|
ENV['APPSIGNAL_IGNORE_ACTIONS'].should == 'action1,action2'
|
64
64
|
end
|
@@ -1,9 +1,51 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
|
-
describe
|
4
|
-
|
4
|
+
describe "extension loading and operation" do
|
5
|
+
describe ".agent_config" do
|
6
|
+
subject { Appsignal::ExtensionLoader.agent_config }
|
7
|
+
|
8
|
+
it { should have_key(:version) }
|
9
|
+
it { should have_key(:triples) }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".arch" do
|
13
|
+
subject { Appsignal::ExtensionLoader.agent_config }
|
14
|
+
|
15
|
+
it { should_not be_nil }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ".agent_version" do
|
19
|
+
subject { Appsignal::ExtensionLoader.agent_version }
|
20
|
+
|
21
|
+
it { should_not be_nil }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when the extension library cannot be loaded" do
|
25
|
+
before do
|
26
|
+
Appsignal::ExtensionLoader.stub(:lib_path => '/tmp/nonsense')
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should log an error and set appsignal to inactive" do
|
30
|
+
Appsignal.logger.should_receive(:error).with(
|
31
|
+
'Failed to load extension (dlopen(/tmp/nonsense, 9): image not found), ' \
|
32
|
+
'please check the install.log file in the ext directory of the gem and e-mail us at support@appsignal.com'
|
33
|
+
)
|
34
|
+
|
35
|
+
Appsignal::ExtensionLoader.load_extension
|
36
|
+
|
37
|
+
Appsignal.extension_loaded?.should be_false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when the extension library can be loaded" do
|
5
42
|
subject { Appsignal::Extension }
|
6
43
|
|
44
|
+
it "should load the extension" do
|
45
|
+
Appsignal::ExtensionLoader.load_extension
|
46
|
+
Appsignal.extension_loaded?.should be_true
|
47
|
+
end
|
48
|
+
|
7
49
|
it "should have a start method" do
|
8
50
|
subject.start
|
9
51
|
end
|
metadata
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.beta.
|
4
|
+
version: 0.12.beta.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
8
|
-
- Steven Weller
|
9
8
|
- Thijs Cadier
|
10
|
-
- Ron Cadier
|
11
|
-
- Jacob Vosmaer
|
12
9
|
autorequire:
|
13
10
|
bindir: bin
|
14
11
|
cert_chain: []
|
15
|
-
date: 2015-09-
|
12
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
16
13
|
dependencies:
|
17
14
|
- !ruby/object:Gem::Dependency
|
18
15
|
name: rack
|
@@ -132,6 +129,7 @@ files:
|
|
132
129
|
- appsignal.gemspec
|
133
130
|
- benchmark.rake
|
134
131
|
- bin/appsignal
|
132
|
+
- ext/agent.yml
|
135
133
|
- ext/appsignal_extension.c
|
136
134
|
- ext/extconf.rb
|
137
135
|
- gemfiles/capistrano2.gemfile
|
@@ -156,6 +154,7 @@ files:
|
|
156
154
|
- lib/appsignal/event_formatter/active_record/sql_formatter.rb
|
157
155
|
- lib/appsignal/event_formatter/moped/query_formatter.rb
|
158
156
|
- lib/appsignal/event_formatter/net_http/request_formatter.rb
|
157
|
+
- lib/appsignal/extension.rb
|
159
158
|
- lib/appsignal/instrumentations/net_http.rb
|
160
159
|
- lib/appsignal/integrations/capistrano/appsignal.cap
|
161
160
|
- lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
|