Skip to content

Commit

Permalink
Optimize TracingProperties (#2438)
Browse files Browse the repository at this point in the history
* optimize TracingProperties

* optimize ElasticJobTracingConfiguration

* fix the code formatting issues

---------

Co-authored-by: cheyx <[email protected]>
  • Loading branch information
ooooooook and cheyx authored Sep 29, 2024
1 parent 70594c4 commit a7e56f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.shardingsphere.elasticjob.kernel.tracing.config.TracingConfiguration;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand Down Expand Up @@ -68,9 +67,11 @@ public DataSource tracingDataSource(final TracingProperties tracingProperties) {
* @return a bean of tracing configuration
*/
@Bean
@ConditionalOnBean(DataSource.class)
public TracingConfiguration<DataSource> tracingConfiguration(@Qualifier("dataSource") final DataSource dataSource,
public TracingConfiguration<DataSource> tracingConfiguration(@Qualifier("dataSource") @Nullable final DataSource dataSource,
@Qualifier("tracingDataSource") @Nullable final DataSource tracingDataSource) {
if (dataSource == null && tracingDataSource == null) {
throw new IllegalArgumentException("Neither dataSource nor tracingDataSource bean is required");
}
return new TracingConfiguration<>("RDB", null == tracingDataSource ? dataSource : tracingDataSource);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import lombok.Setter;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

import java.util.HashSet;
import java.util.Set;
Expand All @@ -32,6 +33,7 @@ public class TracingProperties {

private String type;

@NestedConfigurationProperty
private DataSourceProperties dataSource;

private Set<String> includeJobNames = new HashSet<>();
Expand Down

0 comments on commit a7e56f9

Please sign in to comment.