Skip to content
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

chore: add comment to describe why we clamp down a measurement #223

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,20 @@ public ClusterLagCollector(final String clusterName,
}

public ClusterData collectClusterData() {
final boolean clientConnected = client.isConnected();
final boolean clientWasAlreadyConnected = client.isConnected();
final long startMs = System.currentTimeMillis();
final Set<String> allConsumerGroupIds = client.consumerGroupIds(consumerGroupFilter);
final Map<TopicPartition, List<ConsumerGroupOffset>> groupOffsets = findConsumerGroupOffsets(allConsumerGroupIds);
final Map<TopicPartition, TopicPartitionData> topicPartitionData = findTopicPartitionData(groupOffsets.keySet());
final Map<TopicPartitionData, List<ConsumerGroupData>> topicAndConsumerData = calculateLag(groupOffsets, topicPartitionData);
final long pollTimeMs;
if (clientConnected) {
if (clientWasAlreadyConnected) {
pollTimeMs = System.currentTimeMillis() - startMs;
} else {
/* The first cluster data collection after connecting takes an order of magnitude longer
* than the runs that come after. If we publish this metric, graphs in Prometheus will
* be scaled to a range that makes it impossible to see variations in the actual
* collection times. Thus, clamp it down. */
pollTimeMs = -1;
}
final ClusterData clusterData = new ClusterData(clusterName, topicAndConsumerData, pollTimeMs);
Expand Down