apache / apache/rocketmq-clients
[Java] Expose client metrics through an optional JMX reporter
- Dominant language
- Java
- Stars
- 505
- Forks
- 313
- Avg merge
- 11h 28m
- Merged PRs (30d)
- 6
Description
### Background
The Java gRPC client currently exports its built-in message metrics only through the server-provided OTLP endpoint. Applications that operate their own Prometheus stack need a way to collect the same client-side metrics without adding a client-owned HTTP endpoint or a Prometheus dependency.
### Proposal
Add an internal reporter following Kafka's `JmxReporter` model:
- Keep the reporter disabled by default.
- Enable it with the JVM system property `-Drocketmq.client.jmx.enabled=true`.
- Register metrics in the platform MBean server under the `org.apache.rocketmq.client` domain.
- Let an application-provided Prometheus JMX Exporter scrape the MBeans when present.
- Do not add a public client API, a network port, or a Prometheus library dependency.
- Keep JMX collection independent from the server-controlled OTLP metrics setting.
- Unregister client-owned MBeans during client shutdown.
### Metrics
Expose the existing client metrics and labels:
- `rocketmq_send_cost_time`: histogram with `topic`, `client_id`, and `invocation_status`.
- `rocketmq_delivery_latency`: histogram with `topic`, `client_id`, and `consumer_group`.
- `rocketmq_await_time`: histogram with `topic`, `client_id`, and `consumer_group`.
- `rocketmq_process_time`: histogram with `topic`, `client_id`, `consumer_group`, and `invocation_status`.
- `rocketmq_consumer_cached_messages`: gauge.
- `rocketmq_consumer_cached_bytes`: gauge.
Histogram MBeans should expose count, sum, finite buckets, and the positive-infinity bucket so that an external collector can map them to Prometheus metrics.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing how the existing Java client metrics are registered and how client shutdown is handled, then compare the required reporter behavior with Kafka's JmxReporter model. Done means an opt-in platform MBean registration exposes all listed metrics and histogram fields, remains independent of OTLP, adds no public API or endpoint, and unregisters client-owned MBeans during shutdown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, observability-sre
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100