Skip to content

Use publicly_disabled_labeled_metrics table for available_label_fqns - #5022

Draft
IvanIvanoff wants to merge 1 commit into
masterfrom
support-disabling-label-fqns
Draft

Use publicly_disabled_labeled_metrics table for available_label_fqns#5022
IvanIvanoff wants to merge 1 commit into
masterfrom
support-disabling-label-fqns

Conversation

@IvanIvanoff

@IvanIvanoff IvanIvanoff commented Feb 27, 2026

Copy link
Copy Markdown
Member

Changes

The table publicly_disabled_labeled_metrics allows the bigdata/metrics teams to selectively disable some labels for some metrics, if there is an issue with that computation.

Coverting to draft as we would need to also support the status and not disable always.
Sometimes it would need only to warn

Ticket

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have tried to find clearer solution before commenting hard-to-understand parts of code
  • I have added tests that prove my fix is effective or that my feature works

Summary by CodeRabbit

  • Bug Fixes
    • Fixed filtering logic to consistently exclude publicly-disabled metrics and labels from query results across all metric-related queries.

@coderabbitai

coderabbitai Bot commented Feb 27, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

A new SQL filter helper function is added to exclude publicly-disabled labels from metric queries. The filter is imported and applied consistently across multiple query builders for available label and metric datetime computations.

Changes

Cohort / File(s) Summary
Query Builder Updates
lib/sanbase/clickhouse/metric/sql_query/metric_sql_query.ex
Extended SQL query builders to include not_publicly_disabled_label_filter in WHERE clauses for available label enumeration and metric datetime queries. Import list updated to include the new helper function.
Filter Implementation
lib/sanbase/metric/sql_query_helper.ex
Implemented new public function not_publicly_disabled_label_filter(opts) that generates SQL filters excluding labels from the publicly_disabled_labeled_metrics table. Supports filtering by both label_id and fqn strategies using ClickHouse dictGet operations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 With whiskers twitching and ears held high,
I filter labels that shouldn't fly,
Public disables now caught in the net,
Queries refined—no leaks just yet! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% 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 directly reflects the main change: adding filtering based on the publicly_disabled_labeled_metrics table to the available_label_fqns queries.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch support-disabling-label-fqns

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

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

Inline comments:
In `@lib/sanbase/metric/sql_query_helper.ex`:
- Around line 215-249: The public function not_publicly_disabled_label_filter/1
is missing a `@spec` and an example in its `@doc`; add a typespec such as `@spec`
not_publicly_disabled_label_filter(keyword()) :: String.t() (or more specific
Keyword.t() -> String.t()) placed above the def, and update the `@doc` to include
a minimal usage example showing how to call it with an argument_name and
filter_by (e.g. opts = [argument_name: "metric_name", filter_by: :label_id] and
call not_publicly_disabled_label_filter(opts) — include one example for
:label_id and one brief variant for :fqn if desired) so the doc demonstrates
expected input and returned SQL string.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f04b035 and 31b40e1.

📒 Files selected for processing (2)
  • lib/sanbase/clickhouse/metric/sql_query/metric_sql_query.ex
  • lib/sanbase/metric/sql_query_helper.ex

Comment thread lib/sanbase/metric/sql_query_helper.ex
@IvanIvanoff
IvanIvanoff marked this pull request as draft February 27, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants