appsignal 2.0.0.beta.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +196 -11
- data/lib/appsignal/cli.rb +11 -1
- data/lib/appsignal/cli/demo.rb +23 -0
- data/lib/appsignal/cli/install.rb +17 -11
- data/lib/appsignal/demo.rb +87 -0
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/cli/demo_spec.rb +67 -0
- data/spec/lib/appsignal/cli/install_spec.rb +23 -5
- data/spec/lib/appsignal/cli_spec.rb +2 -1
- data/spec/lib/appsignal/demo_spec.rb +80 -0
- data/spec/lib/appsignal/transaction_spec.rb +14 -3
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b06d39d3717f054714a64e2961c466b4a9caed2e
|
4
|
+
data.tar.gz: 62ebd705722d24809f4c2649ed777230fe1b66c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04a76fba53a43dad673857e71532d96ddbbc4d2699593ee4b755076866f2c58199be03aaad577a2b2bf16c02d97c1180b175c3e889d70a18016cb44de131c2e5
|
7
|
+
data.tar.gz: d174831943495a569f67b307eedc556524ab29a626053c9015154519e50267dfe64f4300de780f477847434e88172b3a985b076bbee1880ce1cc9a714ed62e40
|
data/CHANGELOG.md
CHANGED
@@ -28,6 +28,10 @@
|
|
28
28
|
* Remove deprecated methods. PR #191
|
29
29
|
* Send "ruby" implementation name with version number for better identifying
|
30
30
|
different language implementations. PR #198
|
31
|
+
* Send demonstration samples to AppSignal using the `appsignal install`
|
32
|
+
command instead of asking the user to start their app. PR #196
|
33
|
+
* Add `appsignal demo` command to test the AppSignal demonstration samples
|
34
|
+
instrumentation manually and not just during the installation. PR #199
|
31
35
|
|
32
36
|
# 1.3.6
|
33
37
|
* Support blocks arguments on method instrumentation. PR #163
|
data/README.md
CHANGED
@@ -1,18 +1,161 @@
|
|
1
|
-
# AppSignal agent
|
1
|
+
# AppSignal Ruby agent
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
AppSignal solves all your Ruby monitoring needs in a single tool. You and your
|
4
|
+
team can focus on writing code and we'll provide the alerts if your app has any
|
5
|
+
issues.
|
5
6
|
|
6
|
-
- [
|
7
|
+
- [AppSignal.com website][appsignal]
|
8
|
+
- [Documentation][docs]
|
9
|
+
- [Support][contact]
|
7
10
|
|
8
11
|
[![Build Status](https://travis-ci.org/appsignal/appsignal-ruby.png?branch=master)](https://travis-ci.org/appsignal/appsignal-ruby)
|
9
12
|
[![Gem Version](https://badge.fury.io/rb/appsignal.svg)](http://badge.fury.io/rb/appsignal)
|
10
13
|
[![Code Climate](https://codeclimate.com/github/appsignal/appsignal.png)](https://codeclimate.com/github/appsignal/appsignal)
|
11
14
|
|
15
|
+
## Description
|
16
|
+
|
17
|
+
The AppSignal gem collects exceptions and performance data from your Ruby
|
18
|
+
applications and sends it to [AppSignal][appsignal] for analysis. Get alerted
|
19
|
+
when an error occurs or an endpoint is responding very slowly.
|
20
|
+
|
21
|
+
AppSignal aims to provide a one stop solution to all your monitoring needs.
|
22
|
+
Track metrics from your servers with our [Host metrics][host-metrics] and graph
|
23
|
+
everything else with our [Custom metrics][custom-metrics] feature.
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
First make sure you've installed AppSignal in your application by following the
|
28
|
+
steps in [Installation](#installation).
|
29
|
+
|
30
|
+
AppSignal will automatically monitor requests, report any exceptions that are
|
31
|
+
thrown and any performance issues that might have occurred.
|
32
|
+
|
33
|
+
You can also add extra information to requests by adding custom instrumentation
|
34
|
+
and by adding metadata.
|
35
|
+
|
36
|
+
### Track any error
|
37
|
+
|
38
|
+
Catch any error and report it to AppSignal, even if it doesn't crash a
|
39
|
+
request.
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
begin
|
43
|
+
config = File.read("config.yml")
|
44
|
+
rescue => e
|
45
|
+
Appsignal.set_error(e)
|
46
|
+
# Load alternative config
|
47
|
+
config = { :name => ENV["NAME"] }
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
Read more about [Exception handling][exception-handling] in our documentation.
|
52
|
+
|
53
|
+
### Set metadata
|
54
|
+
|
55
|
+
Need more information with errors and performance issues? Add metadata to your
|
56
|
+
requests to identify common factors for problems.
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
Appsignal.set_metadata("user id", user.id)
|
60
|
+
Appsignal.set_metadata("comments count", user.comments.count)
|
61
|
+
```
|
62
|
+
|
63
|
+
### Custom instrumentation
|
64
|
+
|
65
|
+
If you need more fine-grained instrumentation you can add custom
|
66
|
+
instrumentation anywhere in your code.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
# Simple instrumentation
|
70
|
+
Appsignal.instrument("array_to_hash.expensive_logic", "Complex calculations") do
|
71
|
+
Hash[["a", 1], ["b", 2], ["c", 3]]
|
72
|
+
end
|
73
|
+
|
74
|
+
# Add the query that you're monitoring
|
75
|
+
sql = "SELECT * FROM posts ORDER BY created_at DESC LIMIT 1"
|
76
|
+
Appsignal.instrument("fetch.custom_database", "Fetch latest post", sql) do
|
77
|
+
# ...
|
78
|
+
end
|
79
|
+
|
80
|
+
# Nested instrumentation calls are also supported!
|
81
|
+
Appsignal.instrument("fetch.custom_database", "Fetch current user") do
|
82
|
+
# ...
|
83
|
+
|
84
|
+
Appsignal.instrument("write.custom_database", "Write user update") do
|
85
|
+
# ...
|
86
|
+
end
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
Read more about [custom instrumentation][custom-instrumentation] in our
|
91
|
+
documentation.
|
92
|
+
|
93
|
+
## Installation
|
94
|
+
|
95
|
+
First, [sign up][appsignal-sign-up] for an AppSignal account and add the
|
96
|
+
`appsignal` gem to your `Gemfile`. Then, run `bundle install`.
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
# Gemfile
|
100
|
+
gem "appsignal"
|
101
|
+
```
|
102
|
+
|
103
|
+
Afterward, you can use the `appsignal install` command to install AppSignal
|
104
|
+
into your application by using the "Push API key". This will guide you through
|
105
|
+
our installation wizard.
|
106
|
+
|
107
|
+
```sh
|
108
|
+
appsignal install [push api key]
|
109
|
+
```
|
110
|
+
|
111
|
+
Depending on what framework or gems you use some manual integration is
|
112
|
+
required. Follow the steps in the wizard or consult our [Supported systems and
|
113
|
+
frameworks] page for help.
|
114
|
+
|
115
|
+
If you're stuck feel free to [contact us][contact]!
|
116
|
+
|
117
|
+
## Supported frameworks and gems
|
118
|
+
|
119
|
+
AppSignal automatically supports a collection of Ruby frameworks and gems,
|
120
|
+
including but not limited to:
|
121
|
+
|
122
|
+
- Ruby on Rails
|
123
|
+
- Rack
|
124
|
+
- Sinatra
|
125
|
+
- Padrino
|
126
|
+
- Grape
|
127
|
+
- Webmachine
|
128
|
+
- Capistrano
|
129
|
+
- Sidekiq
|
130
|
+
- Delayed Job
|
131
|
+
- Resque
|
132
|
+
- Rake
|
133
|
+
|
134
|
+
AppSignal instrumentation doesn't depend on automatic integrations. It's easy
|
135
|
+
to set up [custom instrumentation][custom-instrumentation] to add keep track of
|
136
|
+
anything.
|
137
|
+
|
138
|
+
For more detailed information and examples please visit our [Supported
|
139
|
+
frameworks][supported-frameworks] page.
|
140
|
+
|
141
|
+
### Front-end monitoring (Beta)
|
142
|
+
|
143
|
+
We have a [Front-end monitoring program][front-end-monitoring] running in Beta
|
144
|
+
currently. Be sure to check it out!
|
145
|
+
|
146
|
+
## Supported systems
|
147
|
+
|
148
|
+
Currently the AppSignal agent works on most Unix-like operating systems, such
|
149
|
+
as most Linux distributions and macOS, excluding Alpine Linux, FreeBSD and
|
150
|
+
Windows.
|
151
|
+
|
152
|
+
For more detailed information please visit our [Supported
|
153
|
+
systems][supported-systems] page.
|
154
|
+
|
12
155
|
## Development
|
13
156
|
|
14
157
|
Make sure you have Bundler installed and then use the Rake install task to
|
15
|
-
install all
|
158
|
+
install all possible dependencies.
|
16
159
|
|
17
160
|
```
|
18
161
|
gem install bundler
|
@@ -40,16 +183,58 @@ BUNDLE_GEMFILE=gemfiles/sinatra.gemfile bundle exec rspec
|
|
40
183
|
BUNDLE_GEMFILE=gemfiles/webmachine.gemfile bundle exec rspec
|
41
184
|
```
|
42
185
|
|
43
|
-
If you have either
|
186
|
+
If you have either [RVM][rvm] or [rbenv][rbenv] installed you can also use
|
44
187
|
`rake generate_bundle_and_spec_all` to generate a script that runs specs for
|
45
188
|
all Ruby versions and gem combinations we support.
|
46
189
|
|
47
190
|
We run the suite against all of the Gemfiles mentioned above and on
|
48
191
|
a number of different Ruby versions.
|
49
192
|
|
50
|
-
|
193
|
+
### Versioning
|
194
|
+
|
195
|
+
This gem uses [Semantic Versioning][semver].
|
196
|
+
|
197
|
+
The `master` branch corresponds to the current stable release of the gem.
|
198
|
+
|
199
|
+
The `develop` branch is used for development of features that will end up in
|
200
|
+
the next minor release.
|
201
|
+
|
202
|
+
Open a Pull Request on the `master` branch if you're fixing a bug. For new new
|
203
|
+
features, open a Pull Request on the `develop` branch.
|
204
|
+
|
205
|
+
Every stable and unstable release is tagged in git with a version tag.
|
206
|
+
|
207
|
+
## Contributing
|
208
|
+
|
209
|
+
Thinking of contributing to our gem? Awesome! 🚀
|
210
|
+
|
211
|
+
Please follow our [Contributing guide][contributing-guide] in our
|
212
|
+
documentation.
|
213
|
+
|
214
|
+
Also, we would be very happy to send you Stroopwafles. Have look at everyone
|
215
|
+
we send a package to so far on our [Stroopwafles page][waffles-page].
|
216
|
+
|
217
|
+
## Support
|
218
|
+
|
219
|
+
[Contact us][contact] and speak directly with the engineers working on
|
220
|
+
AppSignal. They will help you get set up, tweak your code and make sure you get
|
221
|
+
the most out of using AppSignal.
|
222
|
+
|
223
|
+
[appsignal]: https://appsignal.com
|
224
|
+
[appsignal-sign-up]: https://appsignal.com/users/sign_up
|
225
|
+
[contact]: mailto:support@appsignal.com
|
226
|
+
[waffles-page]: https://appsignal.com/waffles
|
227
|
+
[docs]: http://docs.appsignal.com
|
228
|
+
[contributing-guide]: http://docs.appsignal.com/contributing
|
229
|
+
[supported-systems]: http://docs.appsignal.com/getting-started/supported-frameworks.html
|
230
|
+
[supported-frameworks]: http://docs.appsignal.com/getting-started/supported-frameworks.html
|
231
|
+
[custom-instrumentation]: http://docs.appsignal.com/tweaks-in-your-code/custom-instrumentation.html
|
232
|
+
[front-end-monitoring]: http://docs.appsignal.com/tweaks-in-your-code/frontend-error-catching.html
|
233
|
+
[exception-handling]: http://docs.appsignal.com/tweaks-in-your-code/handle-exceptions.html
|
234
|
+
[tagging]: http://docs.appsignal.com/tweaks-in-your-code/handle-exceptions.html#tagging-requests
|
235
|
+
[host-metrics]: http://docs.appsignal.com/getting-started/host-metrics.html
|
236
|
+
[custom-metrics]: http://docs.appsignal.com/getting-started/custom-metrics.html
|
51
237
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
it's a new feature on `develop`.
|
238
|
+
[semver]: http://semver.org/
|
239
|
+
[rvm]: http://rvm.io/
|
240
|
+
[rbenv]: https://github.com/rbenv/rbenv
|
data/lib/appsignal/cli.rb
CHANGED
@@ -2,13 +2,14 @@ require 'optparse'
|
|
2
2
|
require 'logger'
|
3
3
|
require 'yaml'
|
4
4
|
require 'appsignal'
|
5
|
+
require 'appsignal/cli/demo'
|
5
6
|
require 'appsignal/cli/diagnose'
|
6
7
|
require 'appsignal/cli/install'
|
7
8
|
require 'appsignal/cli/notify_of_deploy'
|
8
9
|
|
9
10
|
module Appsignal
|
10
11
|
class CLI
|
11
|
-
AVAILABLE_COMMANDS = %w(diagnose install notify_of_deploy).freeze
|
12
|
+
AVAILABLE_COMMANDS = %w(demo diagnose install notify_of_deploy).freeze
|
12
13
|
|
13
14
|
class << self
|
14
15
|
attr_accessor :options
|
@@ -23,6 +24,8 @@ module Appsignal
|
|
23
24
|
if AVAILABLE_COMMANDS.include?(command)
|
24
25
|
commands[command].parse!(argv)
|
25
26
|
case command.to_sym
|
27
|
+
when :demo
|
28
|
+
Appsignal::CLI::Demo.run(options)
|
26
29
|
when :diagnose
|
27
30
|
Appsignal::CLI::Diagnose.run
|
28
31
|
when :install
|
@@ -72,6 +75,13 @@ module Appsignal
|
|
72
75
|
|
73
76
|
def command_option_parser
|
74
77
|
{
|
78
|
+
'demo' => OptionParser.new do |o|
|
79
|
+
o.banner = 'Usage: appsignal demo [options]'
|
80
|
+
|
81
|
+
o.on '--environment=<rails_env>', "The environment to demo" do |arg|
|
82
|
+
options[:environment] = arg
|
83
|
+
end
|
84
|
+
end,
|
75
85
|
'diagnose' => OptionParser.new,
|
76
86
|
'install' => OptionParser.new,
|
77
87
|
'notify_of_deploy' => OptionParser.new do |o|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "appsignal/demo"
|
2
|
+
|
3
|
+
module Appsignal
|
4
|
+
class CLI
|
5
|
+
class Demo
|
6
|
+
class << self
|
7
|
+
def run(options = {})
|
8
|
+
ENV["APPSIGNAL_APP_ENV"] = options[:environment] if options[:environment]
|
9
|
+
|
10
|
+
puts "Sending demonstration sample data..."
|
11
|
+
if Appsignal::Demo.transmit
|
12
|
+
puts "Demonstration sample data sent!"
|
13
|
+
puts "It may take about a minute for the data to appear on AppSignal.com/accounts"
|
14
|
+
else
|
15
|
+
puts "Error: Unable to start the AppSignal agent and send data to AppSignal.com"
|
16
|
+
puts "Please use `appsignal diagnose` to debug your configuration."
|
17
|
+
exit 1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'erb'
|
2
2
|
require 'ostruct'
|
3
3
|
require 'io/console'
|
4
|
+
require 'appsignal/demo'
|
4
5
|
|
5
6
|
module Appsignal
|
6
7
|
class CLI
|
@@ -199,6 +200,8 @@ module Appsignal
|
|
199
200
|
def configure(config, environments, name_overwritten)
|
200
201
|
install_for_capistrano
|
201
202
|
|
203
|
+
ENV["APPSIGNAL_APP_ENV"] = "development"
|
204
|
+
|
202
205
|
puts "How do you want to configure AppSignal?"
|
203
206
|
puts " (1) a config file"
|
204
207
|
puts " (2) environment variables"
|
@@ -219,6 +222,10 @@ module Appsignal
|
|
219
222
|
puts
|
220
223
|
break
|
221
224
|
elsif input == '2'
|
225
|
+
ENV["APPSIGNAL_ACTIVE"] = "true"
|
226
|
+
ENV["APPSIGNAL_PUSH_API_KEY"] = config[:push_api_key]
|
227
|
+
ENV["APPSIGNAL_APP_NAME"] = config[:name]
|
228
|
+
|
222
229
|
puts
|
223
230
|
puts "Add the following environment variables to configure AppSignal:"
|
224
231
|
puts " export APPSIGNAL_ACTIVE=true"
|
@@ -242,20 +249,19 @@ module Appsignal
|
|
242
249
|
puts colorize "#####################################", :green
|
243
250
|
sleep 0.3
|
244
251
|
puts
|
245
|
-
puts ' Now you need to send us some data...'
|
246
|
-
puts
|
247
252
|
if Gem.win_platform?
|
248
253
|
puts 'The AppSignal agent currently does not work on Windows, please push these changes to your test/staging/production environment'
|
249
254
|
else
|
250
|
-
puts "
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
255
|
+
puts " Sending example data to AppSignal..."
|
256
|
+
if Appsignal::Demo.transmit
|
257
|
+
puts " Example data sent!"
|
258
|
+
puts " It may take about a minute for the data to appear on AppSignal.com/accounts"
|
259
|
+
puts
|
260
|
+
puts " Please return to your browser and follow the instructions."
|
261
|
+
else
|
262
|
+
puts " Couldn't start the AppSignal agent and send example data to AppSignal.com"
|
263
|
+
puts " Please use `appsignal diagnose` to debug your configuration."
|
264
|
+
end
|
259
265
|
end
|
260
266
|
end
|
261
267
|
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "rack/mock"
|
2
|
+
|
3
|
+
module Appsignal
|
4
|
+
class Demo
|
5
|
+
class TestError < StandardError; end
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def transmit
|
9
|
+
Appsignal.start
|
10
|
+
Appsignal.start_logger
|
11
|
+
return false unless Appsignal.active?
|
12
|
+
|
13
|
+
create_example_error_request
|
14
|
+
create_example_performance_request
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def create_example_error_request
|
21
|
+
transaction = Appsignal::Transaction.create(
|
22
|
+
SecureRandom.uuid,
|
23
|
+
Appsignal::Transaction::HTTP_REQUEST,
|
24
|
+
rack_request
|
25
|
+
)
|
26
|
+
begin
|
27
|
+
raise TestError,
|
28
|
+
"Hello world! This is an error used for demonstration purposes."
|
29
|
+
rescue => error
|
30
|
+
Appsignal.set_error(error)
|
31
|
+
end
|
32
|
+
transaction.set_http_or_background_queue_start
|
33
|
+
transaction.set_metadata("path", "/hello")
|
34
|
+
transaction.set_metadata("method", "GET")
|
35
|
+
transaction.set_action("DemoController#hello")
|
36
|
+
add_demo_metadata_to transaction
|
37
|
+
Appsignal::Transaction.complete_current!
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_example_performance_request
|
41
|
+
transaction = Appsignal::Transaction.create(
|
42
|
+
SecureRandom.uuid,
|
43
|
+
Appsignal::Transaction::HTTP_REQUEST,
|
44
|
+
rack_request
|
45
|
+
)
|
46
|
+
Appsignal.instrument "action_view.render", "Render hello.html.erb", "<h1>Hello world!</h1>" do
|
47
|
+
sleep 2
|
48
|
+
end
|
49
|
+
transaction.set_http_or_background_queue_start
|
50
|
+
transaction.set_metadata("path", "/hello")
|
51
|
+
transaction.set_metadata("method", "GET")
|
52
|
+
transaction.set_action("DemoController#hello")
|
53
|
+
add_demo_metadata_to transaction
|
54
|
+
Appsignal::Transaction.complete_current!
|
55
|
+
end
|
56
|
+
|
57
|
+
def add_demo_metadata_to(transaction)
|
58
|
+
transaction.set_metadata("demo_sample", "true")
|
59
|
+
end
|
60
|
+
|
61
|
+
def rack_request
|
62
|
+
env = ::Rack::MockRequest.env_for(
|
63
|
+
"/demo",
|
64
|
+
:params => {
|
65
|
+
"controller" => "demo",
|
66
|
+
"action" => "hello"
|
67
|
+
},
|
68
|
+
"REMOTE_ADDR" => "127.0.0.1",
|
69
|
+
"REQUEST_METHOD" => "GET",
|
70
|
+
"SERVER_NAME" => "localhost",
|
71
|
+
"SERVER_PORT" => "80",
|
72
|
+
"SERVER_PROTOCOL" => "HTTP/1.1",
|
73
|
+
"REQUEST_URI" => "/hello",
|
74
|
+
"PATH_INFO" => "/hello",
|
75
|
+
"HTTP_ACCEPT" => "text/html,application/xhtml+xml",
|
76
|
+
"HTTP_ACCEPT_ENCODING" => "gzip, deflate, sdch",
|
77
|
+
"HTTP_ACCEPT_LANGUAGE" => "en-US,en;q=0.8,nl;q=0.6",
|
78
|
+
"HTTP_CACHE_CONTROL" => "max-age=0",
|
79
|
+
"HTTP_CONNECTION" => "keep-alive",
|
80
|
+
"HTTP_USER_AGENT" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0)",
|
81
|
+
"HTTP_REFERER" => "http://appsignal.com/accounts"
|
82
|
+
)
|
83
|
+
::Rack::Request.new(env)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/appsignal/version.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
require "appsignal/cli"
|
2
|
+
|
3
|
+
describe Appsignal::CLI::Demo do
|
4
|
+
include CLIHelpers
|
5
|
+
|
6
|
+
let(:options) { {} }
|
7
|
+
let(:out_stream) { StringIO.new }
|
8
|
+
let(:output) { out_stream.string }
|
9
|
+
before do
|
10
|
+
ENV.delete("APPSIGNAL_APP_ENV")
|
11
|
+
ENV.delete("RAILS_ENV")
|
12
|
+
ENV.delete("RACK_ENV")
|
13
|
+
stub_api_request config, "auth"
|
14
|
+
end
|
15
|
+
after { Appsignal.config = nil }
|
16
|
+
around { |example| capture_stdout(out_stream) { example.run } }
|
17
|
+
|
18
|
+
def run
|
19
|
+
run_within_dir project_fixture_path
|
20
|
+
end
|
21
|
+
|
22
|
+
def run_within_dir(chdir)
|
23
|
+
Dir.chdir chdir do
|
24
|
+
run_cli("demo", options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "without configuration" do
|
29
|
+
let(:config) { Appsignal::Config.new("development", tmp_dir) }
|
30
|
+
|
31
|
+
it "returns an error" do
|
32
|
+
expect { run_within_dir tmp_dir }.to raise_error(SystemExit)
|
33
|
+
|
34
|
+
expect(output).to include("Error: Unable to start the AppSignal agent")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with configuration" do
|
39
|
+
let(:config) { project_fixture_config }
|
40
|
+
before do
|
41
|
+
# Ignore sleeps to speed up the test
|
42
|
+
allow(Appsignal::Demo).to receive(:sleep)
|
43
|
+
end
|
44
|
+
|
45
|
+
context "without environment" do
|
46
|
+
it "returns an error" do
|
47
|
+
expect { run_within_dir tmp_dir }.to raise_error(SystemExit)
|
48
|
+
|
49
|
+
expect(output).to include("Error: Unable to start the AppSignal agent")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "with environment" do
|
54
|
+
let(:options) { { :environment => "development" } }
|
55
|
+
|
56
|
+
it "calls Appsignal::Demo transmitter" do
|
57
|
+
expect(Appsignal::Demo).to receive(:transmit).and_return(true)
|
58
|
+
run
|
59
|
+
end
|
60
|
+
|
61
|
+
it "outputs message" do
|
62
|
+
run
|
63
|
+
expect(output).to include("Demonstration sample data sent!")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -429,13 +429,31 @@ describe Appsignal::CLI::Install do
|
|
429
429
|
end
|
430
430
|
|
431
431
|
context "not on windows" do
|
432
|
-
before
|
433
|
-
|
434
|
-
|
432
|
+
before { Gem.stub(:win_platform? => false) }
|
433
|
+
|
434
|
+
context "with demo data sent" do
|
435
|
+
before do
|
436
|
+
expect(Appsignal::Demo).to receive(:transmit).and_return(true)
|
437
|
+
cli.done_notice
|
438
|
+
end
|
439
|
+
|
440
|
+
it "prints sending demo data" do
|
441
|
+
expect(subject).to include "Sending example data to AppSignal", "Example data sent!"
|
442
|
+
end
|
435
443
|
end
|
436
444
|
|
437
|
-
|
438
|
-
|
445
|
+
context "without demo data being sent" do
|
446
|
+
before do
|
447
|
+
expect(Appsignal::Demo).to receive(:transmit).and_return(false)
|
448
|
+
cli.done_notice
|
449
|
+
end
|
450
|
+
|
451
|
+
it "prints that it couldn't send the demo data" do
|
452
|
+
expect(subject).to include "Sending example data to AppSignal",
|
453
|
+
"Couldn't start the AppSignal agent and send example data",
|
454
|
+
"`appsignal diagnose`"
|
455
|
+
end
|
456
|
+
end
|
439
457
|
end
|
440
458
|
end
|
441
459
|
|
@@ -25,7 +25,8 @@ describe Appsignal::CLI do
|
|
25
25
|
}.should raise_error(SystemExit)
|
26
26
|
|
27
27
|
out_stream.string.should include 'appsignal <command> [options]'
|
28
|
-
out_stream.string.should include
|
28
|
+
out_stream.string.should include \
|
29
|
+
'Available commands: demo, diagnose, install, notify_of_deploy'
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require "appsignal/demo"
|
2
|
+
|
3
|
+
describe Appsignal::Demo do
|
4
|
+
before do
|
5
|
+
# Ignore sleeps to speed up the test
|
6
|
+
allow(described_class).to receive(:sleep)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".transmit" do
|
10
|
+
subject { described_class.transmit }
|
11
|
+
|
12
|
+
context "without config" do
|
13
|
+
it "returns false" do
|
14
|
+
expect(subject).to be_false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with config" do
|
19
|
+
let(:config) { project_fixture_config("production") }
|
20
|
+
before { Appsignal.config = config }
|
21
|
+
|
22
|
+
it "returns true" do
|
23
|
+
expect(subject).to be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "creates demonstration samples" do
|
27
|
+
expect(described_class).to receive(:create_example_error_request)
|
28
|
+
expect(described_class).to receive(:create_example_performance_request)
|
29
|
+
subject
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe ".create_example_error_request" do
|
35
|
+
let!(:error_transaction) { http_request_transaction }
|
36
|
+
let(:config) { project_fixture_config("production") }
|
37
|
+
before do
|
38
|
+
Appsignal.config = config
|
39
|
+
expect(Appsignal::Transaction).to receive(:create)
|
40
|
+
.ordered
|
41
|
+
.with(kind_of(String), Appsignal::Transaction::HTTP_REQUEST, kind_of(::Rack::Request))
|
42
|
+
.and_return(error_transaction)
|
43
|
+
end
|
44
|
+
subject { described_class.send(:create_example_error_request) }
|
45
|
+
|
46
|
+
it "sets an error" do
|
47
|
+
expect(error_transaction).to receive(:set_error).with(kind_of(described_class::TestError))
|
48
|
+
expect(error_transaction).to receive(:set_metadata).with("path", "/hello")
|
49
|
+
expect(error_transaction).to receive(:set_metadata).with("method", "GET")
|
50
|
+
expect(error_transaction).to receive(:set_metadata).with("demo_sample", "true")
|
51
|
+
subject
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe ".create_example_performance_request" do
|
56
|
+
let!(:performance_transaction) { http_request_transaction }
|
57
|
+
let(:config) { project_fixture_config("production") }
|
58
|
+
before do
|
59
|
+
Appsignal.config = config
|
60
|
+
expect(Appsignal::Transaction).to receive(:create)
|
61
|
+
.with(kind_of(String), Appsignal::Transaction::HTTP_REQUEST, kind_of(::Rack::Request))
|
62
|
+
.and_return(performance_transaction)
|
63
|
+
end
|
64
|
+
subject { described_class.send(:create_example_performance_request) }
|
65
|
+
|
66
|
+
it "sends a performance sample" do
|
67
|
+
expect(performance_transaction).to receive(:start_event)
|
68
|
+
expect(performance_transaction).to receive(:finish_event).with(
|
69
|
+
"action_view.render",
|
70
|
+
"Render hello.html.erb",
|
71
|
+
"<h1>Hello world!</h1>",
|
72
|
+
Appsignal::EventFormatter::DEFAULT
|
73
|
+
)
|
74
|
+
expect(performance_transaction).to receive(:set_metadata).with("path", "/hello")
|
75
|
+
expect(performance_transaction).to receive(:set_metadata).with("method", "GET")
|
76
|
+
expect(performance_transaction).to receive(:set_metadata).with("demo_sample", "true")
|
77
|
+
subject
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -886,11 +886,22 @@ describe Appsignal::Transaction do
|
|
886
886
|
end
|
887
887
|
|
888
888
|
describe "#cleaned_backtrace" do
|
889
|
-
subject { transaction.send(:cleaned_backtrace, ['line 1']) }
|
889
|
+
subject { transaction.send(:cleaned_backtrace, ['line 1', 'line 2']) }
|
890
890
|
|
891
|
-
it
|
891
|
+
it "returns the backtrace" do
|
892
|
+
expect(subject).to eq ['line 1', 'line 2']
|
893
|
+
end
|
892
894
|
|
893
|
-
|
895
|
+
if rails_present?
|
896
|
+
context "with rails" do
|
897
|
+
it "cleans the backtrace with the Rails backtrace cleaner" do
|
898
|
+
::Rails.backtrace_cleaner.add_filter do |line|
|
899
|
+
line.tr("2", "?")
|
900
|
+
end
|
901
|
+
expect(subject).to eq ['line 1', 'line ?']
|
902
|
+
end
|
903
|
+
end
|
904
|
+
end
|
894
905
|
end
|
895
906
|
end
|
896
907
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-10-
|
12
|
+
date: 2016-10-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -151,10 +151,12 @@ files:
|
|
151
151
|
- lib/appsignal/auth_check.rb
|
152
152
|
- lib/appsignal/capistrano.rb
|
153
153
|
- lib/appsignal/cli.rb
|
154
|
+
- lib/appsignal/cli/demo.rb
|
154
155
|
- lib/appsignal/cli/diagnose.rb
|
155
156
|
- lib/appsignal/cli/install.rb
|
156
157
|
- lib/appsignal/cli/notify_of_deploy.rb
|
157
158
|
- lib/appsignal/config.rb
|
159
|
+
- lib/appsignal/demo.rb
|
158
160
|
- lib/appsignal/event_formatter.rb
|
159
161
|
- lib/appsignal/event_formatter/action_view/render_formatter.rb
|
160
162
|
- lib/appsignal/event_formatter/active_record/instantiation_formatter.rb
|
@@ -216,11 +218,13 @@ files:
|
|
216
218
|
- spec/lib/appsignal/auth_check_spec.rb
|
217
219
|
- spec/lib/appsignal/capistrano2_spec.rb
|
218
220
|
- spec/lib/appsignal/capistrano3_spec.rb
|
221
|
+
- spec/lib/appsignal/cli/demo_spec.rb
|
219
222
|
- spec/lib/appsignal/cli/diagnose_spec.rb
|
220
223
|
- spec/lib/appsignal/cli/install_spec.rb
|
221
224
|
- spec/lib/appsignal/cli/notify_of_deploy_spec.rb
|
222
225
|
- spec/lib/appsignal/cli_spec.rb
|
223
226
|
- spec/lib/appsignal/config_spec.rb
|
227
|
+
- spec/lib/appsignal/demo_spec.rb
|
224
228
|
- spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
|
225
229
|
- spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb
|
226
230
|
- spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb
|
@@ -321,9 +325,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
321
325
|
version: '1.9'
|
322
326
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
323
327
|
requirements:
|
324
|
-
- - "
|
328
|
+
- - ">="
|
325
329
|
- !ruby/object:Gem::Version
|
326
|
-
version:
|
330
|
+
version: '0'
|
327
331
|
requirements: []
|
328
332
|
rubyforge_project:
|
329
333
|
rubygems_version: 2.5.1
|
@@ -334,11 +338,13 @@ test_files:
|
|
334
338
|
- spec/lib/appsignal/auth_check_spec.rb
|
335
339
|
- spec/lib/appsignal/capistrano2_spec.rb
|
336
340
|
- spec/lib/appsignal/capistrano3_spec.rb
|
341
|
+
- spec/lib/appsignal/cli/demo_spec.rb
|
337
342
|
- spec/lib/appsignal/cli/diagnose_spec.rb
|
338
343
|
- spec/lib/appsignal/cli/install_spec.rb
|
339
344
|
- spec/lib/appsignal/cli/notify_of_deploy_spec.rb
|
340
345
|
- spec/lib/appsignal/cli_spec.rb
|
341
346
|
- spec/lib/appsignal/config_spec.rb
|
347
|
+
- spec/lib/appsignal/demo_spec.rb
|
342
348
|
- spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb
|
343
349
|
- spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb
|
344
350
|
- spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb
|