Commit 770f07cd authored by Pawel Chojnacki's avatar Pawel Chojnacki

Make login_counter instance variable instead of class one.

 + remove unecessarey require
 + fix small formatiing issues
parent 394e962e
require 'prometheus/client/formats/text'
class HealthController < ActionController::Base class HealthController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
include RequiresHealthToken include RequiresHealthToken
......
class MetricsController < ActionController::Base class MetricsController < ActionController::Base
include RequiresHealthToken
protect_from_forgery with: :exception protect_from_forgery with: :exception
before_action :validate_prometheus_metrics before_action :validate_prometheus_metrics
include RequiresHealthToken
def metrics def metrics
response = "#{metrics_service.health_metrics_text}\n#{metrics_service.prometheus_metrics_text}" response = "#{metrics_service.health_metrics_text}\n#{metrics_service.prometheus_metrics_text}"
......
...@@ -47,7 +47,7 @@ class SessionsController < Devise::SessionsController ...@@ -47,7 +47,7 @@ class SessionsController < Devise::SessionsController
private private
def self.login_counter def login_counter
@login_counter ||= Gitlab::Metrics.counter(:user_session_logins, 'User logins count') @login_counter ||= Gitlab::Metrics.counter(:user_session_logins, 'User logins count')
end end
...@@ -129,7 +129,7 @@ class SessionsController < Devise::SessionsController ...@@ -129,7 +129,7 @@ class SessionsController < Devise::SessionsController
end end
def log_user_activity(user) def log_user_activity(user)
SessionsController.login_counter.increment login_counter.increment
Users::ActivityService.new(user, 'login').execute Users::ActivityService.new(user, 'login').execute
end end
......
class AddPrometheusSettingsToMetricsSettings < ActiveRecord::Migration class AddPrometheusSettingsToMetricsSettings < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers include Gitlab::Database::MigrationHelpers
disable_ddl_transaction! disable_ddl_transaction!
DOWNTIME = false DOWNTIME = false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment