Skip to content

feat: cdc metrics#518

Merged
venikkin merged 24 commits intomainfrom
cdc-metrics-native
Feb 28, 2026
Merged

feat: cdc metrics#518
venikkin merged 24 commits intomainfrom
cdc-metrics-native

Conversation

@venikkin
Copy link
Contributor

@venikkin venikkin commented Feb 24, 2026

Problem

We need to report custom connector metrics to track a lag between the last processed by the CDC task transaction id and the last transaction id in the database.

Solution

Metrics export destination

The New Plugin Metrics API was introduced only with Kafka 4.1.

The new API will rely on metric.reporters to define a destination for metrics, which can be JMX or other monitoring solutions like DataDog, Prometheus, etc.

However, Kafka Connect 4.0+ is not compatible with JVM 11. Thus, we can only include it into next major release.

For 3.x Kafka Connect, I've implemented a JMX metrics integration. It emulated how metrics are exported to JMX via Plugin Metrics to be forward compatible. As a limitation, it will only work in the use cases, when customers have remote access to the Connect server and won't work with cloud integrations and customer reporters.

Last transaction id committed to a database.

The solution suggested here is a cache with a fixed interval, that is updated via a SHOW DATABASE .. query.

As a side effect in the cases of fast source connect polling and a low number of transactions, the last db transaction id may fall behind CDC processed transaction id for a time < refreshPeriod.

Testing

So far tested localy:
image

# Conflicts:
#	sink/src/main/kotlin/org/neo4j/connectors/kafka/sink/SinkStrategy.kt
#	sink/src/main/kotlin/org/neo4j/connectors/kafka/sink/strategy/cdc/CdcSchemaEventTransformer.kt
#	sink/src/main/kotlin/org/neo4j/connectors/kafka/sink/strategy/cdc/CdcSourceIdEventTransformer.kt
#	sink/src/main/kotlin/org/neo4j/connectors/kafka/sink/strategy/cdc/apoc/ApocCdcHandler.kt
#	sink/src/test/kotlin/org/neo4j/connectors/kafka/sink/SinkConfigurationTest.kt
#	sink/src/test/kotlin/org/neo4j/connectors/kafka/sink/strategy/cdc/CdcSchemaHandlerIT.kt
#	sink/src/test/kotlin/org/neo4j/connectors/kafka/sink/strategy/cdc/CdcSourceIdHandlerIT.kt
#	sink/src/test/kotlin/org/neo4j/connectors/kafka/sink/strategy/cdc/apoc/ApocCdcSchemaHandlerTest.kt
#	sink/src/test/kotlin/org/neo4j/connectors/kafka/sink/strategy/cdc/apoc/ApocCdcSourceIdHandlerTest.kt
#	sink/src/test/kotlin/org/neo4j/connectors/kafka/sink/strategy/cdc/batch/BatchedCdcSchemaHandlerTaskIT.kt
#	sink/src/test/kotlin/org/neo4j/connectors/kafka/sink/strategy/cdc/batch/BatchedCdcSourceIdHandlerTaskIT.kt
@venikkin venikkin marked this pull request as ready for review February 26, 2026 11:11
@venikkin venikkin requested a review from a team as a code owner February 26, 2026 11:11
Copy link
Contributor

@ali-ince ali-ince left a comment

Choose a reason for hiding this comment

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

Looks good, had a few change suggestions.

* update descriptions
* update property keys
* exception handling for last db tx is metric
@venikkin venikkin requested a review from ali-ince February 27, 2026 12:11
Copy link
Contributor

@ali-ince ali-ince left a comment

Choose a reason for hiding this comment

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

I only have a couple of very minor change suggestions.

@venikkin venikkin enabled auto-merge (squash) February 27, 2026 16:52
@venikkin venikkin merged commit e0cb9e6 into main Feb 28, 2026
27 checks passed
@venikkin venikkin deleted the cdc-metrics-native branch February 28, 2026 19:13
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.

2 participants