Skip to content

ROX-33893: glob patterns for header name#19723

Open
parametalol wants to merge 5 commits intomasterfrom
michael/ROX-33893-header-name-glob-v2
Open

ROX-33893: glob patterns for header name#19723
parametalol wants to merge 5 commits intomasterfrom
michael/ROX-33893-header-name-glob-v2

Conversation

@parametalol
Copy link
Copy Markdown
Contributor

@parametalol parametalol commented Mar 31, 2026

Description

Support glob patterns in telemetry header names, not just values. Previously, campaigns could only match exact header names. Now both header names and values support globs (e.g., "Rh-*": NoHeaderOrAnyValue).

Key changes:

  • APICallCampaignCriterion.Headers: map[string]glob.Pattern -> map[glob.Pattern]glob.Pattern
  • Headers.GetAll: matches both header names and values using globs
  • ServiceNow integration now uses "Rh-*" pattern instead of hardcoded header name

Motivation:
ServiceNow sets headers with a common Rh- prefix, but the exact name may vary. Glob patterns for header names allow tracking related headers without hardcoding each variant.

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

  • Unit tests cover glob matching on header names and values, including match/no-match/error cases
  • Existing campaign, interceptor, and request_params tests updated for the refactored Headers field
  • ServiceNow integration test validates "Rh-*" pattern matching
  • All tests pass: go test ./pkg/telemetry/phonehome/... ./central/telemetry/centralclient/...

Current dependencies on/for this PR:

@parametalol parametalol changed the title michael/ROX-33893-header-name-glob-v2 ROX-33893: add support for glob patterns in API call telemetry interceptor header name Mar 31, 2026
@parametalol parametalol changed the title ROX-33893: add support for glob patterns in API call telemetry interceptor header name ROX-33893: glob patterns in telemetry campaign criterion header name Mar 31, 2026
@parametalol parametalol changed the title ROX-33893: glob patterns in telemetry campaign criterion header name ROX-33893: glob patterns for header name Mar 31, 2026
@rhacs-bot
Copy link
Copy Markdown
Contributor

rhacs-bot commented Mar 31, 2026

Images are ready for the commit at f2435e7.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-542-gf2435e76f1.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 82.22222% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.60%. Comparing base (118ca3c) to head (1b30c5d).

Files with missing lines Patch % Lines
pkg/telemetry/phonehome/campaign.go 37.50% 3 Missing and 2 partials ⚠️
pkg/telemetry/phonehome/headers_multimap.go 88.88% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19723   +/-   ##
=======================================
  Coverage   49.60%   49.60%           
=======================================
  Files        2763     2763           
  Lines      208271   208301   +30     
=======================================
+ Hits       103309   103337   +28     
- Misses      97294    97295    +1     
- Partials     7668     7669    +1     
Flag Coverage Δ
go-unit-tests 49.60% <82.22%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@parametalol parametalol force-pushed the michael/telemetry-requestparam-refactoring branch from 2e708df to 27967f6 Compare April 1, 2026 07:58
@parametalol parametalol force-pushed the michael/ROX-33893-header-name-glob-v2 branch from 737025b to 8050edc Compare April 1, 2026 08:00
@parametalol parametalol marked this pull request as draft April 1, 2026 12:00
@parametalol parametalol force-pushed the michael/ROX-33893-header-name-glob-v2 branch from 8050edc to 694e641 Compare April 1, 2026 16:13
@parametalol parametalol force-pushed the michael/telemetry-requestparam-refactoring branch from 2aa5f95 to 5f7202d Compare April 1, 2026 18:59
@parametalol parametalol force-pushed the michael/ROX-33893-header-name-glob-v2 branch from e6be8b7 to a2443b7 Compare April 1, 2026 19:04
@parametalol parametalol marked this pull request as ready for review April 2, 2026 08:17
@parametalol parametalol requested review from a team and stehessel April 2, 2026 08:17
@parametalol parametalol force-pushed the michael/ROX-33893-header-name-glob-v2 branch from a2443b7 to 9024b12 Compare April 2, 2026 10:18
Base automatically changed from michael/telemetry-requestparam-refactoring to master April 2, 2026 12:31
@parametalol parametalol force-pushed the michael/ROX-33893-header-name-glob-v2 branch from 9024b12 to f2435e7 Compare April 2, 2026 12:34
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Refactor

    • Enhanced header pattern matching to support glob patterns for both header names and values, enabling more flexible telemetry campaign criteria matching. ServiceNow integration detection now matches any header with "Rh-*" pattern.
  • Tests

    • Added comprehensive test coverage for header name and value glob pattern matching in telemetry campaigns, including multi-header scenarios and method-based filtering.

Walkthrough

