Skip to content

[INLONG-7567][Sort] Extract metrics as common parameters#7568

Merged
healchow merged 3 commits intoapache:masterfrom
e-mhui:INLONG-7567
Mar 13, 2023
Merged

[INLONG-7567][Sort] Extract metrics as common parameters#7568
healchow merged 3 commits intoapache:masterfrom
e-mhui:INLONG-7567

Conversation

@e-mhui
Copy link
Contributor

@e-mhui e-mhui commented Mar 11, 2023

Prepare a Pull Request

Extract metrics as common parameters

Motivation

In order to better adapt to metrics from other CDCs, make metric parameters as common parameter. Other CDC's SourceConfig only need to implements MetricConfig.

Modifications

  1. Add the metricConfig interface
public interface MetricConfig extends Serializable {

    String getInlongMetric();

    String getInlongAudit();

}
  1. Put metric parameters inside BaseSourceConfig and implements MetricConfig.
public abstract class BaseSourceConfig implements SourceConfig, MetricConfig {

        /****/

    // --------------------------------------------------------------------------------------------
    // Metric Configurations
    // --------------------------------------------------------------------------------------------
    protected final String inlongMetric;
    protected final String inlongAudit;

        /****/

    @Override
    public String getInlongMetric() {
        return inlongMetric;
    }

    @Override
    public String getInlongAudit() {
        return inlongAudit;
    }

}
  1. In the method of registering metrics, use MetricConfig metricConfig = (MetricConfig) sourceConfig; to obtain metric parameters.
   @Override
    public IncrementalSourceReader<T, C> createReader(SourceReaderContext readerContext)
            throws Exception {
        // create source config for the given subtask (e.g. unique server id)
        C sourceConfig = configFactory.create(readerContext.getIndexOfSubtask());
        MetricConfig metricConfig = (MetricConfig) sourceConfig;
        /****/

        // create source config for the given subtask (e.g. unique server id)
        MetricOption metricOption = MetricOption.builder()
                .withInlongLabels(metricConfig.getInlongMetric())
                .withAuditAddress(metricConfig.getInlongAudit())
                .withRegisterMetric(RegisteredMetric.ALL)
                .build();

        sourceReaderMetrics.registerMetrics(metricOption);
        /****/
    }

@healchow healchow merged commit 3e96b03 into apache:master Mar 13, 2023
Yizhou-Yang pushed a commit to Yizhou-Yang/inlong-yyz that referenced this pull request May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improve][Sort] Extract metrics as common parameters

4 participants