appsignal 0.11.18 → 0.12.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/CHANGELOG.md +4 -38
- data/Rakefile +14 -6
- data/appsignal.gemspec +3 -1
- data/benchmark.rake +12 -16
- data/ext/appsignal_extension.c +183 -0
- data/ext/extconf.rb +39 -0
- data/gemfiles/capistrano2.gemfile +0 -1
- data/gemfiles/capistrano3.gemfile +0 -1
- data/gemfiles/rails-4.2.gemfile +1 -1
- data/lib/appsignal.rb +23 -61
- data/lib/appsignal/capistrano.rb +1 -2
- data/lib/appsignal/config.rb +13 -1
- data/lib/appsignal/event_formatter.rb +67 -0
- data/lib/appsignal/event_formatter/action_view/render_formatter.rb +23 -0
- data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +74 -0
- data/lib/appsignal/event_formatter/moped/query_formatter.rb +80 -0
- data/lib/appsignal/event_formatter/net_http/request_formatter.rb +13 -0
- data/lib/appsignal/instrumentations/net_http.rb +6 -4
- data/lib/appsignal/integrations/resque.rb +2 -10
- data/lib/appsignal/integrations/sidekiq.rb +2 -2
- data/lib/appsignal/integrations/sinatra.rb +1 -0
- data/lib/appsignal/js_exception_transaction.rb +44 -28
- data/lib/appsignal/marker.rb +11 -13
- data/lib/appsignal/params_sanitizer.rb +5 -8
- data/lib/appsignal/rack/instrumentation.rb +2 -0
- data/lib/appsignal/rack/js_exception_catcher.rb +1 -0
- data/lib/appsignal/rack/listener.rb +1 -1
- data/lib/appsignal/rack/sinatra_instrumentation.rb +2 -12
- data/lib/appsignal/subscriber.rb +59 -0
- data/lib/appsignal/transaction.rb +117 -174
- data/lib/appsignal/transmitter.rb +8 -37
- data/lib/appsignal/version.rb +2 -1
- data/spec/lib/appsignal/config_spec.rb +25 -4
- data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +42 -0
- data/spec/lib/appsignal/{aggregator/middleware/active_record_sanitizer_spec.rb → event_formatter/active_record/sql_formatter_spec.rb} +61 -61
- data/spec/lib/appsignal/{event/moped_event_spec.rb → event_formatter/moped/query_formatter_spec.rb} +32 -78
- data/spec/lib/appsignal/event_formatter/net_http/request_formatter_spec.rb +26 -0
- data/spec/lib/appsignal/event_formatter_spec.rb +102 -0
- data/spec/lib/appsignal/extension_spec.rb +75 -0
- data/spec/lib/appsignal/instrumentations/net_http_spec.rb +20 -4
- data/spec/lib/appsignal/integrations/delayed_job_spec.rb +3 -2
- data/spec/lib/appsignal/integrations/rails_spec.rb +0 -7
- data/spec/lib/appsignal/integrations/resque_spec.rb +51 -55
- data/spec/lib/appsignal/integrations/sequel_spec.rb +8 -3
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +4 -21
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -6
- data/spec/lib/appsignal/js_exception_transaction_spec.rb +57 -60
- data/spec/lib/appsignal/params_sanitizer_spec.rb +11 -27
- data/spec/lib/appsignal/rack/listener_spec.rb +6 -6
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +2 -43
- data/spec/lib/appsignal/subscriber_spec.rb +162 -0
- data/spec/lib/appsignal/transaction_spec.rb +283 -615
- data/spec/lib/appsignal/transmitter_spec.rb +3 -32
- data/spec/lib/appsignal_spec.rb +41 -90
- data/spec/lib/generators/appsignal/appsignal_generator_spec.rb +0 -17
- data/spec/spec_helper.rb +18 -22
- data/spec/support/helpers/notification_helpers.rb +1 -1
- data/spec/support/helpers/time_helpers.rb +11 -0
- data/spec/support/helpers/transaction_helpers.rb +6 -18
- data/spec/support/project_fixture/config/appsignal.yml +1 -2
- metadata +68 -78
- checksums.yaml +0 -7
- data/gemfiles/padrino-0.13.gemfile +0 -7
- data/gemfiles/resque.gemfile +0 -5
- data/lib/appsignal/agent.rb +0 -217
- data/lib/appsignal/aggregator.rb +0 -67
- data/lib/appsignal/aggregator/middleware.rb +0 -4
- data/lib/appsignal/aggregator/middleware/action_view_sanitizer.rb +0 -23
- data/lib/appsignal/aggregator/middleware/active_record_sanitizer.rb +0 -65
- data/lib/appsignal/aggregator/middleware/chain.rb +0 -101
- data/lib/appsignal/aggregator/middleware/delete_blanks.rb +0 -16
- data/lib/appsignal/aggregator/post_processor.rb +0 -32
- data/lib/appsignal/event.rb +0 -20
- data/lib/appsignal/event/moped_event.rb +0 -90
- data/lib/appsignal/integrations/padrino.rb +0 -64
- data/lib/appsignal/integrations/passenger.rb +0 -13
- data/lib/appsignal/integrations/rake.rb +0 -29
- data/lib/appsignal/integrations/unicorn.rb +0 -25
- data/lib/appsignal/ipc.rb +0 -68
- data/lib/appsignal/transaction/formatter.rb +0 -85
- data/lib/appsignal/transaction/params_sanitizer.rb +0 -4
- data/lib/appsignal/zipped_payload.rb +0 -37
- data/spec/lib/appsignal/agent_spec.rb +0 -592
- data/spec/lib/appsignal/aggregator/middleware/action_view_sanitizer_spec.rb +0 -44
- data/spec/lib/appsignal/aggregator/middleware/chain_spec.rb +0 -168
- data/spec/lib/appsignal/aggregator/middleware/delete_blanks_spec.rb +0 -37
- data/spec/lib/appsignal/aggregator/post_processor_spec.rb +0 -99
- data/spec/lib/appsignal/aggregator_spec.rb +0 -186
- data/spec/lib/appsignal/event_spec.rb +0 -48
- data/spec/lib/appsignal/integrations/padrino_spec.rb +0 -171
- data/spec/lib/appsignal/integrations/passenger_spec.rb +0 -22
- data/spec/lib/appsignal/integrations/rake_spec.rb +0 -92
- data/spec/lib/appsignal/integrations/unicorn_spec.rb +0 -48
- data/spec/lib/appsignal/ipc_spec.rb +0 -128
- data/spec/lib/appsignal/transaction/formatter_spec.rb +0 -247
- data/spec/lib/appsignal/zipped_payload_spec.rb +0 -42
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,39 +1,7 @@
|
|
1
|
-
# 0.
|
2
|
-
*
|
3
|
-
*
|
4
|
-
|
5
|
-
# 0.11.17
|
6
|
-
* Fix for bug using rack request in `send_exception`
|
7
|
-
|
8
|
-
# 0.11.16
|
9
|
-
* Send tags passed to the frontend error catcher
|
10
|
-
* Fix issue with ActiveAdmin sending incompatible instrumentation events
|
11
|
-
|
12
|
-
# 0.11.15
|
13
|
-
* Improve Sinatra support
|
14
|
-
|
15
|
-
# 0.11.14
|
16
|
-
* Support ActiveJob wrapped jobs
|
17
|
-
* Improve proxy support
|
18
|
-
* Improve rake support
|
19
|
-
|
20
|
-
# 0.11.13
|
21
|
-
* Add Padrino support
|
22
|
-
* Add Rake task monitoring
|
23
|
-
* Add http proxy support
|
24
|
-
* Configure Net::HTTP to only use TLS
|
25
|
-
* Don't send queue if there is no content
|
26
|
-
* Don't retry transmission when response code is 400 (no content)
|
27
|
-
* Don't start Resque IPC server when AppSignal is not active
|
28
|
-
* Display warning message when attempting to send a non-exception to `send_exception`
|
29
|
-
* Fix capistrano 2 detection
|
30
|
-
* Fix issue with Sinatra integration attempting to attach an exception to a transaction that doesn't exist.
|
31
|
-
|
32
|
-
# 0.11.12
|
33
|
-
* Sanitizer will no longer inspect unknown objects, since implementations of inspect sometimes trigger unexpected behavior.
|
34
|
-
|
35
|
-
# 0.11.11
|
36
|
-
* Reliably get errors in production for Sinatra
|
1
|
+
# 0.12.0
|
2
|
+
* New version of event formatting and collection
|
3
|
+
* Use native library and agent
|
4
|
+
* Use API V2
|
37
5
|
|
38
6
|
# 0.11.10
|
39
7
|
* Fix for binding bug in exceptions in Resque
|
@@ -47,8 +15,6 @@
|
|
47
15
|
* Add background job metadata (queue, priority etc.) to transaction overview
|
48
16
|
* Add APPSIGNAL_APP_ENV variable to Rails config, so you can override the environment
|
49
17
|
* Handle http queue times in microseconds too
|
50
|
-
* Use less memory when retrying transmissions and don't retry if there's
|
51
|
-
a queue on shutdown
|
52
18
|
|
53
19
|
# 0.11.7
|
54
20
|
* Add option to override Job name in Delayed Job
|
data/Rakefile
CHANGED
@@ -10,15 +10,13 @@ GEMFILES = %w(
|
|
10
10
|
rails-4.2
|
11
11
|
sequel
|
12
12
|
sinatra
|
13
|
-
resque
|
14
13
|
)
|
15
14
|
|
16
15
|
RUBY_VERSIONS = %w(
|
17
16
|
1.9.3-p429
|
18
17
|
2.0.0-p451
|
19
18
|
2.1.2
|
20
|
-
|
21
|
-
rbx-2.2.9
|
19
|
+
2.2.0
|
22
20
|
)
|
23
21
|
|
24
22
|
VERSION_MANAGERS = {
|
@@ -49,8 +47,8 @@ task :publish do
|
|
49
47
|
puts `git tag #{version}`
|
50
48
|
puts `git push origin #{version}`
|
51
49
|
puts `git push appsignal #{version}`
|
52
|
-
puts `git push origin
|
53
|
-
puts `git push appsignal
|
50
|
+
puts `git push origin #{branch}`
|
51
|
+
puts `git push appsignal #{branch}`
|
54
52
|
rescue
|
55
53
|
raise "Tag: '#{version}' already exists"
|
56
54
|
end
|
@@ -68,6 +66,16 @@ task :publish do
|
|
68
66
|
@version ||= 'v' << gem_version
|
69
67
|
end
|
70
68
|
|
69
|
+
def branch
|
70
|
+
if gem_version.include?('alpha') ||
|
71
|
+
gem_version.include?('beta') ||
|
72
|
+
gem_version.include?('rc')
|
73
|
+
'develop'
|
74
|
+
else
|
75
|
+
'master'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
71
79
|
def git_status_to_array(changes)
|
72
80
|
changes.split("\n").each { |change| change.gsub!(/^.. /,'') }
|
73
81
|
end
|
@@ -108,11 +116,11 @@ task :generate_bundle_and_spec_all do
|
|
108
116
|
out << '#!/bin/sh'
|
109
117
|
end
|
110
118
|
out << 'rm -f .ruby-version'
|
111
|
-
|
112
119
|
out << "echo 'Using #{version_manager}'"
|
113
120
|
RUBY_VERSIONS.each do |version|
|
114
121
|
out << "echo 'Switching to #{version}'"
|
115
122
|
out << "#{switch_command} #{version} || { echo 'Switching Ruby failed'; exit 1; }"
|
123
|
+
out << 'cd ext && ruby extconf.rb && make clean && make && cd ..'
|
116
124
|
GEMFILES.each do |gemfile|
|
117
125
|
out << "echo 'Bundling #{gemfile} in #{version}'"
|
118
126
|
out << "bundle --quiet --gemfile gemfiles/#{gemfile}.gemfile || { echo 'Bundling failed'; exit 1; }"
|
data/appsignal.gemspec
CHANGED
@@ -20,10 +20,12 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
21
21
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
22
22
|
gem.name = 'appsignal'
|
23
|
-
gem.require_paths = ['lib']
|
23
|
+
gem.require_paths = ['lib', 'ext']
|
24
24
|
gem.version = Appsignal::VERSION
|
25
25
|
gem.required_ruby_version = '>= 1.9'
|
26
26
|
|
27
|
+
gem.extensions = %w(ext/extconf.rb)
|
28
|
+
|
27
29
|
gem.add_dependency 'rack'
|
28
30
|
gem.add_dependency 'thread_safe'
|
29
31
|
|
data/benchmark.rake
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'appsignal'
|
2
2
|
require 'benchmark'
|
3
3
|
|
4
|
-
class ::Appsignal::
|
4
|
+
class ::Appsignal::EventFormatter::ActiveRecord::SqlFormatter
|
5
5
|
def connection_config; {:adapter => 'mysql'}; end
|
6
6
|
end
|
7
7
|
|
@@ -14,11 +14,7 @@ namespace :benchmark do
|
|
14
14
|
task :run_inactive do
|
15
15
|
puts 'Running with appsignal off'
|
16
16
|
ENV['APPSIGNAL_PUSH_API_KEY'] = nil
|
17
|
-
subscriber = ActiveSupport::Notifications.subscribe do |*args|
|
18
|
-
# Add a subscriber so we can track the overhead of just appsignal
|
19
|
-
end
|
20
17
|
run_benchmark
|
21
|
-
ActiveSupport::Notifications.unsubscribe(subscriber)
|
22
18
|
end
|
23
19
|
|
24
20
|
task :run_active do
|
@@ -29,18 +25,24 @@ namespace :benchmark do
|
|
29
25
|
end
|
30
26
|
|
31
27
|
def run_benchmark
|
28
|
+
no_transactions = 10_000
|
29
|
+
|
32
30
|
total_objects = ObjectSpace.count_objects[:TOTAL]
|
33
31
|
puts "Initializing, currently #{total_objects} objects"
|
34
|
-
|
32
|
+
|
33
|
+
Appsignal.config = Appsignal::Config.new(Dir.pwd, 'production', :endpoint => 'http://localhost:8080')
|
35
34
|
Appsignal.start
|
36
35
|
puts "Appsignal #{Appsignal.active? ? 'active' : 'not active'}"
|
37
36
|
|
38
|
-
puts
|
37
|
+
puts "Running #{no_transactions} normal transactions"
|
39
38
|
puts(Benchmark.measure do
|
40
|
-
|
39
|
+
no_transactions.times do |i|
|
40
|
+
transaction_id = "transaction_#{i}"
|
41
|
+
ActiveSupport::Notifications.instrumenter.instance_variable_set(:@id, transaction_id)
|
41
42
|
Appsignal::Transaction.create("transaction_#{i}", {})
|
42
43
|
|
43
|
-
ActiveSupport::Notifications.instrument('sql.active_record', :sql => 'SELECT `users`.* FROM `users`
|
44
|
+
ActiveSupport::Notifications.instrument('sql.active_record', :sql => 'SELECT `users`.* FROM `users`
|
45
|
+
WHERE `users`.`id` = ?')
|
44
46
|
10.times do
|
45
47
|
ActiveSupport::Notifications.instrument('sql.active_record', :sql => 'SELECT `todos`.* FROM `todos` WHERE `todos`.`id` = ?')
|
46
48
|
end
|
@@ -64,14 +66,8 @@ def run_benchmark
|
|
64
66
|
|
65
67
|
Appsignal::Transaction.complete_current!
|
66
68
|
end
|
69
|
+
puts 'Finished'
|
67
70
|
end)
|
68
71
|
|
69
|
-
if Appsignal.active?
|
70
|
-
puts "Running aggregator post_processed_queue! for #{Appsignal.agent.aggregator.queue.length} transactions"
|
71
|
-
puts(Benchmark.measure do
|
72
|
-
Appsignal.agent.aggregator.post_processed_queue!.to_json
|
73
|
-
end)
|
74
|
-
end
|
75
|
-
|
76
72
|
puts "Done, currently #{ObjectSpace.count_objects[:TOTAL] - total_objects} objects created"
|
77
73
|
end
|
@@ -0,0 +1,183 @@
|
|
1
|
+
#include<ruby.h>
|
2
|
+
|
3
|
+
void appsignal_start(void);
|
4
|
+
void appsignal_start_transaction(char *);
|
5
|
+
void appsignal_start_event(char *);
|
6
|
+
void appsignal_finish_event(char *, char *, char *, char *);
|
7
|
+
void appsignal_set_transaction_error(char *, char *, char *);
|
8
|
+
void appsignal_set_transaction_error_data(char *, char *, char *);
|
9
|
+
void appsignal_set_transaction_basedata(char *, char *, char *, long);
|
10
|
+
void appsignal_set_transaction_metadata(char *, char *, char *);
|
11
|
+
void appsignal_finish_transaction(char *);
|
12
|
+
void appsignal_set_gauge(char *, float);
|
13
|
+
void appsignal_set_process_gauge(char *, float);
|
14
|
+
void appsignal_increment_counter(char *, int);
|
15
|
+
void appsignal_add_distribution_value(char *, float);
|
16
|
+
|
17
|
+
static char * STRING_POINTER(VALUE str) {
|
18
|
+
// TODO we should use RSTRING_PTR and RSTRING_LEN, see:
|
19
|
+
// https://github.com/ruby/ruby/blob/trunk/doc/extension.rdoc
|
20
|
+
return StringValueCStr(str);
|
21
|
+
}
|
22
|
+
|
23
|
+
static VALUE start(VALUE self) {
|
24
|
+
appsignal_start();
|
25
|
+
|
26
|
+
return Qnil;
|
27
|
+
}
|
28
|
+
|
29
|
+
static VALUE start_transaction(VALUE self, VALUE transaction_id) {
|
30
|
+
Check_Type(transaction_id, T_STRING);
|
31
|
+
|
32
|
+
appsignal_start_transaction(STRING_POINTER(transaction_id));
|
33
|
+
return Qnil;
|
34
|
+
}
|
35
|
+
|
36
|
+
static VALUE start_event(VALUE self, VALUE transaction_id) {
|
37
|
+
Check_Type(transaction_id, T_STRING);
|
38
|
+
|
39
|
+
appsignal_start_event(STRING_POINTER(transaction_id));
|
40
|
+
return Qnil;
|
41
|
+
}
|
42
|
+
|
43
|
+
static VALUE finish_event(VALUE self, VALUE transaction_id, VALUE name, VALUE title, VALUE body) {
|
44
|
+
Check_Type(transaction_id, T_STRING);
|
45
|
+
Check_Type(name, T_STRING);
|
46
|
+
Check_Type(title, T_STRING);
|
47
|
+
Check_Type(body, T_STRING);
|
48
|
+
|
49
|
+
appsignal_finish_event(
|
50
|
+
STRING_POINTER(transaction_id),
|
51
|
+
STRING_POINTER(name),
|
52
|
+
STRING_POINTER(title),
|
53
|
+
STRING_POINTER(body)
|
54
|
+
);
|
55
|
+
return Qnil;
|
56
|
+
}
|
57
|
+
|
58
|
+
static VALUE set_transaction_error(VALUE self, VALUE transaction_id, VALUE name, VALUE message) {
|
59
|
+
Check_Type(transaction_id, T_STRING);
|
60
|
+
Check_Type(name, T_STRING);
|
61
|
+
Check_Type(message, T_STRING);
|
62
|
+
|
63
|
+
appsignal_set_transaction_error(
|
64
|
+
STRING_POINTER(transaction_id),
|
65
|
+
STRING_POINTER(name),
|
66
|
+
STRING_POINTER(message)
|
67
|
+
);
|
68
|
+
return Qnil;
|
69
|
+
}
|
70
|
+
|
71
|
+
static VALUE set_transaction_error_data(VALUE self, VALUE transaction_id, VALUE key, VALUE payload) {
|
72
|
+
Check_Type(transaction_id, T_STRING);
|
73
|
+
Check_Type(key, T_STRING);
|
74
|
+
Check_Type(payload, T_STRING);
|
75
|
+
|
76
|
+
appsignal_set_transaction_error_data(
|
77
|
+
STRING_POINTER(transaction_id),
|
78
|
+
STRING_POINTER(key),
|
79
|
+
STRING_POINTER(payload)
|
80
|
+
);
|
81
|
+
return Qnil;
|
82
|
+
}
|
83
|
+
|
84
|
+
static VALUE set_transaction_basedata(VALUE self, VALUE transaction_id, VALUE namespace, VALUE action, VALUE queue_start) {
|
85
|
+
Check_Type(transaction_id, T_STRING);
|
86
|
+
Check_Type(namespace, T_STRING);
|
87
|
+
Check_Type(action, T_STRING);
|
88
|
+
Check_Type(queue_start, T_FIXNUM);
|
89
|
+
|
90
|
+
appsignal_set_transaction_basedata(
|
91
|
+
STRING_POINTER(transaction_id),
|
92
|
+
STRING_POINTER(namespace),
|
93
|
+
STRING_POINTER(action),
|
94
|
+
FIX2LONG(queue_start)
|
95
|
+
);
|
96
|
+
return Qnil;
|
97
|
+
}
|
98
|
+
|
99
|
+
static VALUE set_transaction_metadata(VALUE self, VALUE transaction_id, VALUE key, VALUE value) {
|
100
|
+
Check_Type(transaction_id, T_STRING);
|
101
|
+
Check_Type(key, T_STRING);
|
102
|
+
Check_Type(value, T_STRING);
|
103
|
+
|
104
|
+
appsignal_set_transaction_metadata(
|
105
|
+
STRING_POINTER(transaction_id),
|
106
|
+
STRING_POINTER(key),
|
107
|
+
STRING_POINTER(value)
|
108
|
+
);
|
109
|
+
return Qnil;
|
110
|
+
}
|
111
|
+
|
112
|
+
static VALUE finish_transaction(VALUE self, VALUE transaction_id) {
|
113
|
+
Check_Type(transaction_id, T_STRING);
|
114
|
+
|
115
|
+
appsignal_finish_transaction(STRING_POINTER(transaction_id));
|
116
|
+
return Qnil;
|
117
|
+
}
|
118
|
+
|
119
|
+
static VALUE set_gauge(VALUE self, VALUE key, VALUE value) {
|
120
|
+
Check_Type(key, T_STRING);
|
121
|
+
Check_Type(value, T_FLOAT);
|
122
|
+
|
123
|
+
appsignal_set_gauge(
|
124
|
+
STRING_POINTER(key),
|
125
|
+
NUM2DBL(value)
|
126
|
+
);
|
127
|
+
return Qnil;
|
128
|
+
}
|
129
|
+
|
130
|
+
static VALUE set_process_gauge(VALUE self, VALUE key, VALUE value) {
|
131
|
+
Check_Type(key, T_STRING);
|
132
|
+
Check_Type(value, T_FLOAT);
|
133
|
+
|
134
|
+
appsignal_set_process_gauge(
|
135
|
+
STRING_POINTER(key),
|
136
|
+
NUM2DBL(value)
|
137
|
+
);
|
138
|
+
return Qnil;
|
139
|
+
}
|
140
|
+
|
141
|
+
static VALUE increment_counter(VALUE self, VALUE key, VALUE count) {
|
142
|
+
Check_Type(key, T_STRING);
|
143
|
+
Check_Type(count, T_FIXNUM);
|
144
|
+
|
145
|
+
appsignal_increment_counter(
|
146
|
+
STRING_POINTER(key),
|
147
|
+
FIX2INT(count)
|
148
|
+
);
|
149
|
+
return Qnil;
|
150
|
+
}
|
151
|
+
|
152
|
+
static VALUE add_distribution_value(VALUE self, VALUE key, VALUE value) {
|
153
|
+
Check_Type(key, T_STRING);
|
154
|
+
Check_Type(value, T_FLOAT);
|
155
|
+
|
156
|
+
appsignal_add_distribution_value(
|
157
|
+
STRING_POINTER(key),
|
158
|
+
NUM2DBL(value)
|
159
|
+
);
|
160
|
+
return Qnil;
|
161
|
+
}
|
162
|
+
|
163
|
+
void Init_appsignal_extension(void) {
|
164
|
+
VALUE Appsignal = rb_define_module("Appsignal");
|
165
|
+
VALUE Extension = rb_define_class_under(Appsignal, "Extension", rb_cObject);
|
166
|
+
|
167
|
+
// Transaction monitoring
|
168
|
+
rb_define_singleton_method(Extension, "start", start, 0);
|
169
|
+
rb_define_singleton_method(Extension, "start_transaction", start_transaction, 1);
|
170
|
+
rb_define_singleton_method(Extension, "start_event", start_event, 1);
|
171
|
+
rb_define_singleton_method(Extension, "finish_event", finish_event, 4);
|
172
|
+
rb_define_singleton_method(Extension, "set_transaction_error", set_transaction_error, 3);
|
173
|
+
rb_define_singleton_method(Extension, "set_transaction_error_data", set_transaction_error_data, 3);
|
174
|
+
rb_define_singleton_method(Extension, "set_transaction_basedata", set_transaction_basedata, 4);
|
175
|
+
rb_define_singleton_method(Extension, "set_transaction_metadata", set_transaction_metadata, 3);
|
176
|
+
rb_define_singleton_method(Extension, "finish_transaction", finish_transaction, 1);
|
177
|
+
|
178
|
+
// Metrics
|
179
|
+
rb_define_singleton_method(Extension, "set_gauge", set_gauge, 2);
|
180
|
+
rb_define_singleton_method(Extension, "set_process_gauge", set_process_gauge, 2);
|
181
|
+
rb_define_singleton_method(Extension, "increment_counter", increment_counter, 2);
|
182
|
+
rb_define_singleton_method(Extension, "add_distribution_value", add_distribution_value, 2);
|
183
|
+
}
|
data/ext/extconf.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'zlib'
|
5
|
+
require 'rubygems/package'
|
6
|
+
require File.expand_path('../../lib/appsignal/version.rb', __FILE__)
|
7
|
+
|
8
|
+
HOST = 'd135dj0rjqvssy.cloudfront.net'
|
9
|
+
SUPPORTED_ARCHS = %w(x86_64-linux x86_64-darwin)
|
10
|
+
|
11
|
+
def ext_path(path)
|
12
|
+
File.join(File.expand_path('..', __FILE__), path)
|
13
|
+
end
|
14
|
+
|
15
|
+
arch = "#{Gem::Platform.local.cpu}-#{Gem::Platform.local.os}"
|
16
|
+
|
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
|
+
Gem::Package::TarReader.new(Zlib::GzipReader.open(archive)) do |tar|
|
22
|
+
tar.each do |entry|
|
23
|
+
if entry.file?
|
24
|
+
File.open(ext_path(entry.full_name), 'wb') do |f|
|
25
|
+
f.write(entry.read)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
FileUtils.chmod(0755, ext_path('appsignal-agent'))
|
31
|
+
end
|
32
|
+
|
33
|
+
have_library 'appsignal', 'appsignal_start'
|
34
|
+
|
35
|
+
create_makefile 'appsignal_extension'
|
36
|
+
else
|
37
|
+
puts "AppSignal currently does not support your system architecture (#{arch})."
|
38
|
+
puts "Please let us know at support@appsignal.com, we aim to support everything our customers run."
|
39
|
+
end
|