builder_apm 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +6 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +17 -0
  7. data/Gemfile.lock +196 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +50 -0
  10. data/Rakefile +28 -0
  11. data/app/controllers/builder_apm/dashboard_controller.rb +8 -0
  12. data/app/controllers/builder_apm/error_requests_controller.rb +8 -0
  13. data/app/controllers/builder_apm/n_plus_one_controller.rb +8 -0
  14. data/app/controllers/builder_apm/recent_requests_controller.rb +8 -0
  15. data/app/controllers/builder_apm/request_analysis_controller.rb +8 -0
  16. data/app/controllers/builder_apm/request_data_controller.rb +41 -0
  17. data/app/controllers/builder_apm/request_details_controller.rb +9 -0
  18. data/app/controllers/builder_apm/slow_requests_controller.rb +8 -0
  19. data/app/controllers/builder_apm/wip_controller.rb +8 -0
  20. data/app/views/builder_apm/css/_dark.html.erb +119 -0
  21. data/app/views/builder_apm/css/_main.html.erb +268 -0
  22. data/app/views/builder_apm/dashboard/index.html.erb +10 -0
  23. data/app/views/builder_apm/error_requests/index.html.erb +23 -0
  24. data/app/views/builder_apm/js/_compress.html.erb +93 -0
  25. data/app/views/builder_apm/js/_dashboard.html.erb +199 -0
  26. data/app/views/builder_apm/js/_data_fetcher.html.erb +254 -0
  27. data/app/views/builder_apm/js/_error_requests.html.erb +65 -0
  28. data/app/views/builder_apm/js/_lzma.html.erb +2670 -0
  29. data/app/views/builder_apm/js/_n_plus_one.html.erb +79 -0
  30. data/app/views/builder_apm/js/_recent_requests.html.erb +82 -0
  31. data/app/views/builder_apm/js/_request_analysis.html.erb +77 -0
  32. data/app/views/builder_apm/js/_request_details.html.erb +204 -0
  33. data/app/views/builder_apm/js/_slow_requests.html.erb +74 -0
  34. data/app/views/builder_apm/n_plus_one/index.html.erb +21 -0
  35. data/app/views/builder_apm/recent_requests/index.html.erb +21 -0
  36. data/app/views/builder_apm/request_analysis/index.html.erb +24 -0
  37. data/app/views/builder_apm/request_details/index.html.erb +7 -0
  38. data/app/views/builder_apm/shared/_footer.html.erb +3 -0
  39. data/app/views/builder_apm/shared/_header.html.erb +55 -0
  40. data/app/views/builder_apm/slow_requests/index.html.erb +21 -0
  41. data/app/views/builder_apm/wip/index.html.erb +5 -0
  42. data/bin/console +14 -0
  43. data/bin/setup +8 -0
  44. data/builder_apm.gemspec +23 -0
  45. data/config/routes.rb +12 -0
  46. data/lib/builder_apm/configuration.rb +15 -0
  47. data/lib/builder_apm/controllers/instrumenter.rb +88 -0
  48. data/lib/builder_apm/engine.rb +17 -0
  49. data/lib/builder_apm/methods/instrumenter.rb +79 -0
  50. data/lib/builder_apm/middleware/timing.rb +56 -0
  51. data/lib/builder_apm/models/instrumenter.rb +82 -0
  52. data/lib/builder_apm/railtie.rb +9 -0
  53. data/lib/builder_apm/redis_client.rb +11 -0
  54. data/lib/builder_apm/version.rb +3 -0
  55. data/lib/builder_apm.rb +22 -0
  56. data/lib/generators/builder_apm/install_generator.rb +21 -0
  57. data/lib/generators/builder_apm/templates/builder_apm_config.rb +6 -0
  58. data/lib/generators/builder_apm/templates/create_builder_apm_requests.rb +21 -0
  59. data/lib/generators/builder_apm/templates/create_builder_apm_sql_queries.rb +17 -0
  60. metadata +135 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d04d7cf30b252d8ce9eb608d7c1dfb103c23d5b125cae40f54668f73af768fb9
4
+ data.tar.gz: 92999eb6415744f4290d823400cd6214bd28615267dfc4be0e192510dea2fff3
5
+ SHA512:
6
+ metadata.gz: f9223d0bb63e10a94abcae85fbb97c1b913360eb7a36a172ab678cc179dd22d926b0f65c7764f05d57be2407b3b02907fdb28e16c9d543278c8db2d0c169606e
7
+ data.tar.gz: 5ed4d6abf39245db40e7afae0e10cd8295f28c0bd33a4db08e86818ca86054ceca1bca0603b4bf15eecc9db2f615e02d28108fc3c59d0bb91ed91342aa7e5609
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ dummy
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.2
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at TODO: Write your email address. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in builder_apm.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+
9
+
10
+ group :development, :test do
11
+ gem 'debug'
12
+ end
13
+
14
+ group :test do
15
+ gem 'rspec-rails'
16
+ gem 'fakeredis'
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,196 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ builder_apm (0.1.0)
5
+ rails (>= 4.0, < 8)
6
+ redis (~> 4.5)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (6.1.7.4)
12
+ actionpack (= 6.1.7.4)
13
+ activesupport (= 6.1.7.4)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ actionmailbox (6.1.7.4)
17
+ actionpack (= 6.1.7.4)
18
+ activejob (= 6.1.7.4)
19
+ activerecord (= 6.1.7.4)
20
+ activestorage (= 6.1.7.4)
21
+ activesupport (= 6.1.7.4)
22
+ mail (>= 2.7.1)
23
+ actionmailer (6.1.7.4)
24
+ actionpack (= 6.1.7.4)
25
+ actionview (= 6.1.7.4)
26
+ activejob (= 6.1.7.4)
27
+ activesupport (= 6.1.7.4)
28
+ mail (~> 2.5, >= 2.5.4)
29
+ rails-dom-testing (~> 2.0)
30
+ actionpack (6.1.7.4)
31
+ actionview (= 6.1.7.4)
32
+ activesupport (= 6.1.7.4)
33
+ rack (~> 2.0, >= 2.0.9)
34
+ rack-test (>= 0.6.3)
35
+ rails-dom-testing (~> 2.0)
36
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
+ actiontext (6.1.7.4)
38
+ actionpack (= 6.1.7.4)
39
+ activerecord (= 6.1.7.4)
40
+ activestorage (= 6.1.7.4)
41
+ activesupport (= 6.1.7.4)
42
+ nokogiri (>= 1.8.5)
43
+ actionview (6.1.7.4)
44
+ activesupport (= 6.1.7.4)
45
+ builder (~> 3.1)
46
+ erubi (~> 1.4)
47
+ rails-dom-testing (~> 2.0)
48
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
+ activejob (6.1.7.4)
50
+ activesupport (= 6.1.7.4)
51
+ globalid (>= 0.3.6)
52
+ activemodel (6.1.7.4)
53
+ activesupport (= 6.1.7.4)
54
+ activerecord (6.1.7.4)
55
+ activemodel (= 6.1.7.4)
56
+ activesupport (= 6.1.7.4)
57
+ activestorage (6.1.7.4)
58
+ actionpack (= 6.1.7.4)
59
+ activejob (= 6.1.7.4)
60
+ activerecord (= 6.1.7.4)
61
+ activesupport (= 6.1.7.4)
62
+ marcel (~> 1.0)
63
+ mini_mime (>= 1.1.0)
64
+ activesupport (6.1.7.4)
65
+ concurrent-ruby (~> 1.0, >= 1.0.2)
66
+ i18n (>= 1.6, < 2)
67
+ minitest (>= 5.1)
68
+ tzinfo (~> 2.0)
69
+ zeitwerk (~> 2.3)
70
+ builder (3.2.4)
71
+ concurrent-ruby (1.2.2)
72
+ crass (1.0.6)
73
+ date (3.3.3)
74
+ debug (1.8.0)
75
+ irb (>= 1.5.0)
76
+ reline (>= 0.3.1)
77
+ diff-lcs (1.5.0)
78
+ erubi (1.12.0)
79
+ fakeredis (0.9.2)
80
+ redis (~> 4.8)
81
+ globalid (1.1.0)
82
+ activesupport (>= 5.0)
83
+ i18n (1.14.1)
84
+ concurrent-ruby (~> 1.0)
85
+ io-console (0.6.0)
86
+ irb (1.6.3)
87
+ reline (>= 0.3.0)
88
+ loofah (2.21.3)
89
+ crass (~> 1.0.2)
90
+ nokogiri (>= 1.12.0)
91
+ mail (2.8.1)
92
+ mini_mime (>= 0.1.1)
93
+ net-imap
94
+ net-pop
95
+ net-smtp
96
+ marcel (1.0.2)
97
+ method_source (1.0.0)
98
+ mini_mime (1.1.2)
99
+ minitest (5.18.1)
100
+ net-imap (0.3.6)
101
+ date
102
+ net-protocol
103
+ net-pop (0.1.2)
104
+ net-protocol
105
+ net-protocol (0.2.1)
106
+ timeout
107
+ net-smtp (0.3.3)
108
+ net-protocol
109
+ nio4r (2.5.9)
110
+ nokogiri (1.13.10-arm64-darwin)
111
+ racc (~> 1.4)
112
+ racc (1.7.1)
113
+ rack (2.2.7)
114
+ rack-test (2.1.0)
115
+ rack (>= 1.3)
116
+ rails (6.1.7.4)
117
+ actioncable (= 6.1.7.4)
118
+ actionmailbox (= 6.1.7.4)
119
+ actionmailer (= 6.1.7.4)
120
+ actionpack (= 6.1.7.4)
121
+ actiontext (= 6.1.7.4)
122
+ actionview (= 6.1.7.4)
123
+ activejob (= 6.1.7.4)
124
+ activemodel (= 6.1.7.4)
125
+ activerecord (= 6.1.7.4)
126
+ activestorage (= 6.1.7.4)
127
+ activesupport (= 6.1.7.4)
128
+ bundler (>= 1.15.0)
129
+ railties (= 6.1.7.4)
130
+ sprockets-rails (>= 2.0.0)
131
+ rails-dom-testing (2.1.1)
132
+ activesupport (>= 5.0.0)
133
+ minitest
134
+ nokogiri (>= 1.6)
135
+ rails-html-sanitizer (1.5.0)
136
+ loofah (~> 2.19, >= 2.19.1)
137
+ railties (6.1.7.4)
138
+ actionpack (= 6.1.7.4)
139
+ activesupport (= 6.1.7.4)
140
+ method_source
141
+ rake (>= 12.2)
142
+ thor (~> 1.0)
143
+ rake (12.3.3)
144
+ redis (4.8.1)
145
+ reline (0.3.6)
146
+ io-console (~> 0.5)
147
+ rspec (3.12.0)
148
+ rspec-core (~> 3.12.0)
149
+ rspec-expectations (~> 3.12.0)
150
+ rspec-mocks (~> 3.12.0)
151
+ rspec-core (3.12.2)
152
+ rspec-support (~> 3.12.0)
153
+ rspec-expectations (3.12.3)
154
+ diff-lcs (>= 1.2.0, < 2.0)
155
+ rspec-support (~> 3.12.0)
156
+ rspec-mocks (3.12.6)
157
+ diff-lcs (>= 1.2.0, < 2.0)
158
+ rspec-support (~> 3.12.0)
159
+ rspec-rails (6.0.3)
160
+ actionpack (>= 6.1)
161
+ activesupport (>= 6.1)
162
+ railties (>= 6.1)
163
+ rspec-core (~> 3.12)
164
+ rspec-expectations (~> 3.12)
165
+ rspec-mocks (~> 3.12)
166
+ rspec-support (~> 3.12)
167
+ rspec-support (3.12.1)
168
+ sprockets (4.2.0)
169
+ concurrent-ruby (~> 1.0)
170
+ rack (>= 2.2.4, < 4)
171
+ sprockets-rails (3.4.2)
172
+ actionpack (>= 5.2)
173
+ activesupport (>= 5.2)
174
+ sprockets (>= 3.0.0)
175
+ thor (1.2.2)
176
+ timeout (0.4.0)
177
+ tzinfo (2.0.6)
178
+ concurrent-ruby (~> 1.0)
179
+ websocket-driver (0.7.5)
180
+ websocket-extensions (>= 0.1.0)
181
+ websocket-extensions (0.1.5)
182
+ zeitwerk (2.6.8)
183
+
184
+ PLATFORMS
185
+ arm64-darwin-22
186
+
187
+ DEPENDENCIES
188
+ builder_apm!
189
+ debug
190
+ fakeredis
191
+ rake (~> 12.0)
192
+ rspec (~> 3.0)
193
+ rspec-rails
194
+
195
+ BUNDLED WITH
196
+ 2.4.7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # BuilderApm
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/builder_apm`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'builder_apm'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install builder_apm
22
+
23
+ run
24
+ ```
25
+ rails generate builder_apm:install
26
+ rails db:migrate
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ TODO: Write usage instructions here
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/builder_apm. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/builder_apm/blob/master/CODE_OF_CONDUCT.md).
42
+
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
47
+
48
+ ## Code of Conduct
49
+
50
+ Everyone interacting in the BuilderApm project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/builder_apm/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ namespace :test do
9
+ desc "Creates a dummy Rails app for testing"
10
+ task :dummy_rails do
11
+ require 'rails'
12
+
13
+ dummy_path = File.expand_path("spec/dummy", __dir__)
14
+ system("rm -rf #{dummy_path}") if File.directory?(dummy_path)
15
+
16
+ rails_version = Rails::VERSION::STRING
17
+ rails_new_command = "rails _#{rails_version}_ new #{dummy_path} --skip-bundle --skip-git --skip-keeps --skip-action-mailbox --skip-action-mailer --skip-action-text --skip-active-record --skip-active-storage --skip-action-cable --skip-puma --skip-bootsnap --skip-spring --skip-listen --skip-javascript --skip-turbolinks --skip-test --skip-system-test --quiet"
18
+ system(rails_new_command)
19
+
20
+ # remove the asset pipeline initializer file
21
+ puts 'Removing assets initializer...'
22
+ assets_file_path = File.expand_path("spec/dummy/config/initializers/assets.rb")
23
+ File.delete(assets_file_path) if File.exist?(assets_file_path)
24
+ puts 'Done.'
25
+
26
+ puts "\nCreated dummy Rails app in spec/dummy"
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+ module BuilderApm
2
+ class DashboardController < ActionController::Base
3
+ def index
4
+ end
5
+ end
6
+ end
7
+
8
+
@@ -0,0 +1,8 @@
1
+ module BuilderApm
2
+ class ErrorRequestsController < ActionController::Base
3
+ def index
4
+ end
5
+ end
6
+ end
7
+
8
+
@@ -0,0 +1,8 @@
1
+ module BuilderApm
2
+ class NPlusOneController < ActionController::Base
3
+ def index
4
+ end
5
+ end
6
+ end
7
+
8
+
@@ -0,0 +1,8 @@
1
+ module BuilderApm
2
+ class RecentRequestsController < ActionController::Base
3
+ def index
4
+ end
5
+ end
6
+ end
7
+
8
+
@@ -0,0 +1,8 @@
1
+ module BuilderApm
2
+ class RequestAnalysisController < ActionController::Base
3
+ def index
4
+ end
5
+ end
6
+ end
7
+
8
+
@@ -0,0 +1,41 @@
1
+ module BuilderApm
2
+ class RequestDataController < ActionController::Base
3
+ def index
4
+ cursor = (params[:cursor].presence&.to_f) || "-inf"
5
+ limit = params[:limit].presence&.to_i || 50
6
+
7
+ if cursor == "-inf"
8
+ @requests = retrieve_all_data_from_redis(limit)
9
+ else
10
+ @requests = retrieve_data_from_redis_since(cursor, limit)
11
+ end
12
+
13
+ render json: @requests
14
+ end
15
+
16
+ private
17
+
18
+ def retrieve_data_from_redis_since(cursor, limit)
19
+ # Use ZRANGEBYSCORE to get a range of keys, then get the corresponding data
20
+ keys = redis_client.zrangebyscore("builder_apm:timestamps", cursor, "+inf", limit: [0, limit])
21
+ data = keys.map { |key| redis_client.get("builder_apm:Request:#{key}") }
22
+ begin
23
+ data.map { |d| JSON.parse(d) }
24
+ rescue => e
25
+ debugger
26
+ raise e
27
+ end
28
+ end
29
+
30
+ def retrieve_all_data_from_redis(limit)
31
+ # Similar to the above, but we get all records
32
+ keys = redis_client.zrange("builder_apm:timestamps", -limit, -1)
33
+ data = keys.map { |key| redis_client.get("builder_apm:Request:#{key}") }
34
+ data.map { |d| JSON.parse(d) }
35
+ end
36
+
37
+ def redis_client
38
+ @redis_client ||= BuilderApm::RedisClient.client
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,9 @@
1
+ module BuilderApm
2
+ class RequestDetailsController < ActionController::Base
3
+ def index
4
+ @request_id = params[:request_id]
5
+ end
6
+ end
7
+ end
8
+
9
+
@@ -0,0 +1,8 @@
1
+ module BuilderApm
2
+ class SlowRequestsController < ActionController::Base
3
+ def index
4
+ end
5
+ end
6
+ end
7
+
8
+
@@ -0,0 +1,8 @@
1
+ module BuilderApm
2
+ class WipController < ActionController::Base
3
+ def index
4
+ end
5
+ end
6
+ end
7
+
8
+
@@ -0,0 +1,119 @@
1
+ <style>
2
+ body.dark {
3
+ background-color: #242424;
4
+ color: #b3b3b3;
5
+ }
6
+
7
+ body.dark #header {
8
+ background-color: #666666;
9
+ }
10
+
11
+ body.dark #navbar,
12
+ body.dark #navbar ul {
13
+ background-color: #1f1f1f;
14
+ }
15
+
16
+ body.dark #navbar li a {
17
+ color: #b3b3b3;
18
+ }
19
+
20
+ body.dark #navbar li a:hover {
21
+ background-color: #b3b3b3;
22
+ color: #242424;
23
+ }
24
+
25
+ body.dark #navbar li a.active {
26
+ background-color: #666666;
27
+ color: #ffffff;
28
+ }
29
+
30
+ body.dark table {
31
+ color: #b3b3b3;
32
+ border: 1px solid #666666;
33
+ }
34
+
35
+ body.dark tr:nth-child(even) {
36
+ background-color: #3c3c3c;
37
+ }
38
+
39
+ body.dark th {
40
+ background-color: #666666;
41
+ color: #ffffff;
42
+ }
43
+
44
+ body.dark #details_div .bounding-box {
45
+ border: 1px solid #666666;
46
+ box-shadow: 0px 0px 5px rgba(255,255,255,0.2);
47
+ }
48
+
49
+ body.dark #details_div div.has-children {
50
+ color: #bbbbbb;
51
+ }
52
+
53
+ body.dark #details_div div {
54
+ color: #bbbbbb;
55
+ background-color: #3c3c3c;
56
+ }
57
+
58
+ body.dark #details_div .sql-event {
59
+ background-color: #00001a;
60
+ color: #6699cc;
61
+ }
62
+
63
+ body.dark #details_div .children {
64
+ border-left: 1px solid #666666;
65
+ }
66
+
67
+ body.dark #details_div .has_children {
68
+ border: 1px solid #666666;
69
+ }
70
+
71
+ body.dark #details_div .date,
72
+ body.dark #details_div .duration,
73
+ body.dark #details_div .description,
74
+ body.dark #details_div .sql,
75
+ body.dark #details_div .method_line,
76
+ body.dark #details_div .trigger_line,
77
+ body.dark #details_div .cached,
78
+ body.dark #details_div .record_count,
79
+ body.dark #details_div .params {
80
+ color: #bbbbbb;
81
+ }
82
+
83
+ body.dark #details_div .minor_call {
84
+ background: #1a331a;
85
+ }
86
+
87
+ body.dark #details_div .error_status {
88
+ border: 1px solid #ff0000;
89
+ background-color: rgb(51, 0, 0);
90
+ }
91
+
92
+ body.dark .duration-circle {
93
+ border: 1px solid #666666;
94
+ }
95
+
96
+ body.dark .image-container::before {
97
+ background: radial-gradient(ellipse at center, rgba(0,0,0,0) 57%, rgba(0,0,0,1) 71%);
98
+ }
99
+
100
+ /* Dark mode styles */
101
+
102
+ body.dark #navbar li a,
103
+ body.dark #navbar .nav-button {
104
+ color: #ddd;
105
+ background-color: #666;
106
+ }
107
+
108
+ body.dark #navbar li a:hover,
109
+ body.dark #navbar .nav-button:hover {
110
+ background-color: #555;
111
+ color: #fff;
112
+ }
113
+
114
+ body.dark #navbar li a.active,
115
+ body.dark #navbar .nav-button.active {
116
+ background-color: #777;
117
+ color: #fff;
118
+ }
119
+ </style>