Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElasticJobConfiguration doesn't support tracing #2230

Open
zhangethan opened this issue Jun 12, 2023 · 1 comment
Open

ElasticJobConfiguration doesn't support tracing #2230

zhangethan opened this issue Jun 12, 2023 · 1 comment

Comments

@zhangethan
Copy link

zhangethan commented Jun 12, 2023

Bug Report

SpringBoot 2.3.12
elasticjob-lite-spring-boot-starter 3.0.3

When I setup a job by yaml, it can work properly and insert some tracing records.

elasticjob:
  reg-center:
    server-lists: localhost:2181
    namespace: test
  tracing:
    type: RDB
  jobs:
    testJob1:
      cron: "0/10 * * * * ?"
      elastic-job-class: org.example.Task1
      sharding-total-count: 1
      overwrite: true
      monitorExecution: true
@Slf4j
@Component
public class Task1 implements SimpleJob {

    @Override
    public void execute(ShardingContext shardingContext) {
        log.info("task1: {}", shardingContext);
    }
}

But we are upgrading elasticjob from 2.x to 3.x, and we have many jobs using @ElasticSimpleJob, so I'm going to replace @ElasticSimpleJob with @ElasticJobConfiguration, just like :

elasticjob:
  reg-center:
    server-lists: localhost:2181
    namespace: test
  tracing:
    type: RDB
@SpringBootApplication
@ElasticJobScan("org.example")
public class App1
{
    public static void main( String[] args )
    {
        SpringApplication.run(App1.class, args);
    }
}

@ElasticJobConfiguration(jobName = "testJob1", shardingTotalCount = 1,
        cron = "0/10 * * * * ?", overwrite = true)
@Slf4j
public class Task1 implements SimpleJob {

    @Override
    public void execute(ShardingContext shardingContext) {
        log.info("task1: {}", shardingContext);
    }
}

Expected behavior

The job can be scheduled properly and it can insert tracing records into RDB

Actual behavior

It can't insert tracing records.

Reason analyze (If you can)

It seems that the job created by @ElasticJobConfiguration isn't compatible with the global tracing configuration.

    //JobScheduler.findTracingConfiguration doesn't apply the global tracing configuration
    private Optional<TracingConfiguration<?>> findTracingConfiguration() {
        return this.jobConfig.getExtraConfigurations().stream().filter((each) -> {
            return each instanceof TracingConfiguration;
        }).findFirst().map((extraConfig) -> {
            return (TracingConfiguration)extraConfig;
        });
    }

Steps to reproduce the behavior.

Example codes for reproduce this issue (such as a github link).

@linghengqian
Copy link
Member

  • Would you like to file a PR on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants