Merge pull request #10265 from tchak/yabeda-graphql
chore(yabeda): add graphql metrics
This commit is contained in:
commit
7d4148202c
8 changed files with 32 additions and 1 deletions
3
Gemfile
3
Gemfile
|
@ -103,7 +103,10 @@ gem 'view_component'
|
||||||
gem 'vite_rails'
|
gem 'vite_rails'
|
||||||
gem 'warden'
|
gem 'warden'
|
||||||
gem 'webrick', require: false
|
gem 'webrick', require: false
|
||||||
|
gem 'yabeda-graphql'
|
||||||
gem 'yabeda-prometheus'
|
gem 'yabeda-prometheus'
|
||||||
|
gem 'yabeda-puma-plugin'
|
||||||
|
gem 'yabeda-rails'
|
||||||
gem 'yabeda-sidekiq'
|
gem 'yabeda-sidekiq'
|
||||||
gem 'zipline'
|
gem 'zipline'
|
||||||
gem 'zxcvbn-ruby', require: 'zxcvbn'
|
gem 'zxcvbn-ruby', require: 'zxcvbn'
|
||||||
|
|
15
Gemfile.lock
15
Gemfile.lock
|
@ -838,10 +838,22 @@ GEM
|
||||||
anyway_config (>= 1.0, < 3)
|
anyway_config (>= 1.0, < 3)
|
||||||
concurrent-ruby
|
concurrent-ruby
|
||||||
dry-initializer
|
dry-initializer
|
||||||
|
yabeda-graphql (0.2.3)
|
||||||
|
graphql (>= 1.9, < 3)
|
||||||
|
yabeda (~> 0.2)
|
||||||
yabeda-prometheus (0.9.1)
|
yabeda-prometheus (0.9.1)
|
||||||
prometheus-client (>= 3.0, < 5.0)
|
prometheus-client (>= 3.0, < 5.0)
|
||||||
rack
|
rack
|
||||||
yabeda (~> 0.10)
|
yabeda (~> 0.10)
|
||||||
|
yabeda-puma-plugin (0.7.1)
|
||||||
|
json
|
||||||
|
puma
|
||||||
|
yabeda (~> 0.5)
|
||||||
|
yabeda-rails (0.9.0)
|
||||||
|
activesupport
|
||||||
|
anyway_config (>= 1.3, < 3)
|
||||||
|
railties
|
||||||
|
yabeda (~> 0.8)
|
||||||
yabeda-sidekiq (0.12.0)
|
yabeda-sidekiq (0.12.0)
|
||||||
anyway_config (>= 1.3, < 3)
|
anyway_config (>= 1.3, < 3)
|
||||||
sidekiq
|
sidekiq
|
||||||
|
@ -997,7 +1009,10 @@ DEPENDENCIES
|
||||||
web-console
|
web-console
|
||||||
webmock
|
webmock
|
||||||
webrick
|
webrick
|
||||||
|
yabeda-graphql
|
||||||
yabeda-prometheus
|
yabeda-prometheus
|
||||||
|
yabeda-puma-plugin
|
||||||
|
yabeda-rails
|
||||||
yabeda-sidekiq
|
yabeda-sidekiq
|
||||||
zipline
|
zipline
|
||||||
zxcvbn-ruby
|
zxcvbn-ruby
|
||||||
|
|
|
@ -192,3 +192,5 @@ La compatibilité est testée par Browserstack.<br>[<img src="app/assets/images/
|
||||||
[![View performance data on Skylight](https://badges.skylight.io/status/zAvWTaqO0mu1.svg)](https://oss.skylight.io/app/applications/zAvWTaqO0mu1)
|
[![View performance data on Skylight](https://badges.skylight.io/status/zAvWTaqO0mu1.svg)](https://oss.skylight.io/app/applications/zAvWTaqO0mu1)
|
||||||
|
|
||||||
Nous utilisons Skylight pour suivre les performances de notre application.
|
Nous utilisons Skylight pour suivre les performances de notre application.
|
||||||
|
|
||||||
|
Par ailleurs, nous utilisons [Yabeda](https://github.com/yabeda-rb/yabeda) pour exporter des metriques au format prometheus. L'activation se fait via la variable d'environnement `PROMETHEUS_EXPORTER_ENABLED` voir config/env.example.optional .
|
||||||
|
|
|
@ -147,6 +147,7 @@ class API::V2::Schema < GraphQL::Schema
|
||||||
use Timeout, max_seconds: 30
|
use Timeout, max_seconds: 30
|
||||||
use GraphQL::Batch
|
use GraphQL::Batch
|
||||||
use GraphQL::Backtrace
|
use GraphQL::Backtrace
|
||||||
|
use Yabeda::GraphQL
|
||||||
|
|
||||||
if Rails.env.development?
|
if Rails.env.development?
|
||||||
class LogQueryDepth < GraphQL::Analysis::AST::QueryDepth
|
class LogQueryDepth < GraphQL::Analysis::AST::QueryDepth
|
||||||
|
|
|
@ -2,5 +2,9 @@
|
||||||
|
|
||||||
require_relative "config/environment"
|
require_relative "config/environment"
|
||||||
|
|
||||||
|
if ENV['PROMETHEUS_EXPORTER_ENABLED'] == 'enabled'
|
||||||
|
Yabeda::Prometheus::Exporter.start_metrics_server!
|
||||||
|
end
|
||||||
|
|
||||||
run Rails.application
|
run Rails.application
|
||||||
Rails.application.load_server
|
Rails.application.load_server
|
||||||
|
|
|
@ -244,7 +244,7 @@ REDIS_SIDEKIQ_PASSWORD='sentinel_and_redis_password'
|
||||||
REDIS_SIDEKIQ_USERNAME='sentinel_and_redis_username'
|
REDIS_SIDEKIQ_USERNAME='sentinel_and_redis_username'
|
||||||
|
|
||||||
# configuration for prometheus metrics web server
|
# configuration for prometheus metrics web server
|
||||||
# launched with sidekiq
|
# launched with sidekiq and puma
|
||||||
PROMETHEUS_EXPORTER_BIND="0.0.0.0"
|
PROMETHEUS_EXPORTER_BIND="0.0.0.0"
|
||||||
PROMETHEUS_EXPORTER_PORT="9394"
|
PROMETHEUS_EXPORTER_PORT="9394"
|
||||||
PROMETHEUS_EXPORTER_ENABLED="disabled"
|
PROMETHEUS_EXPORTER_ENABLED="disabled"
|
||||||
|
|
3
config/initializers/prometheus_metrics.rb
Normal file
3
config/initializers/prometheus_metrics.rb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
if ENV['PROMETHEUS_EXPORTER_ENABLED'] == 'enabled' && !Sidekiq.server?
|
||||||
|
Prometheus::Client.config.data_store = Prometheus::Client::DataStores::DirectFileStore.new(dir: Rails.root.join('tmp', 'prometheus'))
|
||||||
|
end
|
|
@ -43,3 +43,6 @@ end
|
||||||
|
|
||||||
# Allow puma to be restarted by `rails restart` command.
|
# Allow puma to be restarted by `rails restart` command.
|
||||||
plugin :tmp_restart
|
plugin :tmp_restart
|
||||||
|
|
||||||
|
activate_control_app
|
||||||
|
plugin :yabeda
|
||||||
|
|
Loading…
Reference in a new issue