appoptics_apm 4.0.3 → 4.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile_test +6 -7
- data/README.md +3 -3
- data/Rakefile +3 -2
- data/appoptics_apm.gemspec +2 -2
- data/docker-compose.yml +0 -22
- data/ext/oboe_metal/extconf.rb +4 -0
- data/lib/appoptics_apm/config.rb +11 -6
- data/lib/appoptics_apm/version.rb +1 -1
- metadata +3 -202
- data/gemfiles/delayed_job.gemfile +0 -36
- data/gemfiles/frameworks.gemfile +0 -44
- data/gemfiles/instrumentation_mocked.gemfile +0 -29
- data/gemfiles/libraries.gemfile +0 -85
- data/gemfiles/noop.gemfile +0 -17
- data/gemfiles/rails23.gemfile +0 -39
- data/gemfiles/rails30.gemfile +0 -42
- data/gemfiles/rails31.gemfile +0 -44
- data/gemfiles/rails32.gemfile +0 -54
- data/gemfiles/rails40.gemfile +0 -27
- data/gemfiles/rails41.gemfile +0 -27
- data/gemfiles/rails42.gemfile +0 -35
- data/gemfiles/rails50.gemfile +0 -44
- data/gemfiles/rails51.gemfile +0 -44
- data/test/benchmark/README.md +0 -65
- data/test/benchmark/logging_bench.rb +0 -54
- data/test/benchmark/with_libraries_gemfile/bunny_bench.rb +0 -69
- data/test/benchmark/with_rails5x_gemfile/action_controller5x_bench.rb +0 -43
- data/test/frameworks/apps/grape_nested.rb +0 -33
- data/test/frameworks/apps/grape_simple.rb +0 -80
- data/test/frameworks/apps/padrino_simple.rb +0 -80
- data/test/frameworks/apps/sinatra_simple.rb +0 -55
- data/test/frameworks/grape_test.rb +0 -286
- data/test/frameworks/padrino_test.rb +0 -222
- data/test/frameworks/rails3x_test.rb +0 -554
- data/test/frameworks/rails4x_test.rb +0 -570
- data/test/frameworks/rails5x_api_test.rb +0 -210
- data/test/frameworks/rails5x_test.rb +0 -376
- data/test/frameworks/rails_shared_tests.rb +0 -172
- data/test/frameworks/sinatra_test.rb +0 -140
- data/test/instrumentation/bunny_client_test.rb +0 -276
- data/test/instrumentation/bunny_consumer_test.rb +0 -204
- data/test/instrumentation/curb_test.rb +0 -398
- data/test/instrumentation/dalli_test.rb +0 -177
- data/test/instrumentation/em_http_request_test.rb +0 -89
- data/test/instrumentation/excon_test.rb +0 -231
- data/test/instrumentation/faraday_test.rb +0 -228
- data/test/instrumentation/http_test.rb +0 -143
- data/test/instrumentation/httpclient_test.rb +0 -304
- data/test/instrumentation/memcache_test.rb +0 -260
- data/test/instrumentation/memcached_test.rb +0 -229
- data/test/instrumentation/mongo_v1_test.rb +0 -479
- data/test/instrumentation/mongo_v2_index_test.rb +0 -124
- data/test/instrumentation/mongo_v2_test.rb +0 -584
- data/test/instrumentation/mongo_v2_view_test.rb +0 -435
- data/test/instrumentation/moped_test.rb +0 -517
- data/test/instrumentation/rack_test.rb +0 -165
- data/test/instrumentation/redis_hashes_test.rb +0 -268
- data/test/instrumentation/redis_keys_test.rb +0 -321
- data/test/instrumentation/redis_lists_test.rb +0 -310
- data/test/instrumentation/redis_misc_test.rb +0 -163
- data/test/instrumentation/redis_sets_test.rb +0 -296
- data/test/instrumentation/redis_sortedsets_test.rb +0 -328
- data/test/instrumentation/redis_strings_test.rb +0 -349
- data/test/instrumentation/resque_test.rb +0 -185
- data/test/instrumentation/rest-client_test.rb +0 -288
- data/test/instrumentation/sequel_mysql2_test.rb +0 -353
- data/test/instrumentation/sequel_mysql_test.rb +0 -334
- data/test/instrumentation/sequel_pg_test.rb +0 -336
- data/test/instrumentation/sidekiq-client_test.rb +0 -159
- data/test/instrumentation/sidekiq-worker_test.rb +0 -180
- data/test/instrumentation/twitter-cassandra_test.rb +0 -424
- data/test/instrumentation/typhoeus_test.rb +0 -284
- data/test/jobs/delayed_job/db_worker_job.rb +0 -29
- data/test/jobs/delayed_job/error_worker_job.rb +0 -10
- data/test/jobs/delayed_job/remote_call_worker_job.rb +0 -20
- data/test/jobs/resque/db_worker_job.rb +0 -29
- data/test/jobs/resque/error_worker_job.rb +0 -10
- data/test/jobs/resque/remote_call_worker_job.rb +0 -20
- data/test/jobs/sidekiq/db_worker_job.rb +0 -29
- data/test/jobs/sidekiq/error_worker_job.rb +0 -10
- data/test/jobs/sidekiq/remote_call_worker_job.rb +0 -20
- data/test/minitest_helper.rb +0 -277
- data/test/mocked/curb_mocked_test.rb +0 -324
- data/test/mocked/excon_mocked_test.rb +0 -174
- data/test/mocked/faraday_mocked_test.rb +0 -97
- data/test/mocked/http_mocked_test.rb +0 -135
- data/test/mocked/httpclient_mocked_test.rb +0 -258
- data/test/mocked/rest_client_mocked_test.rb +0 -109
- data/test/mocked/typhoeus_mocked_test.rb +0 -207
- data/test/models/widget.rb +0 -36
- data/test/noop/noop_test.rb +0 -145
- data/test/profiling/legacy_method_profiling_test.rb +0 -201
- data/test/profiling/method_profiling_test.rb +0 -631
- data/test/queues/delayed_job-client_test.rb +0 -95
- data/test/queues/delayed_job-worker_test.rb +0 -91
- data/test/reporter/reporter_test.rb +0 -14
- data/test/servers/delayed_job.rb +0 -107
- data/test/servers/rackapp_8101.rb +0 -29
- data/test/servers/rails3x_8140.rb +0 -96
- data/test/servers/rails4x_8140.rb +0 -96
- data/test/servers/rails5x_8140.rb +0 -95
- data/test/servers/rails5x_api_8150.rb +0 -78
- data/test/servers/sidekiq.rb +0 -29
- data/test/servers/sidekiq.yml +0 -7
- data/test/servers/sidekiq_initializer.rb +0 -25
- data/test/settings +0 -0
- data/test/support/auto_tracing_test.rb +0 -50
- data/test/support/backcompat_test.rb +0 -276
- data/test/support/config_test.rb +0 -149
- data/test/support/dnt_test.rb +0 -98
- data/test/support/init_report_test.rb +0 -25
- data/test/support/liboboe_settings_test.rb +0 -110
- data/test/support/logging_test.rb +0 -130
- data/test/support/sql_sanitize_test.rb +0 -55
- data/test/support/tracing_mode_test.rb +0 -33
- data/test/support/tvalias_test.rb +0 -15
- data/test/support/xtrace_test.rb +0 -41
data/gemfiles/rails50.gemfile
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gem 'rails', '>= 5.0.0.rc1', '< 5.1'
|
4
|
-
gem 'sass-rails', '~> 5.0'
|
5
|
-
gem 'uglifier', '>= 1.3.0'
|
6
|
-
gem 'coffee-rails', '~> 4.1.0'
|
7
|
-
gem 'therubyracer', platforms: :ruby
|
8
|
-
gem 'jquery-rails'
|
9
|
-
gem 'turbolinks', '~> 5.x'
|
10
|
-
gem 'jbuilder', '~> 2.0'
|
11
|
-
|
12
|
-
group :development do
|
13
|
-
# Access an IRB console on exception pages or by using <%= console %> in views
|
14
|
-
gem 'web-console', '~> 3.0'
|
15
|
-
gem 'listen', '~> 3.0.5'
|
16
|
-
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
17
|
-
gem 'spring'
|
18
|
-
gem 'spring-watcher-listen', '~> 2.0.0'
|
19
|
-
end
|
20
|
-
|
21
|
-
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
22
|
-
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
23
|
-
|
24
|
-
group :development, :test do
|
25
|
-
gem 'rake'
|
26
|
-
gem 'minitest'
|
27
|
-
gem 'minitest-reporters', '< 1.0.18'
|
28
|
-
gem 'minitest-debugger', :require => false
|
29
|
-
gem 'mocha'
|
30
|
-
gem 'rack-test'
|
31
|
-
gem 'puma', '< 3.1.0'
|
32
|
-
gem 'bson', '< 4.0'
|
33
|
-
end
|
34
|
-
|
35
|
-
if defined?(JRUBY_VERSION)
|
36
|
-
gem 'activerecord-jdbc-adapter'
|
37
|
-
gem 'jdbc-postgresql'
|
38
|
-
else
|
39
|
-
gem 'pg', '< 1.0.0' # rails is not ready for pg 1.0
|
40
|
-
gem 'mysql2'
|
41
|
-
end
|
42
|
-
|
43
|
-
gemspec :path => File.expand_path(File.dirname(__FILE__) + '/../')
|
44
|
-
# vim:syntax=ruby
|
data/gemfiles/rails51.gemfile
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gem 'rails', '~> 5.1'
|
4
|
-
gem 'sass-rails'
|
5
|
-
gem 'uglifier'
|
6
|
-
gem 'coffee-rails'
|
7
|
-
gem 'therubyracer', platforms: :ruby
|
8
|
-
gem 'jquery-rails'
|
9
|
-
gem 'turbolinks'
|
10
|
-
gem 'jbuilder'
|
11
|
-
|
12
|
-
group :development do
|
13
|
-
# Access an IRB console on exception pages or by using <%= console %> in views
|
14
|
-
gem 'web-console'
|
15
|
-
gem 'listen'
|
16
|
-
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
17
|
-
gem 'spring'
|
18
|
-
gem 'spring-watcher-listen'
|
19
|
-
end
|
20
|
-
|
21
|
-
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
22
|
-
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
23
|
-
|
24
|
-
group :development, :test do
|
25
|
-
gem 'rake'
|
26
|
-
gem 'minitest'
|
27
|
-
gem 'minitest-reporters'
|
28
|
-
gem 'minitest-debugger', :require => false
|
29
|
-
gem 'mocha'
|
30
|
-
gem 'rack-test'
|
31
|
-
gem 'puma'
|
32
|
-
gem 'bson'
|
33
|
-
end
|
34
|
-
|
35
|
-
if defined?(JRUBY_VERSION)
|
36
|
-
gem 'activerecord-jdbc-adapter'
|
37
|
-
gem 'jdbc-postgresql'
|
38
|
-
else
|
39
|
-
gem 'pg', '< 1.0.0' # rails is not ready for pg 1.0
|
40
|
-
gem 'mysql2'
|
41
|
-
end
|
42
|
-
|
43
|
-
gemspec :path => File.expand_path(File.dirname(__FILE__) + '/../')
|
44
|
-
# vim:syntax=ruby
|
data/test/benchmark/README.md
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
#Micro Benchmarking
|
2
|
-
|
3
|
-
Work In Progress
|
4
|
-
|
5
|
-
In this folder there are samples for doing microbenchmarks.
|
6
|
-
|
7
|
-
They are in folders with names indicating which gemfile needs to be set, eg:
|
8
|
-
```
|
9
|
-
export BUNDLE_GEMFILE=gemfiles/libraries.gemfile
|
10
|
-
bundle install
|
11
|
-
```
|
12
|
-
|
13
|
-
The gems used are `benchmark-ips` and `benchmark-memory` to compare performance and memory usage between different
|
14
|
-
versions of code.
|
15
|
-
|
16
|
-
The variable `ENV['TEST_AB']` is used to define which version of code to run.
|
17
|
-
|
18
|
-
**!!! It is very important to remove `ENV['TEST_AB']` before commiting code !!!**
|
19
|
-
|
20
|
-
###Example of setup for benchmarking:
|
21
|
-
|
22
|
-
The benchmarking code to be run:
|
23
|
-
```
|
24
|
-
Benchmark.ips do |x|
|
25
|
-
x.config(:time => 20, :warmup => 20, :iterations => 3)
|
26
|
-
@conn = Bunny.new(@connection_params)
|
27
|
-
@conn.start
|
28
|
-
@channel = @conn.create_channel
|
29
|
-
@queue = @channel.queue("ao.ruby.test")
|
30
|
-
@exchange = @channel.topic("ao.ruby.topic.tests", :auto_delete => true)
|
31
|
-
|
32
|
-
x.report('bunny_pub_sampling_A') do
|
33
|
-
ENV['TEST_AB'] = 'A'
|
34
|
-
AppOpticsAPM.loaded = true
|
35
|
-
AppOpticsAPM::Config[:tracing_mode] = 'always'
|
36
|
-
AppOpticsAPM::Context.fromString('2B7435A9FE510AE4533414D425DADF4E180D2B4E3649E60702469DB05F00')
|
37
|
-
|
38
|
-
dostuff(@exchange)
|
39
|
-
end
|
40
|
-
|
41
|
-
x.report('bunny_pub_sampling_B') do
|
42
|
-
ENV['TEST_AB'] = 'B'
|
43
|
-
AppOpticsAPM.loaded = true
|
44
|
-
AppOpticsAPM::Config[:tracing_mode] = 'always'
|
45
|
-
AppOpticsAPM::Context.fromString('2B7435A9FE510AE4533414D425DADF4E180D2B4E3649E60702469DB05F00')
|
46
|
-
|
47
|
-
dostuff(@exchange)
|
48
|
-
end
|
49
|
-
|
50
|
-
x.compare!
|
51
|
-
end
|
52
|
-
```
|
53
|
-
The code to be benchmarked:
|
54
|
-
```
|
55
|
-
def basic_publish_with_appoptics(payload, exchange, routing_key, opts = {})
|
56
|
-
# If we're not tracing, just do a fast return.
|
57
|
-
return basic_publish_without_appoptics(payload, exchange, routing_key, opts) if !AppOpticsAPM.tracing? && ENV['TEST_AB'] == 'B'
|
58
|
-
|
59
|
-
begin
|
60
|
-
kvs = collect_channel_kvs
|
61
|
-
if exchange.respond_to?(:name)
|
62
|
-
kvs[:ExchangeName] = exchange.name
|
63
|
-
elsif exchange.respond_to?(:empty?) && !exchange.empty?
|
64
|
-
...
|
65
|
-
```
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# Copyright (c) 2017 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
require 'benchmark/ips'
|
5
|
-
require_relative '../minitest_helper'
|
6
|
-
|
7
|
-
|
8
|
-
# compare logging when testing for loaded versus tracing?
|
9
|
-
ENV['APPOPTICS_GEM_VERBOSE'] = 'false'
|
10
|
-
|
11
|
-
n = 1000
|
12
|
-
|
13
|
-
Benchmark.ips do |x|
|
14
|
-
x.config(:time => 10, :warmup => 2)
|
15
|
-
|
16
|
-
# x.report('tracing_f') do
|
17
|
-
# AppOpticsAPM.loaded = false
|
18
|
-
# AppOpticsAPM::Config[:tracing_mode] = 'never'
|
19
|
-
# AppOpticsAPM::Context.fromString('2B7435A9FE510AE4533414D425DADF4E180D2B4E3649E60702469DB05F00')
|
20
|
-
# n.times do
|
21
|
-
# AppOpticsAPM.tracing?
|
22
|
-
# end
|
23
|
-
# end
|
24
|
-
# x.report('tracing_n') do
|
25
|
-
# AppOpticsAPM.loaded = true
|
26
|
-
# AppOpticsAPM::Config[:tracing_mode] = 'never'
|
27
|
-
# AppOpticsAPM::Context.fromString('2B7435A9FE510AE4533414D425DADF4E180D2B4E3649E60702469DB05F00')
|
28
|
-
# n.times do
|
29
|
-
# AppOpticsAPM.tracing?
|
30
|
-
# end
|
31
|
-
# end
|
32
|
-
|
33
|
-
x.report('tracing_tf') do
|
34
|
-
AppOpticsAPM.loaded = true
|
35
|
-
AppOpticsAPM::Config[:tracing_mode] = 'always'
|
36
|
-
AppOpticsAPM::Context.fromString('2B7435A9FE510AE4533414D425DADF4E180D2B4E3649E60702469DB05F00')
|
37
|
-
n.times do
|
38
|
-
AppOpticsAPM.tracing?
|
39
|
-
end
|
40
|
-
end
|
41
|
-
x.report('tracing_tt') do
|
42
|
-
AppOpticsAPM.loaded = true
|
43
|
-
AppOpticsAPM::Config[:tracing_mode] = 'always'
|
44
|
-
AppOpticsAPM::Context.fromString('2B7435A9FE510AE4533414D425DADF4E180D2B4E3649E60702469DB05F01')
|
45
|
-
n.times do
|
46
|
-
AppOpticsAPM.tracing?
|
47
|
-
AppOpticsAPM.tracing?
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
x.compare!
|
52
|
-
end
|
53
|
-
|
54
|
-
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# Copyright (c) 2017 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
require 'benchmark/ips'
|
5
|
-
require_relative '../../minitest_helper'
|
6
|
-
|
7
|
-
|
8
|
-
# compare logging when testing for loaded versus tracing?
|
9
|
-
ENV['APPOPTICS_GEM_VERBOSE'] = 'false'
|
10
|
-
|
11
|
-
ENV['APPOPTICS_RABBITMQ_SERVER'] = "127.0.0.1" unless ENV['APPOPTICS_RABBITMQ_SERVER']
|
12
|
-
ENV['APPOPTICS_RABBITMQ_PORT'] = "5672" unless ENV['APPOPTICS_RABBITMQ_PORT']
|
13
|
-
ENV['APPOPTICS_RABBITMQ_USERNAME'] = "guest" unless ENV['APPOPTICS_RABBITMQ_USERNAME']
|
14
|
-
ENV['APPOPTICS_RABBITMQ_PASSWORD'] = "guest" unless ENV['APPOPTICS_RABBITMQ_PASSWORD']
|
15
|
-
ENV['APPOPTICS_RABBITMQ_VHOST'] = "/" unless ENV['APPOPTICS_RABBITMQ_VHOST']
|
16
|
-
|
17
|
-
@connection_params = {}
|
18
|
-
@connection_params[:host] = ENV['APPOPTICS_RABBITMQ_SERVER']
|
19
|
-
@connection_params[:port] = ENV['APPOPTICS_RABBITMQ_PORT']
|
20
|
-
@connection_params[:vhost] = ENV['APPOPTICS_RABBITMQ_VHOST']
|
21
|
-
@connection_params[:user] = ENV['APPOPTICS_RABBITMQ_USERNAME']
|
22
|
-
@connection_params[:pass] = ENV['APPOPTICS_RABBITMQ_PASSWORD']
|
23
|
-
|
24
|
-
def dostuff(exchange)
|
25
|
-
# require 'ruby-prof'
|
26
|
-
|
27
|
-
# profile the code
|
28
|
-
# RubyProf.start
|
29
|
-
|
30
|
-
n = 100
|
31
|
-
|
32
|
-
n.times do
|
33
|
-
exchange.publish("The Tortoise and the Hare", :routing_key => @queue.name)
|
34
|
-
end
|
35
|
-
|
36
|
-
# result = RubyProf.stop
|
37
|
-
# print a flat profile to text
|
38
|
-
# printer = RubyProf::FlatPrinter.new(result)
|
39
|
-
# printer.print(STDOUT)
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
Benchmark.ips do |x|
|
44
|
-
x.config(:time => 20, :warmup => 20, :iterations => 3)
|
45
|
-
@conn = Bunny.new(@connection_params)
|
46
|
-
@conn.start
|
47
|
-
@channel = @conn.create_channel
|
48
|
-
@queue = @channel.queue("ao.ruby.test")
|
49
|
-
@exchange = @channel.topic("ao.ruby.topic.tests", :auto_delete => true)
|
50
|
-
|
51
|
-
x.report('bunny_pub_sampling_A') do
|
52
|
-
ENV['TEST_AB'] = 'A'
|
53
|
-
AppOpticsAPM.loaded = true
|
54
|
-
AppOpticsAPM::Config[:tracing_mode] = 'always'
|
55
|
-
AppOpticsAPM::Context.fromString('2B7435A9FE510AE4533414D425DADF4E180D2B4E3649E60702469DB05F00')
|
56
|
-
|
57
|
-
dostuff(@exchange)
|
58
|
-
end
|
59
|
-
x.report('bunny_pub_sampling_B') do
|
60
|
-
ENV['TEST_AB'] = 'B'
|
61
|
-
AppOpticsAPM.loaded = true
|
62
|
-
AppOpticsAPM::Config[:tracing_mode] = 'always'
|
63
|
-
AppOpticsAPM::Context.fromString('2B7435A9FE510AE4533414D425DADF4E180D2B4E3649E60702469DB05F00')
|
64
|
-
|
65
|
-
dostuff(@exchange)
|
66
|
-
end
|
67
|
-
|
68
|
-
x.compare!
|
69
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# Copyright (c) 2017 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
require 'benchmark/ips'
|
5
|
-
require 'benchmark/memory'
|
6
|
-
require_relative '../../minitest_helper'
|
7
|
-
|
8
|
-
# compare logging when testing for loaded versus tracing?
|
9
|
-
ENV['APPOPTICS_GEM_VERBOSE'] = 'false'
|
10
|
-
ENV['DBTYPE'] = "postgresql" unless ENV['DBTYPE']
|
11
|
-
|
12
|
-
def dostuff(uri)
|
13
|
-
n = 100
|
14
|
-
n.times do
|
15
|
-
Net::HTTP.get_response(uri)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
Benchmark.memory do |x|
|
21
|
-
AppOpticsAPM::Config[:action_controller][:collect_backtraces] = false
|
22
|
-
# x.config(:time => 20, :warmup => 20, :iterations => 3)
|
23
|
-
uri = URI.parse('http://127.0.0.1:8140/hello/world')
|
24
|
-
|
25
|
-
x.report('controller_A') do
|
26
|
-
ENV['TEST_AB'] = 'A'
|
27
|
-
AppOpticsAPM.loaded = true
|
28
|
-
AppOpticsAPM::Config[:tracing_mode] = 'always'
|
29
|
-
AppOpticsAPM::Context.fromString('2B7435A9FE510AE4533414D425DADF4E180D2B4E3649E60702469DB05F00')
|
30
|
-
|
31
|
-
dostuff(uri)
|
32
|
-
end
|
33
|
-
x.report('controller_B') do
|
34
|
-
ENV['TEST_AB'] = 'B'
|
35
|
-
AppOpticsAPM.loaded = true
|
36
|
-
AppOpticsAPM::Config[:tracing_mode] = 'always'
|
37
|
-
AppOpticsAPM::Context.fromString('2B7435A9FE510AE4533414D425DADF4E180D2B4E3649E60702469DB05F00')
|
38
|
-
|
39
|
-
dostuff(uri)
|
40
|
-
end
|
41
|
-
|
42
|
-
x.compare!
|
43
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
require 'grape'
|
5
|
-
|
6
|
-
class Wrapper < Grape::API
|
7
|
-
class GrapeSimple < Grape::API
|
8
|
-
rescue_from :all do |e|
|
9
|
-
error_response({ message: "rescued from #{e.class.name}" })
|
10
|
-
end
|
11
|
-
|
12
|
-
get '/json_endpoint' do
|
13
|
-
present({ :test => true })
|
14
|
-
end
|
15
|
-
|
16
|
-
get "/break" do
|
17
|
-
raise Exception.new("This should have http status code 500!")
|
18
|
-
end
|
19
|
-
|
20
|
-
get "/error" do
|
21
|
-
error!("This is a error with 'error'!")
|
22
|
-
end
|
23
|
-
|
24
|
-
get "/breakstring" do
|
25
|
-
raise "This should have http status code 500!"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class GrapeNested < Grape::API
|
31
|
-
mount Wrapper::GrapeSimple
|
32
|
-
end
|
33
|
-
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
require 'grape'
|
5
|
-
|
6
|
-
class GrapeSimple < Grape::API
|
7
|
-
rescue_from :all do |e|
|
8
|
-
error_response({ message: "rescued from #{e.class.name}" })
|
9
|
-
end
|
10
|
-
|
11
|
-
get '/index' do
|
12
|
-
present( )
|
13
|
-
end
|
14
|
-
|
15
|
-
get '/json_endpoint' do
|
16
|
-
present({ :test => true })
|
17
|
-
end
|
18
|
-
|
19
|
-
get "/break" do
|
20
|
-
raise Exception.new("This should have http status code 500!")
|
21
|
-
end
|
22
|
-
|
23
|
-
get "/error" do
|
24
|
-
error!("This is an error with 'error'!")
|
25
|
-
end
|
26
|
-
|
27
|
-
get "/breakstring" do
|
28
|
-
raise "This should have http status code 500!"
|
29
|
-
end
|
30
|
-
|
31
|
-
resource :employee_data do
|
32
|
-
desc "List all Employee"
|
33
|
-
get do
|
34
|
-
present({ :employee_data => "all"})
|
35
|
-
end
|
36
|
-
|
37
|
-
get ':id' do
|
38
|
-
present({ :employee_data => "Employee ##{params[:id]}"})
|
39
|
-
end
|
40
|
-
|
41
|
-
desc "create a new employee"
|
42
|
-
# This takes care of parameter validation
|
43
|
-
params do
|
44
|
-
requires :name, type: String
|
45
|
-
requires :address, type:String
|
46
|
-
requires :age, type:Integer
|
47
|
-
end
|
48
|
-
post do
|
49
|
-
present({ :employee_data => "Creating employee: #{params[:name]}, #{params[:address]}, #{params[:age]}"})
|
50
|
-
end
|
51
|
-
|
52
|
-
desc "update an employee address"
|
53
|
-
params do
|
54
|
-
requires :id, type: String
|
55
|
-
requires :address, type:String
|
56
|
-
end
|
57
|
-
put ':id' do
|
58
|
-
present({ :employee_data => "Updating employee ##{params[:id]}: #{params[:address]}"})
|
59
|
-
end
|
60
|
-
|
61
|
-
desc "delete an employee"
|
62
|
-
params do
|
63
|
-
requires :id, type: String
|
64
|
-
end
|
65
|
-
|
66
|
-
delete ':id' do
|
67
|
-
present({ :employee_data => "Deleting employee ##{params[:id]}"})
|
68
|
-
end
|
69
|
-
|
70
|
-
route_param :id do
|
71
|
-
resource :nested do
|
72
|
-
desc "try a nested route"
|
73
|
-
get ':child' do
|
74
|
-
present({ :employee_data => "Nested employee data for ##{params[:id]}: #{params[:child]}"})
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# This test Padrino stack file was taken from the padrino-core gem.
|
2
|
-
#
|
3
|
-
PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
|
4
|
-
# Remove this comment if you want do some like this: ruby PADRINO_ENV=test app.rb
|
5
|
-
#
|
6
|
-
# require 'rubygems'
|
7
|
-
# require 'padrino-core'
|
8
|
-
#
|
9
|
-
|
10
|
-
class SimpleDemo < Padrino::Application
|
11
|
-
set :public_folder, File.dirname(__FILE__)
|
12
|
-
set :reload, false
|
13
|
-
before { true }
|
14
|
-
after { true }
|
15
|
-
error(404) { "404" }
|
16
|
-
end
|
17
|
-
|
18
|
-
SimpleDemo.controllers do
|
19
|
-
get "/" do
|
20
|
-
'The magick number is: 2767356926488785838763860464013972991031534522105386787489885890443740254365!' # Change only the number!!!
|
21
|
-
end
|
22
|
-
|
23
|
-
get "/rand" do
|
24
|
-
rand(2 ** 256).to_s
|
25
|
-
end
|
26
|
-
|
27
|
-
get "/render" do
|
28
|
-
render :erb, "This is an erb render"
|
29
|
-
end
|
30
|
-
|
31
|
-
get "/render/:id" do
|
32
|
-
render :erb, "The Id is #{params[:id]}"
|
33
|
-
end
|
34
|
-
|
35
|
-
get "/render/:id/what" do
|
36
|
-
render :erb, "WOOT is #{params[:id]}"
|
37
|
-
end
|
38
|
-
|
39
|
-
get :symbol_route do
|
40
|
-
render :erb, "This is an erb render"
|
41
|
-
end
|
42
|
-
|
43
|
-
get :symbol_route, :with => :id do
|
44
|
-
render :erb, "The Id is #{params[:id]}"
|
45
|
-
end
|
46
|
-
|
47
|
-
get "/break" do
|
48
|
-
raise "This is a controller exception!"
|
49
|
-
end
|
50
|
-
|
51
|
-
get "/error" do
|
52
|
-
status 500
|
53
|
-
render :erb, "broken"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
SimpleDemo.controllers :product, :parent => :user do
|
58
|
-
get :index do
|
59
|
-
# url is generated as "/user/#{params[:user_id]}/product"
|
60
|
-
# url_for(:product, :index, :user_id => 5) => "/user/5/product"
|
61
|
-
render :erb, "The user id is #{params[:user_id]}"
|
62
|
-
end
|
63
|
-
|
64
|
-
get :show, :with => :id do
|
65
|
-
# url is generated as "/user/#{params[:user_id]}/product/show/#{params[:id]}"
|
66
|
-
# url_for(:product, :show, :user_id => 5, :id => 10) => "/user/5/product/show/10"
|
67
|
-
render :erb, "Ids: #{params[:user_id]}, #{params[:id]}"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
## If you want use this as a standalone app uncomment:
|
72
|
-
#
|
73
|
-
# Padrino.mount("SimpleDemo").to("/")
|
74
|
-
# Padrino.run! unless Padrino.loaded? # If you enable reloader prevent to re-run the app
|
75
|
-
#
|
76
|
-
# Then run it from your console: ruby -I"lib" test/fixtures/apps/simple.rb
|
77
|
-
#
|
78
|
-
|
79
|
-
Padrino.load!
|
80
|
-
|