The changes refactor header matching logic to support glob patterns for both header names and values instead of just values, updating method signatures and implementations across the telemetry and phonehome packages, including tests and telemetry client usage.

Changes

Cohort / File(s) Summary
Core Header Matching Logic
pkg/telemetry/phonehome/campaign.go, pkg/telemetry/phonehome/headers_multimap.go, pkg/telemetry/phonehome/request_params.go
Updated header matching to support glob patterns for both header names and values. HeaderPattern now accepts two glob patterns (header name and value). GetMatching method signature changed to accept a glob pattern for the header key. GlobMap type changed from map[string]glob.Pattern to map[glob.Pattern]glob.Pattern.
Test Coverage Expansions
pkg/telemetry/phonehome/campaign_test.go, pkg/telemetry/phonehome/headers_multimap_test.go, pkg/telemetry/phonehome/interceptor_test.go, pkg/telemetry/phonehome/request_params_test.go
Added comprehensive test coverage for header name and value glob pattern matching. Renamed TestGetMatching to TestGetMatchingValues. Added TestGetMatching_withKeyPattern and glob matching validation in campaign and interceptor tests.
Telemetry Client Updates
central/telemetry/centralclient/interceptors.go, central/telemetry/centralclient/interceptors_test.go
Removed exported snowIntegrationHeader constant from production code; moved to test-only constant. Updated ServiceNow campaign criterion to match any header with "Rh-*" key pattern instead of specific header key.
Comment Refinement
pkg/telemetry/phonehome/interceptor.go
Reformatted inline comment for HTTP request details code path to single-line format.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding support for glob patterns in header names. It accurately reflects the primary objective of the PR.
Description check ✅ Passed The description comprehensively covers the change with detailed explanation, key changes, motivation, and addresses all template sections including testing, quality, and validation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch michael/ROX-33893-header-name-glob-v2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/telemetry/phonehome/headers_multimap.go`:
- Around line 54-74: GetMatching on Headers returns nil for a nil/empty Headers
when value == NoHeaderOrAnyValue, causing inconsistent behavior versus the
loop's special-case; update Headers.GetMatching so that if h is nil (or empty)
and value == NoHeaderOrAnyValue it returns an empty map instead of nil, e.g. in
the beginning of GetMatching check if value == NoHeaderOrAnyValue and return
make(map[string][]string) when h == nil (and then remove/keep the in-loop
initialization accordingly); reference: Headers.GetMatching, NoHeaderOrAnyValue,
GetMatchingValues.

In `@pkg/telemetry/phonehome/request_params.go`:
- Around line 34-45: RequestParams.MatchHeaders currently uses maps.Copy to
merge per-pattern matches which causes later patterns to overwrite earlier
concrete header entries (non-deterministic for overlapping globs). Replace the
maps.Copy(result, matching) behavior in RequestParams.MatchHeaders with a
per-key merge: iterate over each concrete header key returned by GetMatching and
if that header already exists in result, combine/union the values instead of
replacing them; ensure the merge semantics match the Headers type (e.g., append
or deduplicate values). Alternatively, add a validation step when constructing
the GlobMap to detect and reject overlapping header-name patterns (X-* vs
X-Test) so MatchHeaders can keep deterministic behavior; reference
RequestParams.MatchHeaders, GetMatching, Headers, GlobMap and NoHeaderOrAnyValue
when implementing the fix.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: d7b9db3c-5c82-43f3-afa3-2e6d81168f75

📥 Commits

Reviewing files that changed from the base of the PR and between 994dff5 and f2435e7.

📒 Files selected for processing (10)
  • central/telemetry/centralclient/interceptors.go
  • central/telemetry/centralclient/interceptors_test.go
  • pkg/telemetry/phonehome/campaign.go
  • pkg/telemetry/phonehome/campaign_test.go
  • pkg/telemetry/phonehome/headers_multimap.go
  • pkg/telemetry/phonehome/headers_multimap_test.go
  • pkg/telemetry/phonehome/interceptor.go
  • pkg/telemetry/phonehome/interceptor_test.go
  • pkg/telemetry/phonehome/request_params.go
  • pkg/telemetry/phonehome/request_params_test.go

@parametalol
Copy link
Copy Markdown
Contributor Author

/retest

@parametalol
Copy link
Copy Markdown
Contributor Author

/retest

@parametalol parametalol force-pushed the michael/ROX-33893-header-name-glob-v2 branch from 646fe3c to 1b30c5d Compare April 3, 2026 09:05
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

🚀 Build Images Ready

Images are ready for commit 1b30c5d. To use with deploy scripts:

export MAIN_IMAGE_TAG=4.11.x-561-g1b30c5da4e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants