avirlrma commented on issue #21663:
URL: https://github.com/apache/pulsar/issues/21663#issuecomment-2241549114
# Proposal: URL Parameter Filtering for Pulsar Broker Metrics
## Proposed Approaches
I was able to come up with two potential approaches for implementing this
feature:
### Approach 1: Modify Individual Metric Generation Methods
This approach involves modifying each metric generation method to include
filtering logic.
Pros:
- Direct and straightforward implementation
- Potential for better performance as filtering happens at the source
- Allows for fine-grained control over filtering for each metric type
Cons:
- Requires changes to multiple classes and methods
(`NamespaceStatsAggregator`, `PrometheusMetricsProvider`,
`TransactionAggregator`, `MetricsProviders` etc.)
- May lead to code duplication
- More difficult to maintain and update in the future
### Approach 2: Subclass SimpleTextOutputStream
This approach involves creating a new FilteringTextOutputStream that extends
SimpleTextOutputStream and incorporates the filtering logic.
Pros:
- Centralized filtering logic
- Minimal changes to existing metric generation methods
- Easier to maintain and extend in the future
- Consistent filtering across all metric types
Cons:
- Slight performance overhead due to buffering each line
- May use more memory temporarily while buffering lines
- Less fine-grained control over filtering for specific metric types
## Implementation Details (Common to Both Approaches)
1. URL Parameter:
- We will use the query parameter "m" to specify the filter.
- Example: `/metrics?m=jvm_.*`
2. Filter Format:
- The filter will use Java regular expressions for maximum flexibility.
Having suggested both the approaches, I am leaning towards approach#1, as
it more of a long-term solution to metric filtering problem, just not when
output stream is involved.
Would appreciate feedback on this. Thanks!
CC: @zwOvO
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]