Skip to content

Conversation

@songxiaosheng
Copy link
Member

Fixes #ISSUSE_ID.
fix #2237

Changes proposed in this pull request:

<dependency>
<groupId>org.apache.shardingsphere.elasticjob</groupId>
<artifactId>elasticjob-tracing-observability</artifactId>
<version>3.1.0-SNAPSHOT</version>
Copy link
Member

Choose a reason for hiding this comment

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

  • I recommend using ${project.version}.

Copy link
Member

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

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

  • Can you merge the maater branch to fix CI?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new metrics-based tracing system to ElasticJob, complementing the existing RDB tracing. It introduces a new observability module that collects job metrics and exposes them via Prometheus endpoints.

  • Adds new elasticjob-tracing-observability module with metrics collection capabilities
  • Introduces constants for tracing types to improve code maintainability
  • Adds job initialization tracking with new TASK_INIT state

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
ElasticJobTracingConfiguration.java Adds metrics tracing configuration support alongside existing RDB tracing
pom.xml (spring-boot-starter) Adds dependency on new observability module
JobScheduler.java Adds job executor initialization call
pom.xml (tracing) Includes new observability module in build
RDBTracingListenerConfiguration.java Updates to use TracingType constants
Multiple observability files New module implementing metrics collection with Prometheus integration
TracingType.java New constants class for tracing type strings
JobStatusTraceEvent.java Adds TASK_INIT state for job initialization tracking
ElasticJobExecutor.java Adds initialization method with status tracing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Bean
@ConditionalOnBean(DataSource.class)
@ConditionalOnProperty(name = "elasticjob.tracing.type", havingValue = "RDB")
@ConditionalOnProperty(name = "elasticjob.tracing.type", havingValue = RDB)
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

The havingValue attribute expects a String literal, but RDB is being used as a constant reference. This should be havingValue = \"RDB\" or use the string value from TracingType.RDB.

Copilot uses AI. Check for mistakes.
*/
@Bean
@ConditionalOnBean(MetricConfig.class)
@ConditionalOnProperty(name = "elasticjob.tracing.type", havingValue = TracingType.METRICS)
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

The havingValue attribute expects a String literal, but TracingType.METRICS is being used as a constant reference. This should be havingValue = \"METRICS\" or use the string value directly.

Suggested change
@ConditionalOnProperty(name = "elasticjob.tracing.type", havingValue = TracingType.METRICS)
@ConditionalOnProperty(name = "elasticjob.tracing.type", havingValue = "METRICS")

Copilot uses AI. Check for mistakes.


/**
* RDB tracing listener configuration.
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

The class comment incorrectly refers to 'RDB tracing listener configuration' when this is actually a metrics tracing listener configuration.

Suggested change
* RDB tracing listener configuration.
* Metrics tracing listener configuration.

Copilot uses AI. Check for mistakes.
jobMetrics = new JobMetrics();


//开启一个服务,用于暴露指标
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

Chinese comments should be replaced with English comments for consistency with the rest of the codebase. The comment should be: '// Start a service to expose metrics'.

Suggested change
//开启一个服务,用于暴露指标
// Start a service to expose metrics

Copilot uses AI. Check for mistakes.
os.write(response.getBytes());
}
});
//开启服务
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

Chinese comment should be replaced with English: '// Start the service'.

Suggested change
//开启服务
// Start the service

Copilot uses AI. Check for mistakes.
PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
composite.add(prometheusRegistry);

server = HttpServer.create(new InetSocketAddress(8081), 0);
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

The port 8081 is hardcoded, but the MetricConfig class has a metricsPort field. This should use metricConfig.getMetricsPort() instead of the hardcoded value.

Suggested change
server = HttpServer.create(new InetSocketAddress(8081), 0);
server = HttpServer.create(new InetSocketAddress(metricConfig.getMetricsPort()), 0);

Copilot uses AI. Check for mistakes.

server = HttpServer.create(new InetSocketAddress(8081), 0);

server.createContext("/metrics", httpExchange -> {
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

The metrics path '/metrics' is hardcoded, but the MetricConfig class has a metricsPath field. This should use metricConfig.getMetricsPath() instead of the hardcoded value.

Suggested change
server.createContext("/metrics", httpExchange -> {
server.createContext(metricConfig.getMetricsPath(), httpExchange -> {

Copilot uses AI. Check for mistakes.
}

/**
* Rigourous Test :-)
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

Spelling error: 'Rigourous' should be 'Rigorous'.

Suggested change
* Rigourous Test :-)
* Rigorous Test :-)

Copilot uses AI. Check for mistakes.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

JUnit version 3.8.1 is extremely outdated. Consider updating to a modern version like JUnit 5 or at least JUnit 4.13.2 for better testing capabilities and security updates.

Suggested change
<version>3.8.1</version>
<version>4.13.2</version>

Copilot uses AI. Check for mistakes.
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.

需求:Job接入普罗米修斯监控

2 participants