Skip to content

feat: Sumo Logic multi-query (ABC pattern) support [PC-18992]#889

Open
nikodemrafalski wants to merge 3 commits intomainfrom
PC-18992-implement-multi-query-support-for-sumo-logic-metrics-integration
Open

feat: Sumo Logic multi-query (ABC pattern) support [PC-18992]#889
nikodemrafalski wants to merge 3 commits intomainfrom
PC-18992-implement-multi-query-support-for-sumo-logic-metrics-integration

Conversation

@nikodemrafalski
Copy link
Contributor

@nikodemrafalski nikodemrafalski commented Mar 4, 2026

Motivation

Sumo Logic metrics support a multi-query (ABC) pattern where users define up to 6 query rows (A–F) and later rows reference earlier ones using #A, #B, #C syntax (e.g., #C = (#A / #B) * 100). This enables complex SLI calculations that aren't possible with a single query.

Summary

  • New SumoLogicQuery struct with RowID (A–F) and Query fields
  • New Queries []SumoLogicQuery field on SumoLogicMetric, mutually exclusive with the existing Query field
  • GetQueries() helper normalizes both representations into a single code path
  • Existing Query field marked as deprecated but fully supported for backward compatibility
  • Validation: mutual exclusivity, 1–6 items, unique uppercase A–F row IDs, non-empty queries, forbidden for logs type
  • Count metrics quantization match validation updated to handle both paths

Release Notes

SumoLogicMetric now supports multi-query (ABC pattern). A new Queries field accepts up to 6 query rows (A–F), where later rows can reference earlier ones via #A, #B, etc. The GetQueries() method provides backward-compatible access. Query and Queries are mutually exclusive; Queries is only allowed for the metrics type.

PC-18992

@n9-machine-user n9-machine-user added enhancement New feature or request go minor labels Mar 4, 2026
Fix FormatQuery nil return for multi-query metrics by using GetQueries()
to return the last query. Add nil guard for Query pointer dereference in
count metrics timeslice validation. Remove unused sumoLogicValidRowIDs
variable. Add unit tests for GetQueries() and multi-query count metrics.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds multi-query (ABC pattern) support for Sumo Logic metrics, enabling up to 6 query rows (A–F) where later rows can reference earlier ones using #A, #B, etc. The change maintains backward compatibility with the existing single Query field while introducing a new Queries slice field.

Changes:

  • New SumoLogicQuery struct and Queries field on SumoLogicMetric, with a GetQueries() helper that normalizes both legacy and new representations into a single code path.
  • Comprehensive validation: mutual exclusivity of query/queries, row ID uniqueness and range (A–F), slice length (1–6), queries forbidden for logs type, and count metrics quantization matching updated for both paths.
  • Updated FormatQuery to use GetQueries() for the SumoLogic case, returning the last query row's content.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
manifest/v1alpha/slo/metrics_sumo_logic.go New SumoLogicQuery struct, Queries field, GetQueries() method, multi-query validation rules, null safety guard in count metrics validation
manifest/v1alpha/slo/metrics_sumo_logic_test.go Tests for multi-query validation, GetQueries() normalization, count metrics with multi-query, and updated error expectations
manifest/v1alpha/slo/metrics.go Updated FormatQuery to use GetQueries() and return the last query row for SumoLogic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@skrolikiewicz skrolikiewicz left a comment

Choose a reason for hiding this comment

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

PR Review

Existing comments (Copilot)

Both are valid:

  1. Dead code in FormatQuery — the return m.SumoLogic.Query fallback is unreachable since GetQueries() already normalizes the legacy field.
  2. Extra blank line at metrics_sumo_logic.go:187 — trivial formatting.

New Findings

Breaking change: query field gained omitempty — Medium-High

The JSON tag changed from json:"query" to json:"query,omitempty". Previously, serializing a SumoLogicMetric with Query: nil produced "query": null in JSON. Now it omits the key entirely. Any downstream consumer expecting the query key to always be present will break. This is a backward-incompatible serialization change that should be intentional and documented, or reverted.

FormatQuery "last query" semantics — Low

queries[len(queries)-1].Query returns the last row (e.g. #A - #B), which is typically the "result" expression. This is reasonable but the rationale isn't documented. No external callers were found in this repo, so low risk.

Everything else looks correct

  • Mutual exclusivity of query/queries is properly enforced
  • Row ID validation (A-F, unique) is solid
  • queries is correctly forbidden for logs type
  • Count metrics quantization comparison handles Query == nil correctly (the nil guard added in the fix commit)
  • GetQueries() normalization logic is clean and well-tested
  • Test coverage is thorough across all validation paths

@nikodemrafalski
Copy link
Contributor Author

/build

@nikodemrafalski nikodemrafalski marked this pull request as ready for review March 11, 2026 09:17
Copy link
Member

@skrolikiewicz skrolikiewicz left a comment

Choose a reason for hiding this comment

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

PR Review (Round 2)

All three issues from the previous review have been addressed in f97f239:

  1. Dead code in FormatQuery — fixed, now uses clean early-return pattern
  2. query omitempty breaking change — reverted to json:"query"
  3. Extra blank line — removed

Fresh review of the current state found no remaining issues. Validation logic is correct across all paths, nil guards are properly placed, JSON tags preserve backward compatibility, and test coverage is thorough.

LGTM

@nikodemrafalski nikodemrafalski changed the title feat: Sumo Logic multi-query (ABC pattern) support feat: Sumo Logic multi-query (ABC pattern) support [PC-18992] Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants