Skip to content

refactor(structured,parsers): optimize log parsing with FieldPath interning and Extractor pattern - #928

Merged
kyasbal merged 5 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-qsvrnyvlvsvv
Aug 31, 2026
Merged

kyasbal merged 5 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-qsvrnyvlvsvv

Conversation

@kyasbal

@kyasbal kyasbal commented Aug 31, 2026

Copy link
Copy Markdown
Member

Summary

This PR introduces typed log extraction optimizations and structured log parsing enhancements across all inspection log parsers in KHI:

  1. Pre-compiled FieldPath & Interning:

    • Introduces structured.CompileFieldPath with unique.Handle string interning to avoid repeated allocations and path parsing during hot log inspection loops.
    • Migrates log readers and models to use package-level CompileFieldPath definitions.
  2. Extractor Pattern & Typed Parsing:

    • Migrates K8s audit log parsers, GCP audit log parsers, and remaining log parsers (GKE Autoscaler, serial port, K8s events/control-plane/node/containers, etc.) to the typed Extractor pattern.
    • Replaces untyped map-based log parsing with high-performance typed access via NodeReader.
  3. Testing Infrastructure:

    • Introduces structured.MockNode and test utilities for fast, deterministic unit testing of log parsers without JSON serialization overhead.
    • Migrates unit tests across log parsers to use table-driven tests with MockNode and cmp.Diff.

Verification

  • make pre-commit passed cleanly.
  • make lint-web passed cleanly.
  • make test-web passed cleanly (1066/1066 tests).
  • make test-go passed cleanly across all backend packages.
  • make build-go and make build-web passed cleanly.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the log parsing architecture in KHI by replacing the FieldSetReaderTask pattern with a more efficient, direct extraction approach using Extract functions and structured.NodeReader. It also introduces structured.CompileFieldPath for optimized path traversal and updates various log parsing packages and tests to adopt this new pattern, including the addition of testlog.NewMockLog for improved testing. Documentation has been updated to reflect these architectural changes. I have no feedback to provide.

Comment thread .agents/skills/khi_parser/SKILL.md Resolved
Comment thread .agents/skills/khi_parser/SKILL.md Resolved
Comment thread .agents/skills/khi_parser/SKILL.md Resolved
Comment thread .agents/skills/khi_parser/SKILL.md Resolved
Comment thread pkg/common/structured/reader.go Resolved
Comment thread .agents/skills/khi_parser/SKILL.md Resolved
@kyasbal
kyasbal merged commit d141b61 into GoogleCloudPlatform:main Aug 31, 2026
16 checks passed
@kyasbal
kyasbal deleted the push-qsvrnyvlvsvv branch August 31, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant