-
Notifications
You must be signed in to change notification settings - Fork 163
Description
Motivation
The GQLMetricMiddleware.resolve() method in src/ai/backend/manager/api/gql_legacy/schema.py contains three near-identical observe_request(...) call sites, each passing 7 keyword arguments. This repetition makes the method hard to read and makes subsequent changes (e.g., BA-4299 async timing fix, BA-4330 OTel tracing) produce unnecessarily large diffs that are difficult to review.
Objective
Extract the repeated metric_observer.observe_request(...) invocations in GQLMetricMiddleware.resolve() into a private helper method, reducing each call site to a single line. This is a pure refactoring with no behavior change.
Details
- Add a private
_observe_request()method toGQLMetricMiddlewarethat wrapsgraph_ctx.metric_observer.observe_request(...)with the common parameters (operation_type, field_name, parent_type, operation_name) captured once. - Replace all three existing
observe_request(...)blocks (success, BackendAIError, BaseException) with calls to the helper. - Fix bare
raise eto idiomaticraisein the except blocks (minor style cleanup). - No functional changes to metrics recording behavior.
Impact
- Reduces the diff size of follow-up PRs (BA-4299 async timing fix, BA-4330 OTel tracing) by eliminating repeated boilerplate in their diffs.
- No impact on other services or runtime behavior; the refactoring is internal to the GQL metric middleware.
JIRA Issue: BA-4378
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels