-
Notifications
You must be signed in to change notification settings - Fork 14.8k
KAFKA-19865: Document queues metrics changes in ops.html #21046
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
Open
JimmyWang6
wants to merge
2
commits into
apache:trunk
Choose a base branch
from
JimmyWang6:document
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
203 changes: 203 additions & 0 deletions
203
server/src/main/java/org/apache/kafka/server/share/metrics/ShareGroupMetricsRegistry.java
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 |
|---|---|---|
| @@ -0,0 +1,203 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.kafka.server.share.metrics; | ||
|
|
||
| import org.apache.kafka.common.MetricNameTemplate; | ||
| import org.apache.kafka.common.metrics.Metrics; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.HashSet; | ||
| import java.util.LinkedHashSet; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| public class ShareGroupMetricsRegistry { | ||
|
|
||
| public final MetricNameTemplate shareGroupCount; | ||
| public final MetricNameTemplate writeRate; | ||
| public final MetricNameTemplate writeTotal; | ||
| public final MetricNameTemplate writeLatencyAvg; | ||
| public final MetricNameTemplate writeLatencyMax; | ||
| public final MetricNameTemplate lastPrunedOffset; | ||
| public final MetricNameTemplate totalShareFetchRequestsPerSec; | ||
| public final MetricNameTemplate failedShareFetchRequestsPerSec; | ||
| public final MetricNameTemplate totalShareAcknowledgementRequestsPerSec; | ||
| public final MetricNameTemplate failedShareAcknowledgementRequestsPerSec; | ||
| public final MetricNameTemplate recordAcknowledgementsPerSec; | ||
| public final MetricNameTemplate partitionLoadTimeMs; | ||
| public final MetricNameTemplate requestTopicPartitionsFetchRatio; | ||
| public final MetricNameTemplate topicPartitionsAcquireTimeMs; | ||
| public final MetricNameTemplate acquisitionLockTimeoutPerSec; | ||
| public final MetricNameTemplate inFlightMessageCount; | ||
| public final MetricNameTemplate inFlightBatchCount; | ||
| public final MetricNameTemplate inFlightBatchMessageCount; | ||
| public final MetricNameTemplate fetchLockTimeMs; | ||
| public final MetricNameTemplate fetchLockRatio; | ||
| public final MetricNameTemplate shareSessionEvictionsPerSec; | ||
| public final MetricNameTemplate sharePartitionsCount; | ||
| public final MetricNameTemplate shareSessionsCount; | ||
| public final MetricNameTemplate delayedShareFetchExpiresPerSec; | ||
| public final MetricNameTemplate shareFetchPurgatorySize; | ||
| public final MetricNameTemplate shareFetchNumDelayedOperations; | ||
|
|
||
| public ShareGroupMetricsRegistry() { | ||
| this(new HashSet<>(), ""); | ||
| } | ||
|
|
||
| public ShareGroupMetricsRegistry(Set<String> tags, String metricGrpPrefix) { | ||
|
|
||
| /* BrokerTopicMetrics */ | ||
| String brokerTopicGroupName = "BrokerTopicMetrics"; | ||
| Set<String> topicTags = Set.of("topic"); | ||
|
|
||
| this.totalShareFetchRequestsPerSec = new MetricNameTemplate("TotalShareFetchRequestsPerSec", brokerTopicGroupName, | ||
| "The fetch request rate per second. ", topicTags); | ||
|
|
||
| this.failedShareFetchRequestsPerSec = new MetricNameTemplate("FailedShareFetchRequestsPerSec", brokerTopicGroupName, | ||
| "The share fetch request rate for requests that failed. ", topicTags); | ||
|
|
||
| this.totalShareAcknowledgementRequestsPerSec = new MetricNameTemplate("TotalShareAcknowledgementRequestsPerSec", brokerTopicGroupName, | ||
| "The acknowledgement request rate per second. ", topicTags); | ||
|
|
||
| this.failedShareAcknowledgementRequestsPerSec = new MetricNameTemplate("FailedShareAcknowledgementRequestsPerSec", brokerTopicGroupName, | ||
| "The share acknowledgement request rate for requests that failed. ", topicTags); | ||
|
|
||
| /* Group Coordinator metrics */ | ||
| Set<String> state = Set.of("state"); | ||
| this.shareGroupCount = new MetricNameTemplate("share-group-count", "GroupCoordinator", | ||
| "The number of share groups in respective state.", state); | ||
|
|
||
| /* Share Coordinator metrics */ | ||
| String shareCoordinatorMetrics = "share-coordinator-metrics"; | ||
| this.writeRate = new MetricNameTemplate("write-rate", shareCoordinatorMetrics, | ||
| "The number of share-group state write calls per second.", tags); | ||
|
|
||
| this.writeTotal = new MetricNameTemplate("write-total", shareCoordinatorMetrics, | ||
| "The total number of share-group state write calls.", tags); | ||
|
|
||
| this.writeLatencyAvg = new MetricNameTemplate("write-latency-avg", shareCoordinatorMetrics, | ||
| "The average time taken for a share-group state write call, including the time to write to the share-group state topic.", tags); | ||
|
|
||
| this.writeLatencyMax = new MetricNameTemplate("write-latency-max", shareCoordinatorMetrics, | ||
| "The maximum time taken for a share-group state write call, including the time to write to the share-group state topic.", tags); | ||
|
|
||
| Set<String> topicPartitionTags = Set.of("topic", "partition"); | ||
| this.lastPrunedOffset = new MetricNameTemplate("last-pruned-offset", shareCoordinatorMetrics, | ||
| "The last pruned offset in the share-group state topic.", topicPartitionTags); | ||
|
|
||
| /* ShareGroupMetrics */ | ||
| String shareGroupMetricsName = metricGrpPrefix + "ShareGroupMetrics"; | ||
| Set<String> ackTypeTags = Set.of("ackType"); | ||
|
|
||
| this.recordAcknowledgementsPerSec = new MetricNameTemplate("RecordAcknowledgementsPerSec", shareGroupMetricsName, | ||
| "The rate per second of records acknowledged per acknowledgement type.", ackTypeTags); | ||
|
|
||
| this.partitionLoadTimeMs = new MetricNameTemplate("PartitionLoadTimeMs", shareGroupMetricsName, | ||
| "The time taken to load the share partitions.", tags); | ||
| Set<String> groupTags = Set.of("group"); | ||
|
|
||
| this.requestTopicPartitionsFetchRatio = new MetricNameTemplate("RequestTopicPartitionsFetchRatio", shareGroupMetricsName, | ||
| "The ratio of topic-partitions acquired to the total number of topic-partitions in share fetch request.", groupTags); | ||
|
|
||
| this.topicPartitionsAcquireTimeMs = new MetricNameTemplate("TopicPartitionsAcquireTimeMs", shareGroupMetricsName, | ||
| "The time elapsed (in millisecond) to acquire any topic partition for fetch.", groupTags); | ||
|
|
||
| /* SharePartitionMetrics - Partition level */ | ||
| String sharePartitionMetricsName = "SharePartitionMetrics"; | ||
| Set<String> partitionTags = Set.of("group", "topic", "partition"); | ||
|
|
||
| this.acquisitionLockTimeoutPerSec = new MetricNameTemplate("AcquisitionLockTimeoutPerSec", sharePartitionMetricsName, | ||
| "The rate of acquisition locks for records which are not acknowledged within the timeout.", partitionTags); | ||
|
|
||
| this.inFlightMessageCount = new MetricNameTemplate("InFlightMessageCount", sharePartitionMetricsName, | ||
| "The number of in-flight messages for the share partition.", partitionTags); | ||
|
|
||
| this.inFlightBatchCount = new MetricNameTemplate("InFlightBatchCount", sharePartitionMetricsName, | ||
| "The number of in-flight batches for the share partition.", partitionTags); | ||
|
|
||
| this.inFlightBatchMessageCount = new MetricNameTemplate("InFlightBatchMessageCount", sharePartitionMetricsName, | ||
| "The number of messages in the in-flight batch.", partitionTags); | ||
|
|
||
| this.fetchLockTimeMs = new MetricNameTemplate("FetchLockTimeMs", sharePartitionMetricsName, | ||
| "The time elapsed (in milliseconds) while a share partition is held under lock for fetching messages.", partitionTags); | ||
|
|
||
| this.fetchLockRatio = new MetricNameTemplate("FetchLockRatio", sharePartitionMetricsName, | ||
| "The fraction of time share partition is held under lock.", partitionTags); | ||
|
|
||
| /* ShareSessionCache metrics */ | ||
| String shareSessionCacheName = "ShareSessionCache"; | ||
| this.shareSessionEvictionsPerSec = new MetricNameTemplate("ShareSessionEvictionsPerSec", shareSessionCacheName, | ||
| "The share session eviction rate per second.", tags); | ||
|
|
||
| this.sharePartitionsCount = new MetricNameTemplate("SharePartitionsCount", shareSessionCacheName, | ||
| "The number of cached share partitions.", tags); | ||
|
|
||
| this.shareSessionsCount = new MetricNameTemplate("ShareSessionsCount", shareSessionCacheName, | ||
| "The number of cached share sessions.", tags); | ||
|
|
||
| /* DelayedShareFetchMetrics */ | ||
| String delayedShareFetchMetricsName = "DelayedShareFetchMetrics"; | ||
| this.delayedShareFetchExpiresPerSec = new MetricNameTemplate("ExpiresPerSec", delayedShareFetchMetricsName, | ||
| "The expired delayed share fetch operation rate per second.", tags); | ||
|
|
||
| /* DelayedOperationPurgatory metrics */ | ||
| String delayedOperationPurgatoryName = "DelayedOperationPurgatory"; | ||
| Set<String> shareFetchTags = new LinkedHashSet<>(tags); | ||
| shareFetchTags.add("delayedOperation"); | ||
|
|
||
| this.shareFetchPurgatorySize = new MetricNameTemplate("PurgatorySize", delayedOperationPurgatoryName, | ||
| "The number of requests waiting in the share fetch purgatory. This is high if share consumers use a large value for fetch.wait.max.ms", shareFetchTags); | ||
|
|
||
| this.shareFetchNumDelayedOperations = new MetricNameTemplate("NumDelayedOperations", delayedOperationPurgatoryName, | ||
| "The number of delayed operations for share fetch purgatory.", shareFetchTags); | ||
| } | ||
|
|
||
| public List<MetricNameTemplate> getAllTemplates() { | ||
| return Arrays.asList( | ||
| shareGroupCount, | ||
| writeRate, | ||
| writeTotal, | ||
| writeLatencyAvg, | ||
| writeLatencyMax, | ||
| totalShareFetchRequestsPerSec, | ||
| failedShareFetchRequestsPerSec, | ||
| totalShareAcknowledgementRequestsPerSec, | ||
| failedShareAcknowledgementRequestsPerSec, | ||
| recordAcknowledgementsPerSec, | ||
| partitionLoadTimeMs, | ||
| requestTopicPartitionsFetchRatio, | ||
| topicPartitionsAcquireTimeMs, | ||
| acquisitionLockTimeoutPerSec, | ||
| inFlightMessageCount, | ||
| inFlightBatchCount, | ||
| inFlightBatchMessageCount, | ||
| fetchLockTimeMs, | ||
| fetchLockRatio, | ||
| shareSessionEvictionsPerSec, | ||
| sharePartitionsCount, | ||
| shareSessionsCount, | ||
| delayedShareFetchExpiresPerSec, | ||
| shareFetchPurgatorySize, | ||
| shareFetchNumDelayedOperations | ||
| ); | ||
| } | ||
|
|
||
| public static void main(String[] args) { | ||
| ShareGroupMetricsRegistry metrics = new ShareGroupMetricsRegistry(); | ||
| System.out.println(Metrics.toHtmlTable("kafka.server", metrics.getAllTemplates())); | ||
| } | ||
| } | ||
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.
Not quite sure if we need to show the
DelayedOperationPurgatorymetrics in the documentation, as it doesn't only apply to share group.