You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/05/30 09:04:59 UTC
[GitHub] [kafka] dajac opened a new pull request, #12227: MINOR: inline metrics in RecordAccumulator
dajac opened a new pull request, #12227:
URL: https://github.com/apache/kafka/pull/12227
### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] dajac commented on a diff in pull request #12227: MINOR: inline metrics in RecordAccumulator
Posted by GitBox <gi...@apache.org>.
dajac commented on code in PR #12227:
URL: https://github.com/apache/kafka/pull/12227#discussion_r885679085
##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/RecordAccumulator.java:
##########
@@ -195,29 +193,17 @@ public RecordAccumulator(LogContext logContext,
}
private void registerMetrics(Metrics metrics, String metricGrpName) {
- MetricName metricName = metrics.metricName("waiting-threads", metricGrpName, "The number of user threads blocked waiting for buffer memory to enqueue their records");
- Measurable waitingThreads = new Measurable() {
- public double measure(MetricConfig config, long now) {
- return free.queued();
- }
- };
- metrics.addMetric(metricName, waitingThreads);
+ MetricName metricName = metrics.metricName("waiting-threads", metricGrpName,
+ "The number of user threads blocked waiting for buffer memory to enqueue their records");
+ metrics.addMetric(metricName, (config, now) -> free.queued());
- metricName = metrics.metricName("buffer-total-bytes", metricGrpName, "The maximum amount of buffer memory the client can use (whether or not it is currently used).");
- Measurable totalBytes = new Measurable() {
- public double measure(MetricConfig config, long now) {
- return free.totalMemory();
- }
- };
- metrics.addMetric(metricName, totalBytes);
+ metricName = metrics.metricName("buffer-total-bytes", metricGrpName,
Review Comment:
I agree. I have refactored it.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] hachikuji commented on a diff in pull request #12227: MINOR: inline metrics in RecordAccumulator
Posted by GitBox <gi...@apache.org>.
hachikuji commented on code in PR #12227:
URL: https://github.com/apache/kafka/pull/12227#discussion_r885101221
##########
clients/src/main/java/org/apache/kafka/clients/producer/internals/RecordAccumulator.java:
##########
@@ -195,29 +193,17 @@ public RecordAccumulator(LogContext logContext,
}
private void registerMetrics(Metrics metrics, String metricGrpName) {
- MetricName metricName = metrics.metricName("waiting-threads", metricGrpName, "The number of user threads blocked waiting for buffer memory to enqueue their records");
- Measurable waitingThreads = new Measurable() {
- public double measure(MetricConfig config, long now) {
- return free.queued();
- }
- };
- metrics.addMetric(metricName, waitingThreads);
+ MetricName metricName = metrics.metricName("waiting-threads", metricGrpName,
+ "The number of user threads blocked waiting for buffer memory to enqueue their records");
+ metrics.addMetric(metricName, (config, now) -> free.queued());
- metricName = metrics.metricName("buffer-total-bytes", metricGrpName, "The maximum amount of buffer memory the client can use (whether or not it is currently used).");
- Measurable totalBytes = new Measurable() {
- public double measure(MetricConfig config, long now) {
- return free.totalMemory();
- }
- };
- metrics.addMetric(metricName, totalBytes);
+ metricName = metrics.metricName("buffer-total-bytes", metricGrpName,
Review Comment:
While we're at it, these redefinitions are a little annoying. Could we create a little helper or just use different variables? e.g.:
```java
MetricName waitingThreadsName = metrics.metricName("waiting-threads", metricGrpName,
"The number of user threads blocked waiting for buffer memory to enqueue their records");
metrics.addMetric(waitingThreadsName, (config, now) -> free.queued());
...
```
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] dajac merged pull request #12227: MINOR: inline metrics in RecordAccumulator
Posted by GitBox <gi...@apache.org>.
dajac merged PR #12227:
URL: https://github.com/apache/kafka/pull/12227
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org