appsignal 0.12.beta.8 → 0.12.beta.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/appsignal_extension.c +50 -38
- data/lib/appsignal.rb +8 -2
- data/lib/appsignal/config.rb +2 -1
- data/lib/appsignal/js_exception_transaction.rb +8 -8
- data/lib/appsignal/subscriber.rb +2 -2
- data/lib/appsignal/transaction.rb +8 -8
- data/lib/appsignal/version.rb +2 -2
- data/spec/lib/appsignal/config_spec.rb +3 -2
- data/spec/lib/appsignal/extension_spec.rb +29 -9
- data/spec/lib/appsignal/js_exception_transaction_spec.rb +9 -8
- data/spec/lib/appsignal/rack/listener_spec.rb +1 -1
- data/spec/lib/appsignal/subscriber_spec.rb +5 -5
- data/spec/lib/appsignal/transaction_spec.rb +16 -15
- data/spec/lib/appsignal_spec.rb +10 -0
- metadata +24 -40
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 15cdef7b5499176e7453ff3c4360754b29646fd2
|
4
|
+
data.tar.gz: 01c020ac0bd899d466085976b612588e19d8a9ef
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3eebc7f80f249e15bcc6fb540deed0bfe13b220bf7b4e97baf9a07e2de5df6acd7cd4d937a1deb6836ff485d1edf0e61aa469ab91e7fc8dc0e2e9757c6725cb3
|
7
|
+
data.tar.gz: 24eb957be42fc1ccff18275eb164da3222931ad2f0ab70983e4d4cc73f29b56e0dad79b74a1fac0abcecdd3fa2450bfc948e3cc2557f4c658759226f1aa11cf1
|
data/ext/appsignal_extension.c
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
#include "ruby/debug.h"
|
3
3
|
#include "appsignal_extension.h"
|
4
4
|
|
5
|
-
VALUE __current_transaction_id = Qnil;
|
6
|
-
|
7
5
|
static VALUE start(VALUE self) {
|
8
6
|
appsignal_start();
|
9
7
|
|
@@ -19,27 +17,24 @@ static VALUE stop(VALUE self) {
|
|
19
17
|
static VALUE start_transaction(VALUE self, VALUE transaction_id) {
|
20
18
|
Check_Type(transaction_id, T_STRING);
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
appsignal_start_transaction(StringValueCStr(transaction_id));
|
25
|
-
return Qnil;
|
20
|
+
return INT2FIX(appsignal_start_transaction(StringValueCStr(transaction_id)));
|
26
21
|
}
|
27
22
|
|
28
|
-
static VALUE start_event(VALUE self, VALUE
|
29
|
-
Check_Type(
|
23
|
+
static VALUE start_event(VALUE self, VALUE transaction_index) {
|
24
|
+
Check_Type(transaction_index, T_FIXNUM);
|
30
25
|
|
31
|
-
appsignal_start_event(
|
26
|
+
appsignal_start_event(FIX2INT(transaction_index));
|
32
27
|
return Qnil;
|
33
28
|
}
|
34
29
|
|
35
|
-
static VALUE finish_event(VALUE self, VALUE
|
36
|
-
Check_Type(
|
30
|
+
static VALUE finish_event(VALUE self, VALUE transaction_index, VALUE name, VALUE title, VALUE body) {
|
31
|
+
Check_Type(transaction_index, T_FIXNUM);
|
37
32
|
Check_Type(name, T_STRING);
|
38
33
|
Check_Type(title, T_STRING);
|
39
34
|
Check_Type(body, T_STRING);
|
40
35
|
|
41
36
|
appsignal_finish_event(
|
42
|
-
|
37
|
+
FIX2INT(transaction_index),
|
43
38
|
StringValueCStr(name),
|
44
39
|
StringValueCStr(title),
|
45
40
|
StringValueCStr(body)
|
@@ -47,40 +42,40 @@ static VALUE finish_event(VALUE self, VALUE transaction_id, VALUE name, VALUE ti
|
|
47
42
|
return Qnil;
|
48
43
|
}
|
49
44
|
|
50
|
-
static VALUE set_transaction_error(VALUE self, VALUE
|
51
|
-
Check_Type(
|
45
|
+
static VALUE set_transaction_error(VALUE self, VALUE transaction_index, VALUE name, VALUE message) {
|
46
|
+
Check_Type(transaction_index, T_FIXNUM);
|
52
47
|
Check_Type(name, T_STRING);
|
53
48
|
Check_Type(message, T_STRING);
|
54
49
|
|
55
50
|
appsignal_set_transaction_error(
|
56
|
-
|
51
|
+
FIX2INT(transaction_index),
|
57
52
|
StringValueCStr(name),
|
58
53
|
StringValueCStr(message)
|
59
54
|
);
|
60
55
|
return Qnil;
|
61
56
|
}
|
62
57
|
|
63
|
-
static VALUE set_transaction_error_data(VALUE self, VALUE
|
64
|
-
Check_Type(
|
58
|
+
static VALUE set_transaction_error_data(VALUE self, VALUE transaction_index, VALUE key, VALUE payload) {
|
59
|
+
Check_Type(transaction_index, T_FIXNUM);
|
65
60
|
Check_Type(key, T_STRING);
|
66
61
|
Check_Type(payload, T_STRING);
|
67
62
|
|
68
63
|
appsignal_set_transaction_error_data(
|
69
|
-
|
64
|
+
FIX2INT(transaction_index),
|
70
65
|
StringValueCStr(key),
|
71
66
|
StringValueCStr(payload)
|
72
67
|
);
|
73
68
|
return Qnil;
|
74
69
|
}
|
75
70
|
|
76
|
-
static VALUE
|
77
|
-
Check_Type(
|
71
|
+
static VALUE set_transaction_base_data(VALUE self, VALUE transaction_index, VALUE namespace, VALUE action, VALUE queue_start) {
|
72
|
+
Check_Type(transaction_index, T_FIXNUM);
|
78
73
|
Check_Type(namespace, T_STRING);
|
79
74
|
Check_Type(action, T_STRING);
|
80
75
|
Check_Type(queue_start, T_FIXNUM);
|
81
76
|
|
82
|
-
|
83
|
-
|
77
|
+
appsignal_set_transaction_base_data(
|
78
|
+
FIX2INT(transaction_index),
|
84
79
|
StringValueCStr(namespace),
|
85
80
|
StringValueCStr(action),
|
86
81
|
FIX2LONG(queue_start)
|
@@ -88,25 +83,23 @@ static VALUE set_transaction_basedata(VALUE self, VALUE transaction_id, VALUE na
|
|
88
83
|
return Qnil;
|
89
84
|
}
|
90
85
|
|
91
|
-
static VALUE set_transaction_metadata(VALUE self, VALUE
|
92
|
-
Check_Type(
|
86
|
+
static VALUE set_transaction_metadata(VALUE self, VALUE transaction_index, VALUE key, VALUE value) {
|
87
|
+
Check_Type(transaction_index, T_FIXNUM);
|
93
88
|
Check_Type(key, T_STRING);
|
94
89
|
Check_Type(value, T_STRING);
|
95
90
|
|
96
91
|
appsignal_set_transaction_metadata(
|
97
|
-
|
92
|
+
FIX2INT(transaction_index),
|
98
93
|
StringValueCStr(key),
|
99
94
|
StringValueCStr(value)
|
100
95
|
);
|
101
96
|
return Qnil;
|
102
97
|
}
|
103
98
|
|
104
|
-
static VALUE finish_transaction(VALUE self, VALUE
|
105
|
-
Check_Type(
|
106
|
-
|
107
|
-
__current_transaction_id = Qnil;
|
99
|
+
static VALUE finish_transaction(VALUE self, VALUE transaction_index) {
|
100
|
+
Check_Type(transaction_index, T_FIXNUM);
|
108
101
|
|
109
|
-
appsignal_finish_transaction(
|
102
|
+
appsignal_finish_transaction(FIX2INT(transaction_index));
|
110
103
|
return Qnil;
|
111
104
|
}
|
112
105
|
|
@@ -166,15 +159,24 @@ static VALUE add_distribution_value(VALUE self, VALUE key, VALUE value) {
|
|
166
159
|
}
|
167
160
|
|
168
161
|
static void track_allocation(VALUE tpval, void *data) {
|
169
|
-
|
170
|
-
|
162
|
+
appsignal_track_allocation();
|
163
|
+
}
|
164
|
+
|
165
|
+
static void track_gc(VALUE tpval, void *data) {
|
166
|
+
rb_trace_arg_t *tparg = rb_tracearg_from_tracepoint(tpval);
|
167
|
+
rb_event_flag_t flag = rb_tracearg_event_flag(tparg);
|
168
|
+
|
169
|
+
switch (flag) {
|
170
|
+
case RUBY_INTERNAL_EVENT_GC_START:
|
171
|
+
appsignal_track_gc_start();
|
172
|
+
case RUBY_INTERNAL_EVENT_GC_END_SWEEP:
|
173
|
+
appsignal_track_gc_end();
|
171
174
|
}
|
172
175
|
}
|
173
176
|
|
174
|
-
static void
|
177
|
+
static void install_tracepoint_callbacks() {
|
175
178
|
#if defined(RUBY_INTERNAL_EVENT_NEWOBJ)
|
176
|
-
VALUE allocation_tracer
|
177
|
-
allocation_tracer = rb_tracepoint_new(
|
179
|
+
VALUE allocation_tracer = rb_tracepoint_new(
|
178
180
|
Qnil,
|
179
181
|
RUBY_INTERNAL_EVENT_NEWOBJ,
|
180
182
|
track_allocation,
|
@@ -182,6 +184,16 @@ static void install_tracepoint() {
|
|
182
184
|
);
|
183
185
|
rb_tracepoint_enable(allocation_tracer);
|
184
186
|
#endif
|
187
|
+
#if defined(RUBY_INTERNAL_EVENT_GC_START) && defined(RUBY_INTERNAL_EVENT_GC_END_SWEEP)
|
188
|
+
rb_event_flag_t events = RUBY_INTERNAL_EVENT_GC_START|RUBY_INTERNAL_EVENT_GC_END_SWEEP;
|
189
|
+
VALUE gc_tracer = rb_tracepoint_new(
|
190
|
+
Qnil,
|
191
|
+
events,
|
192
|
+
track_gc,
|
193
|
+
0
|
194
|
+
);
|
195
|
+
rb_tracepoint_enable(gc_tracer);
|
196
|
+
#endif
|
185
197
|
}
|
186
198
|
|
187
199
|
void Init_appsignal_extension(void) {
|
@@ -196,7 +208,7 @@ void Init_appsignal_extension(void) {
|
|
196
208
|
rb_define_singleton_method(Extension, "finish_event", finish_event, 4);
|
197
209
|
rb_define_singleton_method(Extension, "set_transaction_error", set_transaction_error, 3);
|
198
210
|
rb_define_singleton_method(Extension, "set_transaction_error_data", set_transaction_error_data, 3);
|
199
|
-
rb_define_singleton_method(Extension, "
|
211
|
+
rb_define_singleton_method(Extension, "set_transaction_base_data", set_transaction_base_data, 4);
|
200
212
|
rb_define_singleton_method(Extension, "set_transaction_metadata", set_transaction_metadata, 3);
|
201
213
|
rb_define_singleton_method(Extension, "finish_transaction", finish_transaction, 1);
|
202
214
|
|
@@ -207,6 +219,6 @@ void Init_appsignal_extension(void) {
|
|
207
219
|
rb_define_singleton_method(Extension, "increment_counter", increment_counter, 2);
|
208
220
|
rb_define_singleton_method(Extension, "add_distribution_value", add_distribution_value, 2);
|
209
221
|
|
210
|
-
//
|
211
|
-
|
222
|
+
// Tracepoint callbacks
|
223
|
+
install_tracepoint_callbacks();
|
212
224
|
}
|
data/lib/appsignal.rb
CHANGED
@@ -137,16 +137,22 @@ module Appsignal
|
|
137
137
|
@in_memory_log = StringIO.new unless @in_memory_log
|
138
138
|
@logger ||= Logger.new(@in_memory_log).tap do |l|
|
139
139
|
l.level = Logger::INFO
|
140
|
-
l.formatter =
|
140
|
+
l.formatter = log_formatter
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
+
def log_formatter
|
145
|
+
proc do |severity, datetime, progname, msg|
|
146
|
+
"[#{datetime.strftime('%Y-%m-%dT%H:%M:%S')} (process) ##{Process.pid}][#{severity}] #{msg}"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
144
150
|
def start_logger(path)
|
145
151
|
if path && File.writable?(path) &&
|
146
152
|
!ENV['DYNO'] &&
|
147
153
|
!ENV['SHELLYCLOUD_DEPLOYMENT']
|
148
154
|
@logger = Logger.new(File.join(path, 'appsignal.log'))
|
149
|
-
@logger.formatter =
|
155
|
+
@logger.formatter = log_formatter
|
150
156
|
else
|
151
157
|
@logger = Logger.new($stdout)
|
152
158
|
@logger.formatter = lambda do |severity, datetime, progname, msg|
|
data/lib/appsignal/config.rb
CHANGED
@@ -7,11 +7,11 @@ module Appsignal
|
|
7
7
|
include Appsignal::CarefulLogger
|
8
8
|
|
9
9
|
DEFAULT_CONFIG = {
|
10
|
+
:debug => false,
|
10
11
|
:ignore_exceptions => [],
|
11
12
|
:ignore_actions => [],
|
12
13
|
:send_params => true,
|
13
14
|
:endpoint => 'https://push.appsignal.com',
|
14
|
-
:slow_request_threshold => 200,
|
15
15
|
:instrument_net_http => true,
|
16
16
|
:skip_session_data => false,
|
17
17
|
:enable_frontend_error_catching => false,
|
@@ -72,6 +72,7 @@ module Appsignal
|
|
72
72
|
ENV['APPSIGNAL_APP_PATH'] = root_path.to_s
|
73
73
|
ENV['APPSIGNAL_AGENT_PATH'] = File.expand_path('../../../ext', __FILE__).to_s
|
74
74
|
ENV['APPSIGNAL_LOG_PATH'] = File.join(root_path, 'log')
|
75
|
+
ENV['APPSIGNAL_DEBUG_LOGGING'] = config_hash[:debug].to_s
|
75
76
|
ENV['APPSIGNAL_PUSH_API_ENDPOINT'] = config_hash[:endpoint]
|
76
77
|
ENV['APPSIGNAL_PUSH_API_KEY'] = config_hash[:push_api_key]
|
77
78
|
ENV['APPSIGNAL_APP_NAME'] = config_hash[:name]
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Appsignal
|
2
2
|
class JSExceptionTransaction
|
3
|
+
attr_reader :uuid, :transaction_index
|
3
4
|
|
4
5
|
def initialize(data)
|
5
6
|
@data = data
|
6
7
|
@uuid = SecureRandom.uuid
|
7
|
-
|
8
|
-
Appsignal::Extension.start_transaction(@uuid)
|
8
|
+
@transaction_index = Appsignal::Extension.start_transaction(@uuid)
|
9
9
|
|
10
10
|
set_base_data
|
11
11
|
set_metadata
|
@@ -14,8 +14,8 @@ module Appsignal
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def set_base_data
|
17
|
-
Appsignal::Extension.
|
18
|
-
@
|
17
|
+
Appsignal::Extension.set_transaction_base_data(
|
18
|
+
@transaction_index,
|
19
19
|
'frontend',
|
20
20
|
@data['action'],
|
21
21
|
0
|
@@ -24,13 +24,13 @@ module Appsignal
|
|
24
24
|
|
25
25
|
def set_metadata
|
26
26
|
Appsignal::Extension.set_transaction_metadata(
|
27
|
-
@
|
27
|
+
@transaction_index, 'path', @data['path']
|
28
28
|
) if @data['path']
|
29
29
|
end
|
30
30
|
|
31
31
|
def set_error
|
32
32
|
Appsignal::Extension.set_transaction_error(
|
33
|
-
@
|
33
|
+
@transaction_index,
|
34
34
|
@data['name'],
|
35
35
|
@data['message']
|
36
36
|
)
|
@@ -46,7 +46,7 @@ module Appsignal
|
|
46
46
|
next unless data.is_a?(Array) || data.is_a?(Hash)
|
47
47
|
begin
|
48
48
|
Appsignal::Extension.set_transaction_error_data(
|
49
|
-
@
|
49
|
+
@transaction_index,
|
50
50
|
key.to_s,
|
51
51
|
JSON.generate(data)
|
52
52
|
)
|
@@ -57,7 +57,7 @@ module Appsignal
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def complete!
|
60
|
-
Appsignal::Extension.finish_transaction(@
|
60
|
+
Appsignal::Extension.finish_transaction(@transaction_index)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
data/lib/appsignal/subscriber.rb
CHANGED
@@ -35,7 +35,7 @@ module Appsignal
|
|
35
35
|
return unless transaction = Appsignal::Transaction.current
|
36
36
|
|
37
37
|
return if transaction.paused?
|
38
|
-
Appsignal::Extension.start_event(transaction.
|
38
|
+
Appsignal::Extension.start_event(transaction.transaction_index)
|
39
39
|
end
|
40
40
|
|
41
41
|
def finish(name, id, payload)
|
@@ -49,7 +49,7 @@ module Appsignal
|
|
49
49
|
|
50
50
|
title, body = Appsignal::EventFormatter.format(name, payload)
|
51
51
|
Appsignal::Extension.finish_event(
|
52
|
-
transaction.
|
52
|
+
transaction.transaction_index,
|
53
53
|
name,
|
54
54
|
title || BLANK,
|
55
55
|
body || BLANK
|
@@ -17,7 +17,6 @@ module Appsignal
|
|
17
17
|
class << self
|
18
18
|
def create(request_id, env)
|
19
19
|
Appsignal.logger.debug("Creating transaction: #{request_id}")
|
20
|
-
Appsignal::Extension.start_transaction(request_id)
|
21
20
|
Thread.current[:appsignal_transaction] = Appsignal::Transaction.new(request_id, env)
|
22
21
|
end
|
23
22
|
|
@@ -27,7 +26,7 @@ module Appsignal
|
|
27
26
|
|
28
27
|
def complete_current!
|
29
28
|
if current
|
30
|
-
Appsignal::Extension.finish_transaction(current.
|
29
|
+
Appsignal::Extension.finish_transaction(current.transaction_index)
|
31
30
|
Thread.current[:appsignal_transaction] = nil
|
32
31
|
else
|
33
32
|
Appsignal.logger.error('Trying to complete current, but no transaction present')
|
@@ -35,7 +34,7 @@ module Appsignal
|
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
|
-
attr_reader :request_id, :process_action_event, :action, :exception,
|
37
|
+
attr_reader :request_id, :transaction_index, :process_action_event, :action, :exception,
|
39
38
|
:env, :fullpath, :time, :tags, :kind, :queue_start, :paused, :root_event_payload
|
40
39
|
|
41
40
|
def initialize(request_id, env)
|
@@ -47,6 +46,7 @@ module Appsignal
|
|
47
46
|
@tags = {}
|
48
47
|
@paused = false
|
49
48
|
@queue_start = -1
|
49
|
+
@transaction_index = Appsignal::Extension.start_transaction(@request_id)
|
50
50
|
end
|
51
51
|
|
52
52
|
def sanitized_environment
|
@@ -80,8 +80,8 @@ module Appsignal
|
|
80
80
|
@kind = BACKGROUND_JOB
|
81
81
|
set_background_queue_start
|
82
82
|
end
|
83
|
-
Appsignal::Extension.
|
84
|
-
|
83
|
+
Appsignal::Extension.set_transaction_base_data(
|
84
|
+
transaction_index,
|
85
85
|
kind,
|
86
86
|
action,
|
87
87
|
queue_start
|
@@ -90,14 +90,14 @@ module Appsignal
|
|
90
90
|
|
91
91
|
def set_metadata(key, value)
|
92
92
|
return unless value
|
93
|
-
Appsignal::Extension.set_transaction_metadata(
|
93
|
+
Appsignal::Extension.set_transaction_metadata(transaction_index, key, value)
|
94
94
|
end
|
95
95
|
|
96
96
|
def set_error(error)
|
97
97
|
return unless error
|
98
98
|
Appsignal.logger.debug("Adding #{error.class.name} to transaction: #{request_id}")
|
99
99
|
Appsignal::Extension.set_transaction_error(
|
100
|
-
|
100
|
+
transaction_index,
|
101
101
|
error.class.name,
|
102
102
|
error.message
|
103
103
|
)
|
@@ -112,7 +112,7 @@ module Appsignal
|
|
112
112
|
next unless data.is_a?(Array) || data.is_a?(Hash)
|
113
113
|
begin
|
114
114
|
Appsignal::Extension.set_transaction_error_data(
|
115
|
-
|
115
|
+
transaction_index,
|
116
116
|
key.to_s,
|
117
117
|
JSON.generate(data)
|
118
118
|
)
|
data/lib/appsignal/version.rb
CHANGED
@@ -16,13 +16,13 @@ describe Appsignal::Config do
|
|
16
16
|
|
17
17
|
it "should merge with the default config and fill the config hash" do
|
18
18
|
subject.config_hash.should == {
|
19
|
+
:debug => false,
|
19
20
|
:ignore_exceptions => [],
|
20
21
|
:ignore_actions => [],
|
21
22
|
:instrument_net_http => true,
|
22
23
|
:skip_session_data => false,
|
23
24
|
:send_params => true,
|
24
25
|
:endpoint => 'https://push.appsignal.com',
|
25
|
-
:slow_request_threshold => 200,
|
26
26
|
:push_api_key => 'abc',
|
27
27
|
:name => 'TestApp',
|
28
28
|
:active => true,
|
@@ -51,6 +51,7 @@ describe Appsignal::Config do
|
|
51
51
|
ENV['APPSIGNAL_APP_PATH'].should end_with('spec/support/project_fixture')
|
52
52
|
ENV['APPSIGNAL_AGENT_PATH'].should end_with('/ext')
|
53
53
|
ENV['APPSIGNAL_LOG_PATH'].should end_with('/log')
|
54
|
+
ENV['APPSIGNAL_DEBUG_LOGGING'].should == 'false'
|
54
55
|
ENV['APPSIGNAL_PUSH_API_ENDPOINT'].should == 'https://push.appsignal.com'
|
55
56
|
ENV['APPSIGNAL_PUSH_API_KEY'].should == 'abc'
|
56
57
|
ENV['APPSIGNAL_APP_NAME'].should == 'TestApp'
|
@@ -152,6 +153,7 @@ describe Appsignal::Config do
|
|
152
153
|
)
|
153
154
|
|
154
155
|
subject.config_hash.should == {
|
156
|
+
:debug => false,
|
155
157
|
:push_api_key => 'push_api_key',
|
156
158
|
:ignore_exceptions => [],
|
157
159
|
:ignore_actions => [],
|
@@ -159,7 +161,6 @@ describe Appsignal::Config do
|
|
159
161
|
:instrument_net_http => true,
|
160
162
|
:skip_session_data => false,
|
161
163
|
:endpoint => 'https://push.appsignal.com',
|
162
|
-
:slow_request_threshold => 200,
|
163
164
|
:active => true,
|
164
165
|
:enable_frontend_error_catching => false,
|
165
166
|
:frontend_error_catching_path => '/appsignal_error_catcher'
|
@@ -22,12 +22,12 @@ describe Appsignal::Extension do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should have a start_event method" do
|
25
|
-
subject.start_event(
|
25
|
+
subject.start_event(1)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should have a finish_event method" do
|
29
29
|
subject.finish_event(
|
30
|
-
|
30
|
+
1,
|
31
31
|
'name',
|
32
32
|
'title',
|
33
33
|
'body'
|
@@ -36,7 +36,7 @@ describe Appsignal::Extension do
|
|
36
36
|
|
37
37
|
it "should have a set_transaction_error method" do
|
38
38
|
subject.set_transaction_error(
|
39
|
-
|
39
|
+
1,
|
40
40
|
'name',
|
41
41
|
'message'
|
42
42
|
)
|
@@ -44,15 +44,15 @@ describe Appsignal::Extension do
|
|
44
44
|
|
45
45
|
it "should have a set_transaction_error_data method" do
|
46
46
|
subject.set_transaction_error_data(
|
47
|
-
|
47
|
+
1,
|
48
48
|
'params',
|
49
49
|
'{}'
|
50
50
|
)
|
51
51
|
end
|
52
52
|
|
53
|
-
it "should have a
|
54
|
-
subject.
|
55
|
-
|
53
|
+
it "should have a set_transaction_base_data method" do
|
54
|
+
subject.set_transaction_base_data(
|
55
|
+
1,
|
56
56
|
'kind',
|
57
57
|
'action',
|
58
58
|
100
|
@@ -61,14 +61,34 @@ describe Appsignal::Extension do
|
|
61
61
|
|
62
62
|
it "should have a set_transaction_metadata method" do
|
63
63
|
subject.set_transaction_metadata(
|
64
|
-
|
64
|
+
1,
|
65
65
|
'key',
|
66
66
|
'value'
|
67
67
|
)
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should have a finish_transaction method" do
|
71
|
-
subject.finish_transaction(
|
71
|
+
subject.finish_transaction(1)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should have a set_gauge method" do
|
75
|
+
Appsignal.set_gauge('key', 1.0)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should have a set_host_gauge method" do
|
79
|
+
Appsignal.set_host_gauge('key', 1.0)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should have a set_process_gauge method" do
|
83
|
+
Appsignal.set_process_gauge('key', 1.0)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should have a increment_counter method" do
|
87
|
+
Appsignal.increment_counter('key', 1)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should have a add_distribution_value method" do
|
91
|
+
Appsignal.add_distribution_value('key', 1.0)
|
72
92
|
end
|
73
93
|
end
|
74
94
|
end
|
@@ -20,7 +20,7 @@ describe Appsignal::JSExceptionTransaction do
|
|
20
20
|
|
21
21
|
describe "#initialize" do
|
22
22
|
it "should call all required methods" do
|
23
|
-
expect( Appsignal::Extension ).to receive(:start_transaction).with('123abc')
|
23
|
+
expect( Appsignal::Extension ).to receive(:start_transaction).with('123abc').and_return(1)
|
24
24
|
|
25
25
|
expect( transaction ).to receive(:set_base_data)
|
26
26
|
expect( transaction ).to receive(:set_metadata)
|
@@ -28,13 +28,15 @@ describe Appsignal::JSExceptionTransaction do
|
|
28
28
|
expect( transaction ).to receive(:set_error_data)
|
29
29
|
|
30
30
|
transaction.send :initialize, data
|
31
|
+
|
32
|
+
expect( transaction.transaction_index ).to eq(1)
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
36
|
describe "#set_base_data" do
|
35
37
|
it "should call `Appsignal::Extension.set_transaction_basedata`" do
|
36
|
-
expect( Appsignal::Extension ).to receive(:
|
37
|
-
|
38
|
+
expect( Appsignal::Extension ).to receive(:set_transaction_base_data).with(
|
39
|
+
kind_of(Integer),
|
38
40
|
'frontend',
|
39
41
|
'ExceptionIncidentComponent',
|
40
42
|
0
|
@@ -47,7 +49,7 @@ describe Appsignal::JSExceptionTransaction do
|
|
47
49
|
describe "#set_metadata" do
|
48
50
|
it "should call `Appsignal::Extension.set_transaction_metadata`" do
|
49
51
|
expect( Appsignal::Extension ).to receive(:set_transaction_metadata).with(
|
50
|
-
|
52
|
+
kind_of(Integer),
|
51
53
|
'path',
|
52
54
|
'foo.bar/moo'
|
53
55
|
)
|
@@ -59,7 +61,7 @@ describe Appsignal::JSExceptionTransaction do
|
|
59
61
|
describe "#set_error" do
|
60
62
|
it "should call `Appsignal::Extension.set_transaction_error`" do
|
61
63
|
expect( Appsignal::Extension ).to receive(:set_transaction_error).with(
|
62
|
-
|
64
|
+
kind_of(Integer),
|
63
65
|
'TypeError',
|
64
66
|
'foo is not a valid method'
|
65
67
|
)
|
@@ -71,7 +73,7 @@ describe Appsignal::JSExceptionTransaction do
|
|
71
73
|
describe "#set_error_data" do
|
72
74
|
it "should call `Appsignal::Extension.set_transaction_error_data`" do
|
73
75
|
expect( Appsignal::Extension ).to receive(:set_transaction_error_data).with(
|
74
|
-
|
76
|
+
kind_of(Integer),
|
75
77
|
'backtrace',
|
76
78
|
'["foo.bar/js:11:1","foo.bar/js:22:2"]'
|
77
79
|
)
|
@@ -82,9 +84,8 @@ describe Appsignal::JSExceptionTransaction do
|
|
82
84
|
|
83
85
|
describe "#complete!" do
|
84
86
|
it "should call all required methods" do
|
85
|
-
expect( Appsignal::Extension ).to receive(:finish_transaction).with(
|
87
|
+
expect( Appsignal::Extension ).to receive(:finish_transaction).with(kind_of(Integer))
|
86
88
|
transaction.complete!
|
87
89
|
end
|
88
90
|
end
|
89
|
-
|
90
91
|
end
|
@@ -19,7 +19,7 @@ describe Appsignal::Rack::Listener do
|
|
19
19
|
let(:env) { {} }
|
20
20
|
|
21
21
|
describe '#call' do
|
22
|
-
let(:current) { double(:request_id => '1', :set_error => true) }
|
22
|
+
let(:current) { double(:request_id => '1', :set_error => true, :transaction_index => 1) }
|
23
23
|
before do
|
24
24
|
middleware.stub(:request_id => '1')
|
25
25
|
Appsignal::Transaction.stub(:current => current)
|
@@ -81,10 +81,10 @@ describe Appsignal::Subscriber do
|
|
81
81
|
|
82
82
|
it "should call native start and finish event for every event" do
|
83
83
|
Appsignal::Extension.should_receive(:start_event).exactly(4).times
|
84
|
-
Appsignal::Extension.should_receive(:finish_event).with(
|
85
|
-
Appsignal::Extension.should_receive(:finish_event).with(
|
86
|
-
Appsignal::Extension.should_receive(:finish_event).with(
|
87
|
-
Appsignal::Extension.should_receive(:finish_event).with(
|
84
|
+
Appsignal::Extension.should_receive(:finish_event).with(kind_of(Integer), 'one', '', '').once
|
85
|
+
Appsignal::Extension.should_receive(:finish_event).with(kind_of(Integer), 'two', '', '').once
|
86
|
+
Appsignal::Extension.should_receive(:finish_event).with(kind_of(Integer), 'two.three', '', '').once
|
87
|
+
Appsignal::Extension.should_receive(:finish_event).with(kind_of(Integer), 'one.three', '', '').once
|
88
88
|
|
89
89
|
ActiveSupport::Notifications.instrument('one') do
|
90
90
|
ActiveSupport::Notifications.instrument('two') do
|
@@ -99,7 +99,7 @@ describe Appsignal::Subscriber do
|
|
99
99
|
it "should call finish with title and body if there is a formatter" do
|
100
100
|
Appsignal::Extension.should_receive(:start_event).once
|
101
101
|
Appsignal::Extension.should_receive(:finish_event).with(
|
102
|
-
|
102
|
+
kind_of(Integer),
|
103
103
|
'request.net_http',
|
104
104
|
'GET http://www.google.com',
|
105
105
|
''
|
@@ -50,7 +50,7 @@ describe Appsignal::Transaction do
|
|
50
50
|
before { Appsignal::Transaction.create('2', {}) }
|
51
51
|
|
52
52
|
it "should complete the current transaction and set the thread appsignal_transaction to nil" do
|
53
|
-
Appsignal::Extension.should_receive(:finish_transaction).with(
|
53
|
+
Appsignal::Extension.should_receive(:finish_transaction).with(kind_of(Integer))
|
54
54
|
|
55
55
|
Appsignal::Transaction.complete_current!
|
56
56
|
|
@@ -114,6 +114,7 @@ describe Appsignal::Transaction do
|
|
114
114
|
subject { transaction }
|
115
115
|
|
116
116
|
its(:request_id) { should == '3' }
|
117
|
+
its(:transaction_index) { should be_a Integer }
|
117
118
|
its(:root_event_payload) { should be_nil }
|
118
119
|
its(:exception) { should be_nil }
|
119
120
|
its(:env) { should == env }
|
@@ -141,8 +142,8 @@ describe Appsignal::Transaction do
|
|
141
142
|
let(:payload) { create_payload }
|
142
143
|
|
143
144
|
it "should set the meta data in the transaction and native" do
|
144
|
-
Appsignal::Extension.should_receive(:
|
145
|
-
|
145
|
+
Appsignal::Extension.should_receive(:set_transaction_base_data).with(
|
146
|
+
kind_of(Integer),
|
146
147
|
'http_request',
|
147
148
|
'BlogPostsController#show',
|
148
149
|
kind_of(Integer)
|
@@ -172,8 +173,8 @@ describe Appsignal::Transaction do
|
|
172
173
|
let(:payload) { create_background_payload }
|
173
174
|
|
174
175
|
it "should set the meta data in the transaction and native" do
|
175
|
-
Appsignal::Extension.should_receive(:
|
176
|
-
|
176
|
+
Appsignal::Extension.should_receive(:set_transaction_base_data).with(
|
177
|
+
kind_of(Integer),
|
177
178
|
'background_job',
|
178
179
|
'BackgroundJob#perform',
|
179
180
|
kind_of(Integer)
|
@@ -192,7 +193,7 @@ describe Appsignal::Transaction do
|
|
192
193
|
describe "#set_metadata" do
|
193
194
|
it "should set the metdata in native" do
|
194
195
|
Appsignal::Extension.should_receive(:set_transaction_metadata).with(
|
195
|
-
|
196
|
+
kind_of(Integer),
|
196
197
|
'request_method',
|
197
198
|
'GET'
|
198
199
|
).once
|
@@ -216,27 +217,27 @@ describe Appsignal::Transaction do
|
|
216
217
|
|
217
218
|
it "should set an error and it's data in native" do
|
218
219
|
Appsignal::Extension.should_receive(:set_transaction_error).with(
|
219
|
-
|
220
|
+
kind_of(Integer),
|
220
221
|
'RSpec::Mocks::Mock',
|
221
222
|
'test message'
|
222
223
|
)
|
223
224
|
Appsignal::Extension.should_receive(:set_transaction_error_data).with(
|
224
|
-
|
225
|
+
kind_of(Integer),
|
225
226
|
'environment',
|
226
227
|
"{\"SERVER_NAME\":\"localhost\",\"HTTP_X_REQUEST_START\":\"1000000\",\"HTTP_USER_AGENT\":\"IE6\"}"
|
227
228
|
).once
|
228
229
|
Appsignal::Extension.should_receive(:set_transaction_error_data).with(
|
229
|
-
|
230
|
+
kind_of(Integer),
|
230
231
|
'session_data',
|
231
232
|
"{}"
|
232
233
|
).once
|
233
234
|
Appsignal::Extension.should_receive(:set_transaction_error_data).with(
|
234
|
-
|
235
|
+
kind_of(Integer),
|
235
236
|
'backtrace',
|
236
237
|
"[\"line 1\"]"
|
237
238
|
).once
|
238
239
|
Appsignal::Extension.should_receive(:set_transaction_error_data).with(
|
239
|
-
|
240
|
+
kind_of(Integer),
|
240
241
|
'tags',
|
241
242
|
"{}"
|
242
243
|
).once
|
@@ -251,12 +252,12 @@ describe Appsignal::Transaction do
|
|
251
252
|
|
252
253
|
it "should also set params" do
|
253
254
|
Appsignal::Extension.should_receive(:set_transaction_error_data).with(
|
254
|
-
|
255
|
+
kind_of(Integer),
|
255
256
|
'params',
|
256
257
|
'{"controller":"blog_posts","action":"show","id":"1"}'
|
257
258
|
).once
|
258
259
|
Appsignal::Extension.should_receive(:set_transaction_error_data).with(
|
259
|
-
|
260
|
+
kind_of(Integer),
|
260
261
|
kind_of(String),
|
261
262
|
kind_of(String)
|
262
263
|
).exactly(4).times
|
@@ -272,12 +273,12 @@ describe Appsignal::Transaction do
|
|
272
273
|
|
273
274
|
it "should skip the field" do
|
274
275
|
Appsignal::Extension.should_not_receive(:set_transaction_error_data).with(
|
275
|
-
|
276
|
+
kind_of(Integer),
|
276
277
|
'params',
|
277
278
|
kind_of(String)
|
278
279
|
)
|
279
280
|
Appsignal::Extension.should_receive(:set_transaction_error_data).with(
|
280
|
-
|
281
|
+
kind_of(Integer),
|
281
282
|
kind_of(String),
|
282
283
|
kind_of(String)
|
283
284
|
).exactly(4).times
|
data/spec/lib/appsignal_spec.rb
CHANGED
@@ -403,6 +403,16 @@ describe Appsignal do
|
|
403
403
|
end
|
404
404
|
end
|
405
405
|
|
406
|
+
describe ".log_formatter" do
|
407
|
+
subject { Appsignal.log_formatter }
|
408
|
+
|
409
|
+
it "should format a log line" do
|
410
|
+
Process.stub(:pid => 100)
|
411
|
+
subject.call('Debug', Time.parse('2015-07-08'), nil, 'log line').should ==
|
412
|
+
'[2015-07-08T00:00:00 (process) #100][Debug] log line'
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
406
416
|
describe '.config' do
|
407
417
|
subject { Appsignal.config }
|
408
418
|
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.beta.
|
5
|
-
prerelease: 5
|
4
|
+
version: 0.12.beta.9
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Robert Beekman
|
@@ -13,118 +12,104 @@ authors:
|
|
13
12
|
autorequire:
|
14
13
|
bindir: bin
|
15
14
|
cert_chain: []
|
16
|
-
date: 2015-
|
15
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
17
16
|
dependencies:
|
18
17
|
- !ruby/object:Gem::Dependency
|
19
18
|
name: rack
|
20
19
|
requirement: !ruby/object:Gem::Requirement
|
21
|
-
none: false
|
22
20
|
requirements:
|
23
|
-
- -
|
21
|
+
- - ">="
|
24
22
|
- !ruby/object:Gem::Version
|
25
23
|
version: '0'
|
26
24
|
type: :runtime
|
27
25
|
prerelease: false
|
28
26
|
version_requirements: !ruby/object:Gem::Requirement
|
29
|
-
none: false
|
30
27
|
requirements:
|
31
|
-
- -
|
28
|
+
- - ">="
|
32
29
|
- !ruby/object:Gem::Version
|
33
30
|
version: '0'
|
34
31
|
- !ruby/object:Gem::Dependency
|
35
32
|
name: thread_safe
|
36
33
|
requirement: !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
34
|
requirements:
|
39
|
-
- -
|
35
|
+
- - ">="
|
40
36
|
- !ruby/object:Gem::Version
|
41
37
|
version: '0'
|
42
38
|
type: :runtime
|
43
39
|
prerelease: false
|
44
40
|
version_requirements: !ruby/object:Gem::Requirement
|
45
|
-
none: false
|
46
41
|
requirements:
|
47
|
-
- -
|
42
|
+
- - ">="
|
48
43
|
- !ruby/object:Gem::Version
|
49
44
|
version: '0'
|
50
45
|
- !ruby/object:Gem::Dependency
|
51
46
|
name: rake
|
52
47
|
requirement: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
48
|
requirements:
|
55
|
-
- -
|
49
|
+
- - ">="
|
56
50
|
- !ruby/object:Gem::Version
|
57
51
|
version: '0'
|
58
52
|
type: :development
|
59
53
|
prerelease: false
|
60
54
|
version_requirements: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
55
|
requirements:
|
63
|
-
- -
|
56
|
+
- - ">="
|
64
57
|
- !ruby/object:Gem::Version
|
65
58
|
version: '0'
|
66
59
|
- !ruby/object:Gem::Dependency
|
67
60
|
name: rspec
|
68
61
|
requirement: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
62
|
requirements:
|
71
|
-
- - ~>
|
63
|
+
- - "~>"
|
72
64
|
- !ruby/object:Gem::Version
|
73
65
|
version: 2.14.1
|
74
66
|
type: :development
|
75
67
|
prerelease: false
|
76
68
|
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
69
|
requirements:
|
79
|
-
- - ~>
|
70
|
+
- - "~>"
|
80
71
|
- !ruby/object:Gem::Version
|
81
72
|
version: 2.14.1
|
82
73
|
- !ruby/object:Gem::Dependency
|
83
74
|
name: pry
|
84
75
|
requirement: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
76
|
requirements:
|
87
|
-
- -
|
77
|
+
- - ">="
|
88
78
|
- !ruby/object:Gem::Version
|
89
79
|
version: '0'
|
90
80
|
type: :development
|
91
81
|
prerelease: false
|
92
82
|
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
83
|
requirements:
|
95
|
-
- -
|
84
|
+
- - ">="
|
96
85
|
- !ruby/object:Gem::Version
|
97
86
|
version: '0'
|
98
87
|
- !ruby/object:Gem::Dependency
|
99
88
|
name: timecop
|
100
89
|
requirement: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
90
|
requirements:
|
103
|
-
- -
|
91
|
+
- - ">="
|
104
92
|
- !ruby/object:Gem::Version
|
105
93
|
version: '0'
|
106
94
|
type: :development
|
107
95
|
prerelease: false
|
108
96
|
version_requirements: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
97
|
requirements:
|
111
|
-
- -
|
98
|
+
- - ">="
|
112
99
|
- !ruby/object:Gem::Version
|
113
100
|
version: '0'
|
114
101
|
- !ruby/object:Gem::Dependency
|
115
102
|
name: webmock
|
116
103
|
requirement: !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
104
|
requirements:
|
119
|
-
- -
|
105
|
+
- - ">="
|
120
106
|
- !ruby/object:Gem::Version
|
121
107
|
version: '0'
|
122
108
|
type: :development
|
123
109
|
prerelease: false
|
124
110
|
version_requirements: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
111
|
requirements:
|
127
|
-
- -
|
112
|
+
- - ">="
|
128
113
|
- !ruby/object:Gem::Version
|
129
114
|
version: '0'
|
130
115
|
description: The official appsignal.com gem
|
@@ -136,9 +121,9 @@ extensions:
|
|
136
121
|
- ext/extconf.rb
|
137
122
|
extra_rdoc_files: []
|
138
123
|
files:
|
139
|
-
- .gitignore
|
140
|
-
- .rspec
|
141
|
-
- .travis.yml
|
124
|
+
- ".gitignore"
|
125
|
+
- ".rspec"
|
126
|
+
- ".travis.yml"
|
142
127
|
- CHANGELOG.md
|
143
128
|
- Gemfile
|
144
129
|
- LICENSE
|
@@ -246,28 +231,27 @@ files:
|
|
246
231
|
homepage: https://github.com/appsignal/appsignal
|
247
232
|
licenses:
|
248
233
|
- MIT
|
234
|
+
metadata: {}
|
249
235
|
post_install_message:
|
250
236
|
rdoc_options: []
|
251
237
|
require_paths:
|
252
238
|
- lib
|
253
239
|
- ext
|
254
240
|
required_ruby_version: !ruby/object:Gem::Requirement
|
255
|
-
none: false
|
256
241
|
requirements:
|
257
|
-
- -
|
242
|
+
- - ">="
|
258
243
|
- !ruby/object:Gem::Version
|
259
244
|
version: '1.9'
|
260
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
261
|
-
none: false
|
262
246
|
requirements:
|
263
|
-
- -
|
247
|
+
- - ">"
|
264
248
|
- !ruby/object:Gem::Version
|
265
249
|
version: 1.3.1
|
266
250
|
requirements: []
|
267
251
|
rubyforge_project:
|
268
|
-
rubygems_version:
|
252
|
+
rubygems_version: 2.4.5
|
269
253
|
signing_key:
|
270
|
-
specification_version:
|
254
|
+
specification_version: 4
|
271
255
|
summary: Logs performance and exception data from your app to appsignal.com
|
272
256
|
test_files:
|
273
257
|
- spec/lib/appsignal/auth_check_spec.rb
|