2021-09-21 14:11:18 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Metrics
|
|
|
|
module RailsSlis
|
|
|
|
class << self
|
2022-02-07 19:14:26 -05:00
|
|
|
def initialize_request_slis!
|
2022-05-17 11:09:01 -04:00
|
|
|
Gitlab::Metrics::Sli::Apdex.initialize_sli(:rails_request, possible_request_labels)
|
|
|
|
Gitlab::Metrics::Sli::Apdex.initialize_sli(:graphql_query, possible_graphql_query_labels)
|
2021-09-21 14:11:18 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def request_apdex
|
2022-05-17 11:09:01 -04:00
|
|
|
Gitlab::Metrics::Sli::Apdex[:rails_request]
|
2021-09-21 14:11:18 -04:00
|
|
|
end
|
|
|
|
|
2021-11-09 13:13:13 -05:00
|
|
|
def graphql_query_apdex
|
2022-05-17 11:09:01 -04:00
|
|
|
Gitlab::Metrics::Sli::Apdex[:graphql_query]
|
2021-11-09 13:13:13 -05:00
|
|
|
end
|
|
|
|
|
2021-09-21 14:11:18 -04:00
|
|
|
private
|
|
|
|
|
2021-11-09 13:13:13 -05:00
|
|
|
def possible_graphql_query_labels
|
|
|
|
::Gitlab::Graphql::KnownOperations.default.operations.map do |op|
|
|
|
|
{
|
|
|
|
endpoint_id: op.to_caller_id,
|
|
|
|
# We'll be able to correlate feature_category with https://gitlab.com/gitlab-org/gitlab/-/issues/328535
|
|
|
|
feature_category: nil,
|
|
|
|
query_urgency: op.query_urgency.name
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-21 14:11:18 -04:00
|
|
|
def possible_request_labels
|
|
|
|
possible_controller_labels + possible_api_labels
|
|
|
|
end
|
|
|
|
|
|
|
|
def possible_api_labels
|
|
|
|
Gitlab::RequestEndpoints.all_api_endpoints.map do |route|
|
|
|
|
endpoint_id = API::Base.endpoint_id_for_route(route)
|
|
|
|
route_class = route.app.options[:for]
|
|
|
|
feature_category = route_class.feature_category_for_app(route.app)
|
2021-10-19 08:12:07 -04:00
|
|
|
request_urgency = route_class.urgency_for_app(route.app)
|
2021-09-21 14:11:18 -04:00
|
|
|
|
|
|
|
{
|
|
|
|
endpoint_id: endpoint_id,
|
2021-10-19 08:12:07 -04:00
|
|
|
feature_category: feature_category,
|
|
|
|
request_urgency: request_urgency.name
|
2021-09-21 14:11:18 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def possible_controller_labels
|
|
|
|
Gitlab::RequestEndpoints.all_controller_actions.map do |controller, action|
|
|
|
|
{
|
|
|
|
endpoint_id: controller.endpoint_id_for_action(action),
|
2021-10-19 08:12:07 -04:00
|
|
|
feature_category: controller.feature_category_for_action(action),
|
|
|
|
request_urgency: controller.urgency_for_action(action).name
|
2021-09-21 14:11:18 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|