Skip to content

Conversation

@coderzc
Copy link
Member

@coderzc coderzc commented Nov 16, 2025

PIP: https://github.com/apache/pulsar/blob/master/pip/pip-447.md

Motivation

Modifications

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Nov 16, 2025
@lhotari lhotari requested a review from Copilot January 2, 2026 14:06
Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

One comment about the usage of PolicyName.MAX_SUBSCRIPTIONS

Copy link
Contributor

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 implements PIP-447 to add support for customizable Prometheus labels on topic metrics, allowing operators to attach custom metadata (like SLA tier, team ownership, etc.) to topics that will be exposed as Prometheus labels.

Key changes:

  • Adds customMetricLabels field to TopicPolicies with clone and validation support
  • Implements REST APIs, admin client methods, and CLI commands for managing custom metric labels
  • Integrates custom labels into Prometheus metrics generation in TopicStats
  • Adds configuration options to enable/disable the feature and control allowed label keys and value lengths

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/TopicPolicies.java Adds customMetricLabels field with proper cloning and accessor methods
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/HierarchyTopicPolicies.java Adds PolicyHierarchyValue for customMetricLabels to support policy hierarchy
pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/TopicPolicies.java Adds API methods for setting, getting, and removing custom metric labels
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TopicPoliciesImpl.java Implements client-side REST API calls for custom metric labels operations
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java Adds CLI commands for managing custom metric labels in CmdTopics
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopicPolicies.java Adds CLI commands for managing custom metric labels in CmdTopicPolicies
pulsar-client-tools/src/test/java/org/apache/pulsar/admin/cli/CmdTopicPoliciesTest.java Adds comprehensive tests for CLI command functionality
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java Adds REST endpoints for custom metric labels operations
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java Implements business logic for setting, getting, and removing custom metric labels with validation
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java Updates topic policy loading to include customMetricLabels
pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/TopicStats.java Modifies metrics generation to include custom labels in Prometheus output
pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/NamespaceStatsAggregator.java Retrieves and passes custom metric labels to TopicStats for metrics generation
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java Adds integration tests for custom metric labels feature including validation scenarios
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java Adds three configuration properties for the custom metric labels feature
conf/broker.conf Documents the new configuration properties with examples

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

@coderzc coderzc marked this pull request as draft January 5, 2026 02:43
…configuration

- Add namespace-level allowed_topic_properties_for_metrics field in Policies.java
- Add admin API methods for set/get/remove allowedTopicPropertiesForMetrics
- Add REST endpoints in Namespaces.java (v2)
- Add CLI commands: set-allowed-topic-properties-for-metrics, get-allowed-topic-properties-for-metrics, remove-allowed-topic-properties-for-metrics
- Integrate with Prometheus metrics generation to merge broker-level and namespace-level configurations
- Add test for namespace-level allowedTopicPropertiesForMetrics
Since PIP-447 now uses topic properties instead of topic policies, this removes:
- TopicPolicies.customMetricLabels field and methods
- HierarchyTopicPolicies.customMetricLabels field
- TopicPolicies admin API methods (set/get/removeCustomMetricLabels)
- CLI commands in CmdTopicPolicies and CmdTopics
- TopicPoliciesImpl implementation
- REST API endpoints in PersistentTopics.java (v2)
- Internal methods in PersistentTopicsBase.java
- References in AbstractTopic.java
- Unit tests in CmdTopicPoliciesTest.java
- Renamed test method in PrometheusMetricsLabelsTest.java
@coderzc coderzc closed this Feb 12, 2026
@coderzc coderzc reopened this Feb 12, 2026
@coderzc coderzc marked this pull request as ready for review February 12, 2026 02:04
…LabelValueLength and clarify allowedTopicPropertiesForMetrics documentation
…metrics

- Move logic for fetching and filtering custom metric labels to TopicStats
- Simplify NamespaceStatsAggregator by delegating label handling to TopicStats
- Ensure only allowed topic properties are exposed as custom metric labels
@github-actions github-actions bot added the PIP label Feb 12, 2026
@coderzc coderzc added this to the 4.2.0 milestone Feb 12, 2026
@coderzc coderzc added the type/feature The PR added a new feature or issue requested a new feature label Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/metrics doc-not-needed Your PR changes do not impact docs PIP ready-to-test type/feature The PR added a new feature or issue requested a new feature type/PIP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants