File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ gem "stimulus-rails"
1717# Build JSON APIs with ease [https://github.com/rails/jbuilder]
1818gem "jbuilder"
1919
20+ gem "yabeda-rails"
21+ gem "yabeda-prometheus"
22+
2023# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
2124# gem "bcrypt", "~> 3.1.7"
2225
Original file line number Diff line number Diff line change 7474 uri (>= 0.13.1 )
7575 addressable (2.8.7 )
7676 public_suffix (>= 2.0.2 , < 7.0 )
77+ anyway_config (2.7.2 )
78+ ruby-next-core (~> 1.0 )
7779 ast (2.4.3 )
7880 base64 (0.3.0 )
7981 bcrypt_pbkdf (1.1.1 )
104106 reline (>= 0.3.8 )
105107 dotenv (3.1.8 )
106108 drb (2.2.3 )
109+ dry-initializer (3.2.0 )
107110 ed25519 (1.4.0 )
108111 erb (5.0.3 )
109112 erubi (1.13.1 )
186189 prettyprint
187190 prettyprint (0.2.0 )
188191 prism (1.4.0 )
192+ prometheus-client (4.2.5 )
193+ base64
189194 propshaft (1.3.1 )
190195 actionpack (>= 7.0.0 )
191196 activesupport (>= 7.0.0 )
274279 rubocop (>= 1.72 )
275280 rubocop-performance (>= 1.24 )
276281 rubocop-rails (>= 2.30 )
282+ ruby-next-core (1.1.2 )
277283 ruby-progressbar (1.13.0 )
278284 rubyzip (3.1.1 )
279285 securerandom (0.4.1 )
342348 websocket-extensions (0.1.5 )
343349 xpath (3.2.0 )
344350 nokogiri (~> 1.8 )
351+ yabeda (0.14.0 )
352+ anyway_config (>= 1.0 , < 3 )
353+ concurrent-ruby
354+ dry-initializer
355+ yabeda-prometheus (0.9.1 )
356+ prometheus-client (>= 3.0 , < 5.0 )
357+ rack
358+ yabeda (~> 0.10 )
359+ yabeda-rails (0.10.0 )
360+ activesupport
361+ anyway_config (>= 1.3 , < 3 )
362+ railties
363+ yabeda (~> 0.8 )
345364 zeitwerk (2.7.3 )
346365
347366PLATFORMS
@@ -371,6 +390,8 @@ DEPENDENCIES
371390 turbo-rails
372391 tzinfo-data
373392 web-console
393+ yabeda-prometheus
394+ yabeda-rails
374395
375396BUNDLED WITH
376397 2.4.19
Original file line number Diff line number Diff line change 1+ class HelloController < ApplicationController
2+ def index
3+ Yabeda . top_shop . index_page_opened . increment
4+ render plain : "Главная страница"
5+ end
6+
7+ def refresh_online
8+ users_online_count = rand ( 100 ..1000 )
9+ Yabeda . top_shop . user_online . set ( { } , users_online_count )
10+ render plain : "#{ users_online_count } users online now"
11+ end
12+
13+ def seed_everything
14+ GenerateEverythingJob . perform_now
15+ render plain : "Done!"
16+ end
17+ end
Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ def seed_users
1414 end
1515
1616 def seed_couriers
17- rand ( 0 .. 1 ) . times { User . create ( kind : :courier ) }
17+ rand ( 1 .. 2 ) . times { User . create ( kind : :courier ) }
1818 end
1919
2020 def seed_orders
21- rand ( 10 .. 20 ) . times { Order . create ( amount : rand ( 100 ..5000 ) ) }
21+ rand ( 40 .. 90 ) . times { Order . create ( amount : rand ( 100 ..5000 ) ) }
2222 end
2323end
Original file line number Diff line number Diff line change 11class Order < ApplicationRecord
2+ after_create :track_order
3+
4+ private
5+
6+ def track_order
7+ Yabeda . top_shop . orders_placed . increment
8+ Yabeda . top_shop . money_earned . increment ( { } , by : amount )
9+ end
210end
Original file line number Diff line number Diff line change 11class User < ApplicationRecord
2+ after_create :track_user
3+
4+ private
5+
6+ def track_user
7+ Yabeda . top_shop . users_registered . increment ( { kind : } )
8+ end
29end
Original file line number Diff line number Diff line change 1+ Yabeda . configure do
2+ group :top_shop do
3+ counter :index_page_opened , comment : "Index page visits"
4+ counter :users_registered , tags : %i[ kind ] , comment : "Users registered"
5+ counter :orders_placed , comment : "Orders placed"
6+ counter :money_earned , comment : "Total GMV"
7+
8+ gauge :user_online , comment : "Users online"
9+ end
10+ end
Original file line number Diff line number Diff line change 11Rails . application . routes . draw do
2+ mount Yabeda ::Prometheus ::Exporter , at : "/metrics"
23 # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
34
45 # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
910 # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest
1011 # get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker
1112
13+ get "seed" => "hello#seed_everything"
14+ get "refresh_online" => "hello#refresh_online"
15+
1216 # Defines the root path route ("/")
13- # root "posts #index"
17+ root "hello #index"
1418end
You can’t perform that action at this time.
0 commit comments