Git Product home page Git Product logo

Comments (3)

petercheon avatar petercheon commented on July 19, 2024 2

@jonatan-ivanov

Thank you for your feedback.
As you mentioned, I used LazyTraceExecutor as you suggested, but I still confirmed that the span is not propagated.
I have verified that the span is propagated correctly when not using parallel().

    @Bean(name = "peterPool")
    @Lazy
    public Executor getCustomForkJoinPool(Tracer tracer) {
        final ForkJoinPool.ForkJoinWorkerThreadFactory factory = pool -> {
            final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
            worker.setName("peterPool" + worker.getPoolIndex());
            return worker;
        };

        return new LazyTraceExecutor(beanFactory,
                new ForkJoinPool(Runtime.getRuntime().availableProcessors(), factory, null, true));
    }
    private final Executor peterPool;

    @GetMapping("/test")
    public String test() throws ExecutionException, InterruptedException {
        peterPool.execute(() -> {
            IntStream.range(1, 20).parallel().map(idx -> {
                httpClient.get(1000L);
                return idx;
            }).sum();
        });

        return "test";
    }

Thank you

from spring-cloud-sleuth.

jonatan-ivanov avatar jonatan-ivanov commented on July 19, 2024 1

Have you tried LazyTraceExecutor?

from spring-cloud-sleuth.

jonatan-ivanov avatar jonatan-ivanov commented on July 19, 2024

Your example does not use LazyTraceExecutor. You create a bean of it but the parallel stream does not use it. I checked a few things and I don't see the way using an executor/completion service in parallel streams. So I guess the solution is you need to instrument it on your own (basically what LazyTraceExecutor) does.

from spring-cloud-sleuth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.