-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1241 from SUSE/test_yabeda
Yabeda integration for prom metrics
- Loading branch information
Showing
12 changed files
with
106 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# :nocov: | ||
# frozen_string_literal: true | ||
|
||
return unless Settings.dig(:scc, :metrics, :enabled) | ||
|
||
# Configure prometheus client | ||
Prometheus::Client.config.data_store = Prometheus::Client::DataStores::DirectFileStore.new( | ||
dir: './tmp/prometheus/' | ||
) | ||
|
||
# Configure yabeda | ||
Yabeda.configure do | ||
assign_labels = lambda { | ||
default_tag :environment, Rails.env | ||
default_tag :application, 'rmt' | ||
} | ||
|
||
group :rails, &assign_labels | ||
|
||
group :rails do | ||
counter :started_requests_total, | ||
comment: 'A counter of the total number of HTTP requests rails has started to process.', | ||
tags: %i[controller action format method] | ||
end | ||
end | ||
|
||
# Instrument the request from the start | ||
ActiveSupport::Notifications.subscribe 'start_processing.action_controller' do |*args| | ||
# Match the same event as Yabeda | ||
event = Yabeda::Rails::Event.new(*args) | ||
|
||
Yabeda.rails.started_requests_total.tap do |metric| | ||
labels = event.labels.slice(*metric.tags) | ||
|
||
metric.increment(labels, by: 1) | ||
end | ||
end | ||
# :nocov: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def configure_prometheus!(puma) | ||
ENV['STARTED_FROM_PUMA'] = '1' | ||
|
||
puma.activate_control_app | ||
puma.plugin :yabeda | ||
puma.plugin :yabeda_prometheus | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters