feat: add CEL metrics tracking for expression evaluations#934
feat: add CEL metrics tracking for expression evaluations#934govindup63 wants to merge 4 commits intokubernetes-sigs:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: govindup63 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @govindup63. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
- Introduced CELMetrics struct to track total cost and cost per resource. - Implemented methods to record, reset, and retrieve CEL metrics in ResourceGraphDefinitionRuntime. - Updated expression evaluation methods to track costs during evaluations. - Enhanced instance status preparation to include CEL metrics in the status map. - Added comprehensive tests for CEL metrics functionality and cost tracking in various scenarios
- Updated instance reconciliation to clarify CEL metrics initialization. - Improved status preparation to handle nil runtime scenarios and ensure CEL metrics are included only when available. - Added default CEL metrics field to CRD schema for consistent tracking. - Enhanced tests for CEL cost tracking across multiple resources and readiness evaluations. - Introduced logging for CEL metrics tracking to aid in debugging.
20d86fb to
7ecbc59
Compare
|
Hey @govindup63, thanks for working on this! It would be good to align with @TusharMohapatra07 in #931, since they're doing similar work. |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Hey @bschaatsbergen! Hope you're doing great :) |
|
Hi @a-hilaly , just a gentle ping on this PR when you get a chance. |
a-hilaly
left a comment
There was a problem hiding this comment.
thanks for working on this.
I’m going to close this PR for now. Exposing CEL evaluation cost in instance status adds a new public status surface, and I don’t think we have the design fully settled yet for what exactly should be tracked, how stable that contract should be, and whether this belongs in status vs other observability paths.
/close
|
@a-hilaly: Closed this PR. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
This PR implements CEL expression evaluation cost tracking and exposes metrics in the ResourceGroup instance status, addressing issue #190.
The implementation tracks the cost of all CEL expression evaluations during reconciliation and provides both total cost and per-resource cost breakdown in the instance status. This enables platform teams to monitor and optimize CEL expression performance.
Changes
Core Implementation
Added CEL metrics tracking in
pkg/runtime/runtime.go:CELMetricsstruct to track total cost and per-resource costsRecordCELCost()method to accumulate costs during expression evaluationGetCELMetrics()method that returns a deep copy to protect internal stateResetCELMetrics()method for resetting metrics (interface compliance)evaluateStaticVariables)evaluateDynamicVariables)includeWhenexpressions (ReadyToProcessResource)readyWhenexpressions (IsResourceReady)Status exposure in
pkg/controller/instance/controller_status.go:celMetricsto instance status withtotalCostandcostPerResourceCRD schema updates in
pkg/graph/crd/:celMetricsas a default status field in CRD schematotalCost(int64) andcostPerResource(map[string]int64)additionalProperties: trueto status schema to support controller-injected fieldsTesting
pkg/runtime/runtime_test.go:TestCELMetrics- tests cost accumulation, retrieval, and resetTestEvaluateExpressionCostTracking- verifies cost tracking is enabledTestRuntimeCELCostIntegration- integration test for static variable cost trackingTestIsResourceReadyCostTracking- testsreadyWhenexpression cost trackingTestReadyToProcessResourceCostTracking- testsincludeWhenexpression cost trackingTestCELCostMultipleResources- tests cost tracking across multiple resourcesTestCELCostReadyWhen- focused test for readyWhen expressionsExample Output
After reconciliation, the instance status includes CEL metrics: