-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-16115: Adding missing heartbeat metrics #15216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
0d6fcce
heartbeat metrics
112f6ce
clean up
946c740
remove lastHeartbeatsend and use the requestState var instead
6bd15e8
update test
6759da1
clean up
39c5239
allow the manager to accept a group prefix
c55dae2
clean up
df8ac28
Update AbstractConsumerMetrics.java
6151964
Reconsolidate metrics into consumer coordinator metrics
a84f83b
clean up name
4f39701
heartbeat metrics
99d6fab
clean up
cf95499
remove lastHeartbeatsend and use the requestState var instead
631a755
update test
e96a06e
clean up
6043316
allow the manager to accept a group prefix
d0e1728
clean up
2e425a6
Update AbstractConsumerMetrics.java
308daa2
Reconsolidate metrics into consumer coordinator metrics
8824608
clean up name
b17455e
resolving conflict
31b9757
Merge branch 'ctr-heartbeat-metrics' of https://github.com/philipnee/…
6285909
resolve conflict
1424ed9
make naming consistent
7076ba5
clean up
4eddba4
Update HeartbeatRequestManagerTest.java
9c86077
privatize metric field
336c443
Merge branch 'trunk' into ctr-heartbeat-metrics
8964a8d
PR comments
22fcb39
clean up according to PR comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,10 +23,12 @@ | |
| import org.apache.kafka.clients.consumer.internals.events.BackgroundEventHandler; | ||
| import org.apache.kafka.clients.consumer.internals.events.ErrorBackgroundEvent; | ||
| import org.apache.kafka.clients.consumer.internals.events.GroupMetadataUpdateEvent; | ||
| import org.apache.kafka.clients.consumer.internals.metrics.HeartbeatMetricsManager; | ||
| import org.apache.kafka.common.Uuid; | ||
| import org.apache.kafka.common.errors.GroupAuthorizationException; | ||
| import org.apache.kafka.common.errors.RetriableException; | ||
| import org.apache.kafka.common.message.ConsumerGroupHeartbeatRequestData; | ||
| import org.apache.kafka.common.metrics.Metrics; | ||
| import org.apache.kafka.common.protocol.Errors; | ||
| import org.apache.kafka.common.requests.ConsumerGroupHeartbeatRequest; | ||
| import org.apache.kafka.common.requests.ConsumerGroupHeartbeatResponse; | ||
|
|
@@ -108,6 +110,7 @@ public class HeartbeatRequestManager implements RequestManager { | |
| * sending heartbeat until the next poll. | ||
| */ | ||
| private final Timer pollTimer; | ||
| private final HeartbeatMetricsManager metricsManager; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I'd either group this with the field below or separate this from |
||
|
|
||
| private GroupMetadataUpdateEvent previousGroupMetadataUpdateEvent = null; | ||
|
|
||
|
|
@@ -118,7 +121,8 @@ public HeartbeatRequestManager( | |
| final CoordinatorRequestManager coordinatorRequestManager, | ||
| final SubscriptionState subscriptions, | ||
| final MembershipManager membershipManager, | ||
| final BackgroundEventHandler backgroundEventHandler) { | ||
| final BackgroundEventHandler backgroundEventHandler, | ||
| final Metrics metrics) { | ||
| this.coordinatorRequestManager = coordinatorRequestManager; | ||
| this.logger = logContext.logger(getClass()); | ||
| this.membershipManager = membershipManager; | ||
|
|
@@ -130,6 +134,7 @@ public HeartbeatRequestManager( | |
| this.heartbeatRequestState = new HeartbeatRequestState(logContext, time, 0, retryBackoffMs, | ||
| retryBackoffMaxMs, maxPollIntervalMs); | ||
| this.pollTimer = time.timer(maxPollIntervalMs); | ||
| this.metricsManager = new HeartbeatMetricsManager(metrics); | ||
| } | ||
|
|
||
| // Visible for testing | ||
|
|
@@ -141,7 +146,8 @@ public HeartbeatRequestManager( | |
| final MembershipManager membershipManager, | ||
| final HeartbeatState heartbeatState, | ||
| final HeartbeatRequestState heartbeatRequestState, | ||
| final BackgroundEventHandler backgroundEventHandler) { | ||
| final BackgroundEventHandler backgroundEventHandler, | ||
| final Metrics metrics) { | ||
| this.logger = logContext.logger(this.getClass()); | ||
| this.maxPollIntervalMs = config.getInt(CommonClientConfigs.MAX_POLL_INTERVAL_MS_CONFIG); | ||
| this.coordinatorRequestManager = coordinatorRequestManager; | ||
|
|
@@ -150,6 +156,7 @@ public HeartbeatRequestManager( | |
| this.membershipManager = membershipManager; | ||
| this.backgroundEventHandler = backgroundEventHandler; | ||
| this.pollTimer = timer; | ||
| this.metricsManager = new HeartbeatMetricsManager(metrics); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -245,6 +252,7 @@ private NetworkClientDelegate.UnsentRequest makeHeartbeatRequest(final long curr | |
| NetworkClientDelegate.UnsentRequest request = makeHeartbeatRequest(ignoreResponse); | ||
| heartbeatRequestState.onSendAttempt(currentTimeMs); | ||
| membershipManager.onHeartbeatRequestSent(); | ||
| metricsManager.recordHeartbeatSentMs(currentTimeMs); | ||
| return request; | ||
| } | ||
|
|
||
|
|
@@ -257,6 +265,7 @@ private NetworkClientDelegate.UnsentRequest makeHeartbeatRequest(final boolean i | |
| else | ||
| return request.whenComplete((response, exception) -> { | ||
| if (response != null) { | ||
| metricsManager.recordRequestLatency(response.requestLatencyMs()); | ||
| onResponse((ConsumerGroupHeartbeatResponse) response.responseBody(), request.handler().completionTimeMs()); | ||
| } else { | ||
| onFailure(exception, request.handler().completionTimeMs()); | ||
|
|
@@ -267,6 +276,7 @@ private NetworkClientDelegate.UnsentRequest makeHeartbeatRequest(final boolean i | |
| private NetworkClientDelegate.UnsentRequest logResponse(final NetworkClientDelegate.UnsentRequest request) { | ||
| return request.whenComplete((response, exception) -> { | ||
| if (response != null) { | ||
| metricsManager.recordRequestLatency(response.requestLatencyMs()); | ||
| Errors error = | ||
| Errors.forCode(((ConsumerGroupHeartbeatResponse) response.responseBody()).data().errorCode()); | ||
| if (error == Errors.NONE) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
...ain/java/org/apache/kafka/clients/consumer/internals/metrics/AbstractConsumerMetrics.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final?