[ISSUE#173]Connect Exporter for Prometheus - #200
Conversation
|
|
||
|
|
||
| public class MetricsExportSinkTask extends SinkTask { | ||
| private List<MetricsExporter> metricsExporters; |
There was a problem hiding this comment.
Has the implementation of MetricsExporter been submitted yet?
There was a problem hiding this comment.
Sorry not yet :( . But I am trying my best to finish a exporter for Prometheus which gets the metrics from the log files, and some preliminary knowledge is got. And I hear the sftp source connector (my upstream task) is designing in the last weekly meeting. So I'm waiting for the implementation ConnectRecord in it in order to complete my parsing.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR modifies 6 file(s) with 198 lines of diff. No test changes detected — consider adding test coverage.
Automated review by github-manager-bot
| @@ -0,0 +1,41 @@ | |||
| package org.apache.rocket.connect.metrics.export.sink.connector; | |||
There was a problem hiding this comment.
No test changes detected alongside source modifications. Consider adding tests to cover the changes.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR introduces the interface scaffolding for a Prometheus metrics exporter connector for RocketMQ Connect. It defines the MetricsExporter SPI interface, a SinkConnector/SinkTask pair that delegates to discovered exporters via ServiceLoader, and a utility class for service discovery.
The design is sound (SPI-based extensibility), but the implementation has several issues that need attention before this can be merged:
- Critical: The SPI service file is empty and has a truncated filename, so no implementations will be discovered at runtime
- Warnings: Class name typo, instance initializer ordering, and missing null safety
Additionally, this PR only adds interfaces — there is no actual Prometheus exporter implementation included. Is this intentional (to be followed by another PR), or should the implementation be part of this PR?
Note: This PR has been open since July 2022. If it is still actively being worked on, please address the above issues. If it has been abandoned, consider closing it.
Automated review by "github-manager-bot"
Additional notes (not anchored to a changed line)
- [CRITICAL]
connectors/rocketmq-connect-metrics-exporter/src/main/resources/META-INF/service/org.apache.rocket.connect.metrics.export.sink.connector.MetricsExport:1— This SPI service file is empty and has a truncated filename (should end with MetricsExporter, not MetricsExport). Without a valid SPI entry, ServiceLoader will find no implementations. (line outside diff)
|
|
||
| /** | ||
| * @author: ming | ||
| */ |
There was a problem hiding this comment.
Typo in class name: ServiceProvicerUtil should be ServiceProviderUtil (missing d in Provider).
|
|
||
| private List<MetricsExporter> metricsExporters; | ||
| { | ||
| metricsExporters = ServiceProvicerUtil.getMetricsExporterServices(); |
There was a problem hiding this comment.
Instance initializer block runs at construction time, before start(). Consider moving ServiceLoader initialization to start() to avoid potential classpath issues.
| private List<MetricsExporter> metricsExporters; | ||
|
|
||
| @Override public void put(List<ConnectRecord> sinkRecords) throws ConnectException { | ||
| for (MetricsExporter exporter : metricsExporters) { |
There was a problem hiding this comment.
metricsExporters is initialized in init() but used in put() without null check. If put() is somehow called before init(), this will NPE. Consider adding a null guard or lazy initialization.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
PR received and logged for review. This PR requires detailed code review by a maintainer.
Diff size: 198 lines
Author: yhx-coder (CONTRIBUTOR)
Automated review by RockteMQ-AI
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Review of PR #200: [ISSUE#173]Connect Exporter for Prometheus
Findings: 8 issue(s) identified (1 critical).
CLA: unknown
Please address the inline comments above.
Automated review by github-manager-bot
Additional notes (not anchored to a changed line)
- [CRITICAL]
connectors/rocketmq-connect-metrics-exporter/src/main/resources/META-INF/service/org.apache.rocket.connect.metrics.export.sink.connector.MetricsExport— SPI service file has two fatal errors: (1) directory must be META-INF/services/ (plural), not META-INF/service/; (2) filename must be the fully-qualified interface name 'org.apache.rocket.connect.metrics.export.sink.connector.MetricsExporter' (missing trailing 'r'). Additionally the file is empty — no implementation classes are registered. ServiceLoader.load(MetricsExporter.class) will find zero implementations, making the entire connector a silent no-op. (missing file/line/body)
| private List<MetricsExporter> metricsExporters; | ||
| { | ||
| metricsExporters = ServiceProvicerUtil.getMetricsExporterServices(); | ||
| } |
There was a problem hiding this comment.
metricsExporters is loaded in an instance initializer block but never closed/stopped in stop(). If exporters hold resources (e.g., HTTP clients, thread pools for Prometheus scraping), they will leak because the connector's stop() only nulls out config. Consider iterating metricsExporters in stop() and calling stop() on each, or documenting that lifecycle is fully managed by the task.
| private List<MetricsExporter> metricsExporters; | ||
|
|
||
| @Override public void put(List<ConnectRecord> sinkRecords) throws ConnectException { | ||
| for (MetricsExporter exporter : metricsExporters) { |
There was a problem hiding this comment.
In put(), if one exporter throws an exception, all subsequent exporters in the loop are skipped and the entire batch is lost. For a multi-exporter setup this means one faulty exporter blocks all others. Consider catching per-exporter, logging, and continuing — or aggregating exceptions before rethrowing.
| private List<MetricsExporter> metricsExporters; | ||
|
|
||
| @Override public void put(List<ConnectRecord> sinkRecords) throws ConnectException { | ||
| for (MetricsExporter exporter : metricsExporters) { |
There was a problem hiding this comment.
If metricsExporters is empty (which it will be given the broken SPI file), put() silently discards all incoming ConnectRecords with no log or error. A warning or exception when the list is empty during start() or init() would prevent silent data loss.
| * @author: ming | ||
| */ | ||
| public class ServiceProvicerUtil { | ||
|
|
There was a problem hiding this comment.
Class name 'ServiceProvicerUtil' contains a typo — should be 'ServiceProviderUtil'. This is a public API surface; fixing it later would be a breaking change.
| List<KeyValue> configs = new ArrayList<>(); | ||
| configs.add(config); | ||
| return configs; | ||
| } |
There was a problem hiding this comment.
taskConfigs(int maxTasks) always returns a single-element list regardless of maxTasks. If the framework distributes work across multiple tasks for parallelism, this silently caps it at one. Either honor maxTasks or explicitly document that this connector supports only a single task.
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
There was a problem hiding this comment.
pom.xml has no parent POM and uses a standalone hardcoded version '1.0-SNAPSHOT' with a standalone groupId. Other connector modules in this repo likely inherit from a parent POM for consistent dependency management. This may cause version drift and build inconsistency.
| @@ -0,0 +1,47 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
There was a problem hiding this comment.
No test files are included in this PR. There is no unit or integration test coverage for the connector, task, or SPI loading logic — critical paths like put(), start()/stop() lifecycle, and validate() are completely untested.
ISSUE#173 What is the purpose of the change
Some simple interfaces designed for metric exposure.
Brief changelog
Design some interfaces to ensure exposure behavior of metrics provided by dynamic loading.Thus,we can export the metrics to anywhere we want, e.g. prometheus.