Log fractional GraphQL complexity scores

What does this MR do and why?

Gitlab::Graphql::QueryAnalyzers::AST::LoggerAnalyzer#result only recorded a complexity score when graphql-ruby returned an Integer. A Float matched neither when branch, so the query was logged with depth but no complexity and no analysis_error — silently unscored.

  • Match Numeric instead of Integer. Scores are fractional whenever __typename (complexity 0.2) is selected with no resolver-backed field between it and the root, which is most currentUser, subscription and mutation traffic: 19.0M of 39.9M executions (48%) in one hour of gitlab.com's graphql_json.log had no score, including 99% of subscriptions.
  • Store .floor. Types::QueryComplexityType#score already floors the same value through its Int field, so the log and the GraphQL field now agree. Enforcement is unaffected — MaxQueryComplexity compares the raw Float.
  • Log the raw score as query_analysis.graphql_complexity_raw next to the floored complexity, using .to_f so the value is always a float (3.0, never 3) and the Elasticsearch mapping keeps one type. The key is Labkit::Fields::GRAPHQL_COMPLEXITY_RAW, registered in gitlab-org/quality/tooling/labkit-spec!40 (merged) and shipped in gitlab-labkit 5.2.0, which !257500 (merged) bumped on master.

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/628442

🤖 Generated with Claude Code

Edited by Max Woolf

Merge request reports

Loading
Loading