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

[Streaming Telemetry 1] Prepares TopicPartitionChannel for telemetry #696

Merged
merged 28 commits into from
Sep 7, 2023

Conversation

sfc-gh-rcheng
Copy link
Collaborator

@sfc-gh-rcheng sfc-gh-rcheng commented Aug 30, 2023

  • Requires TelemetryService not null in TopicPartitionChannel
  • Adds offset setters in TopicPartitionChannel to update offset and SnowflakeTelemetryChannelStatus offsets at the same time
  • Moves JMX into new SnowflakeTelemetryChannelStatus

Changes coming in part 2 PR

  • SnowflakeTelemetryChannelStatus becomes a telemetry object
  • Enables reportKafkaPartitionStart/Usage telemetry

@@ -284,12 +291,6 @@ public TopicPartitionChannel(
+ " correct offset instead",
this.getChannelName());
}

if (enableCustomJMXMonitoring) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved into snowflakeTelemetryChannelStatus constructor

@@ -1095,10 +1127,9 @@ protected SnowflakeTelemetryService getTelemetryServiceV2() {
return this.telemetryServiceV2;
}

protected void setLatestConsumerOffset(long consumerOffset) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved up to the other offset setters

* @param metricsJmxReporter wrapper class for registering all metrics related to above connector
* and channel
*/
public void registerChannelJMXMetrics(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved into SnowflakeTelemetryChannelStatus

import com.snowflake.kafka.connector.internal.metrics.MetricsUtil;
import java.util.concurrent.atomic.AtomicLong;

public class SnowflakeTelemetryChannelStatus {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will extend SnowflakeTelemetryBasicInfo and become a proper telemetry object in the next PR

@@ -817,27 +835,52 @@ public void testBigAvroBufferBytesThreshold() throws Exception {
}

@Test
public void testRegisterJmxMetrics() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved into SnowflakeTelemetryChannelStatusTest

@sfc-gh-rcheng sfc-gh-rcheng marked this pull request as ready for review August 30, 2023 23:53
Copy link
Collaborator

@sfc-gh-japatel sfc-gh-japatel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall lgtm, couple of questions and one request to add a new test.

Copy link
Contributor

@sfc-gh-tzhang sfc-gh-tzhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments, PTAL, thanks!

// offsets
currentMetricRegistry.register(
constructMetricName(
this.channelName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not familiar with JMX, but can a channel name be uniquely identify a metric? What if we have two channels with the same name but different client sequencer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Channel names are meant to be unique identifiers for that particular topic and partition.

From what I understand, client sequencers are bumped up when a channel is reopened, which means the registry should replace the previous channel name's metrics. This should be ok behavior, wdyt?

Another potential issue is two connectors listening to the same topic, however this is not an issue because the MetricRegistry is created off the unique connector name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about during rebalance? Any concern about emit metrics from two nodes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be rebalance issues because JmxReporters are created at the serviceSink level. When registering new metrics for a TopicPartitionChannel during rebalance, we remove all existing metrics and then register new ones.

mockTelemetryService = Mockito.mock(SnowflakeTelemetryService.class);
Mockito.when(mockStreamingClient.isClosed()).thenReturn(false);
Mockito.when(mockStreamingClient.openChannel(ArgumentMatchers.any(OpenChannelRequest.class)))
.thenReturn(mockStreamingChannel);
Mockito.when(mockStreamingChannel.getFullyQualifiedName()).thenReturn(TEST_CHANNEL_NAME);
this.topicPartition = new TopicPartition(TOPIC, PARTITION);
this.sfConnectorConfig = TestUtils.getConfig();
this.streamingBufferThreshold = new StreamingBufferThreshold(10, 10_000, 1);
this.streamingBufferThreshold = new StreamingBufferThreshold(1, 10_000, 1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reduced the time flush to 1 second to replicate our recommended settings

Copy link
Contributor

@sfc-gh-tzhang sfc-gh-tzhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, ship it!

import com.snowflake.kafka.connector.internal.metrics.MetricsUtil;
import java.util.concurrent.atomic.AtomicLong;

public class SnowflakeTelemetryChannelStatus {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment about what this class is doing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be added in the next PR

// offsets
currentMetricRegistry.register(
constructMetricName(
this.channelName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about during rebalance? Any concern about emit metrics from two nodes?

@sfc-gh-rcheng sfc-gh-rcheng merged commit a87e8b5 into master Sep 7, 2023
@sfc-gh-rcheng sfc-gh-rcheng deleted the rcheng-sstelem-1 branch September 7, 2023 17:52
khsoneji pushed a commit to confluentinc/snowflake-kafka-connector that referenced this pull request Oct 12, 2023
khsoneji pushed a commit to confluentinc/snowflake-kafka-connector that referenced this pull request Oct 12, 2023
khsoneji pushed a commit to confluentinc/snowflake-kafka-connector that referenced this pull request Oct 12, 2023
khsoneji pushed a commit to confluentinc/snowflake-kafka-connector that referenced this pull request Oct 12, 2023
EduardHantig pushed a commit to streamkap-com/snowflake-kafka-connector that referenced this pull request Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants