Repository navigation
fix(estimator): inject call options in StructuredLogEstimator and document Google API guidelines - #900
Merged
Conversation
kyasbal
requested review from
K53,
RyuSA,
jyane,
kkuchima and
renamoo
as code owners
August 25, 2026 08:24
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces mandatory rules and guidelines for calling Google Cloud APIs in KHI, including the addition of a new skill guide and task rules regarding the CallOptionInjector. The StructuredLogEstimator and StructuredListLogEntriesTask have been updated to support injecting call options into the context. The review feedback suggests strictly adhering to the new rules by retrieving the injector using coretask.GetTaskResult instead of GetTaskResultOptional in StructuredListLogEntriesTask, and simplifying the corresponding test by removing the unnecessary test case that runs without this mandatory dependency.
Pass CallOptionInjector into StructuredLogEstimator and call InjectToCallContext prior to querying Cloud Monitoring metrics and Cloud Logging probe entries. In StructuredListLogEntriesTask, retrieve CallOptionInjector from task dependencies and provide it during volume estimation. Add googlecloud-api skill and update task rules to document mandatory CallOptionInjector usage when calling Google APIs in KHI.
kyasbal
force-pushed
the
push-qpzqrvsmmnvr
branch
from
August 25, 2026 08:49
fe8b49b to
b57a18a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR ensures that Google Cloud API call options are properly injected into the request context before executing volume estimation queries in
StructuredLogEstimator. It also introduces documentation and repository rules defining the mandatory usage ofCallOptionInjectorwhenever calling Google Cloud APIs across KHI.Background & Motivation
StructuredLogEstimator:StructuredLogEstimatorqueries Cloud Monitoring metrics and Cloud Logging probe entries during log volume estimation. Previously,InjectToCallContextwas not invoked on the context prior to issuing these queries. Consequently, gRPC call options, custom request headers, and quota project parameters were not propagated, which could lead to API call failures or unexpected quota accounting.In KHI, all calls to Google Cloud APIs must carry options associated with their target resource container (
googlecloud.Project,googlecloud.Folder, orgooglecloud.Organization). A dedicated skill and rule documentation ensures all current and future tasks/components adhere to this requirement.Key Changes
1. Go Backend
pkg/api/googlecloud/logestimator/estimator.go:CallOptionInjector *googlecloud.CallOptionInjectorfield toStructuredLogEstimator.NewStructuredLogEstimatorandNewStructuredLogEstimatorFromClientsto acceptcallOptionInjector.Estimate(), appliedctx = e.CallOptionInjector.InjectToCallContext(ctx, container)before spawning goroutines witherrgroup.WithContext(ctx).pkg/task/inspection/googlecloudcommon/contract/structured_listlogentries_task.go:APIClientCallOptionsInjectorTaskID.Ref()to task dependencies.callOptionInjectorviacoretask.GetTaskResultOptionaland forwarded it toStructuredLogEstimator.pkg/api/googlecloud/logestimator/estimator_test.go: AddedTestStructuredLogEstimator_CallOptionInjectorverifying context injection on Cloud Monitoring and Cloud Logging queries.pkg/task/inspection/googlecloudcommon/contract/structured_listlogentries_task_test.go: AddedTestStructuredListLogEntriesTask_DryRun_CallOptionInjectortesting dependency resolution and call option propagation.nil.2. Developer & Agent Guidelines
.agents/skills/googlecloud_api/SKILL.md:.agents/skills/khi_parser/SKILL.md:googlecloud-apiskill in Step 2 (Log Query Tasks)..agents/rules/khi-task-rule.md:CallOptionInjector.InjectToCallContextfor any task invoking Google Cloud APIs.Verification
make test-gopassed (all 672 top-level tests, 2,732 subtests).make lint-go,make lint-md,make format-md, andmake pre-commitpassed with 0 issues.