Loading
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
Numericinstead ofInteger. Scores are fractional whenever__typename(complexity0.2) is selected with no resolver-backed field between it and the root, which is mostcurrentUser, subscription and mutation traffic: 19.0M of 39.9M executions (48%) in one hour of gitlab.com'sgraphql_json.loghad no score, including 99% of subscriptions. - Store
.floor.Types::QueryComplexityType#scorealready floors the same value through itsIntfield, so the log and the GraphQL field now agree. Enforcement is unaffected —MaxQueryComplexitycompares the rawFloat. - Log the raw score as
query_analysis.graphql_complexity_rawnext to the flooredcomplexity, using.to_fso the value is always a float (3.0, never3) and the Elasticsearch mapping keeps one type. The key isLabkit::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
Edited by Max Woolf