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

[yugabyte/yugabyte-db#26069] Custom metrics implementation for multi task model #165

Merged
merged 5 commits into from
Feb 24, 2025

Conversation

vaibhav-yb
Copy link
Collaborator

@vaibhav-yb vaibhav-yb commented Oct 28, 2024

Problem

Currently, the connector follows a single task single partition model and thus uses the DefaultChangeEventSourceMetricsFactory which doesn't let us override the metric object names. Since we cannot override names, this causes an issue when we go for the multi task model as there's a conflict in the metric object names if a task registers its metric objects and subsequent tasks try to register their metric objects too.

Solution

This is resolved by adding a custom metrics implementation which lets us customise things accordingly for a multi task model. This is done by following the example of metrics implemented by SqlServerConnector at https://github.com/yugabyte/debezium/tree/2.5.2.Final/debezium-connector-sqlserver/src/main/java/io/debezium/connector/sqlserver/metrics

This closes yugabyte/yugabyte-db#26069

@vaibhav-yb vaibhav-yb self-assigned this Oct 28, 2024
@@ -1086,13 +1086,6 @@ public static AutoCreateMode parse(String value, String defaultValue) {
public static final Field SOURCE_INFO_STRUCT_MAKER = CommonConnectorConfig.SOURCE_INFO_STRUCT_MAKER
.withDefault(PostgresSourceInfoStructMaker.class.getName());

public static final Field TASK_ID = Field.create("task.id")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was removed since we already have a task.id field in the CommonConnectorConfig of type STRING - we are now reusing the same config.

@@ -123,9 +124,10 @@ public ChangeEventSourceCoordinator<PostgresPartition, PostgresOffsetContext> st
final PostgresValueConverter valueConverter = valueConverterBuilder.build(typeRegistry);

schema = new PostgresSchema(connectorConfig, defaultValueConverter, topicNamingStrategy, valueConverter);
this.taskContext = new PostgresTaskContext(connectorConfig, schema, topicNamingStrategy, connectorConfig.taskId());
this.taskContext = new PostgresTaskContext(connectorConfig, schema, topicNamingStrategy, connectorConfig.getTaskId());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This change is simply to use the existing method to get the task ID.

@@ -21,9 +21,9 @@ public class PostgresPartition extends AbstractPartition implements Partition {
private static final String SERVER_PARTITION_KEY = "server";

private final String serverName;
private final int taskId;
private final String taskId;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Task ID was added in #163 as an integer but since we are reusing the existing one in CommonConnectorConfig, keeping it as String would simplify things as we will not need unnecessary type casts.

@vaibhav-yb vaibhav-yb changed the title [WIP] Custom metrics implementation [yugabyte/yugabyte-db#26069] Custom metrics implementation Feb 17, 2025
@vaibhav-yb vaibhav-yb changed the title [yugabyte/yugabyte-db#26069] Custom metrics implementation [yugabyte/yugabyte-db#26069] Custom metrics implementation for multi task model Feb 17, 2025
@suranjan suranjan self-requested a review February 17, 2025 11:28
@vaibhav-yb vaibhav-yb merged commit 615451f into ybdb-debezium-2.5.2 Feb 24, 2025
1 check passed
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.

[DBZ-PGYB] Implement metrics for multi task model
3 participants