GithubHelp home page GithubHelp logo

opentracing-contrib / java-concurrent Goto Github PK

View Code? Open in Web Editor NEW
38.0 8.0 19.0 91 KB

OpenTracing-aware helpers related to java.util.concurrent

License: Apache License 2.0

Java 84.77% Shell 15.23%
opentracing tracing concurrent-programming executorservice runnable callable

java-concurrent's Introduction

Build Status Released Version

OpenTracing instrumentation for java.util.concurrent

OpenTracing instrumentation for java.util.concurrent package. It instruments ExecutorService, Executor, Runnable and Callable.

Configuration

ExecutorService executorService = new TracedExecutorService(Executors.newFixedThreadPool(4), tracer);

Development

./mvnw clean install

Release

Follow instructions in RELEASE

java-concurrent's People

Contributors

bhs avatar jam01 avatar malafeev avatar objectiser avatar pavolloffay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-concurrent's Issues

ClassCastException with Slick

I am using OpenTracing Special Agent with Play and Slick. If I include the "concurrent" rule, I get the following error with Slick.

[error] ErrorHandler - class io.opentracing.contrib.specialagent.rule.concurrent.TracedRunnable cannot be cast to class slick.util.AsyncExecutor$PrioritizedRunnable (io.opentracing.contrib.specialagent.rule.concurrent.TracedRunnable is in unnamed module of loader 'bootstrap'; slick.util.AsyncExecutor$PrioritizedRunnable is in unnamed module of loader play.runsupport.NamedURLClassLoader @70355caa)
java.lang.ClassCastException: class io.opentracing.contrib.specialagent.rule.concurrent.TracedRunnable cannot be cast to class slick.util.AsyncExecutor$PrioritizedRunnable (io.opentracing.contrib.specialagent.rule.concurrent.TracedRunnable is in unnamed module of loader 'bootstrap'; slick.util.AsyncExecutor$PrioritizedRunnable is in unnamed module of loader play.runsupport.NamedURLClassLoader @70355caa)
	at slick.util.ManagedArrayBlockingQueue.offer(ManagedArrayBlockingQueue.scala:17)
	at java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1347)
	at slick.util.AsyncExecutor$$anon$1$$anon$4.execute(AsyncExecutor.scala:163)
	at slick.basic.BasicBackend$DatabaseDef.runSynchronousDatabaseAction(BasicBackend.scala:265)
	at slick.basic.BasicBackend$DatabaseDef.runSynchronousDatabaseAction$(BasicBackend.scala:263)

Looks like it is trying to instrument something it shouldn't. If this issue should be part of the Special Agent instead, please let me know.

If I don't include the concurrent plugin, there are no errors. But then the tracer is not propagated properly.

The trace context does not propagate to the callback of ThreadPoolTaskExecutor/Scheduler

TracedThreadPoolTaskExecutor tracedExecutor = new TracedThreadPoolTaskExecutor(myExecutor, GlobalTracer.get());
try (Scope scope = GlobalTracer.activateSpan(span)) {
    ListenableFuture<?> future = tracedExecutor.submitListenable(() -> {
        Thread.sleep(1000); // Let callback run in other thread
        System.out.println(GlobalTracer.get().activeSpan()); // It's OK
    });
    future.addCallback(
        r -> System.out.println(GlobalTracer.get().activeSpan()), // Context loss!
        e -> {}
    );
}

It's confusing me, the context (activeSpan) is loss in the callback while the main task can get it correctly.

Create new span if paren span is missing

This library currently, only passes active span from parent thread to submitted runnable/callable. If there is no parent span it does nothing.

We should consider creating a new span if there is no parent span.

ongoing span relationships with jobs that repeat jobs

It seems questionable to propagate the parent span to jobs (callables and runnables) that repeat forever. This leads to traces that never close.

I have a use case where a first-access causes a scheduled job to be created 'scheduleAtFixedRate' or 'scheduleWithFixedDelay'. This is a repeated job, as such, it should not be associated with the parent span that initially caused it to be scheduled.

This behavior is in the TracedScheduledExecutorService class. I would suggest that inclusion of the these 'rules' be opt-in, not by default.

I'm curious what the use case is of associating a repeating job with a parent span, as I can't think of one immediately...

Additional documentation

The readme says this package instruments ExecutorService, Executor, Runnable, and Callable, but it only gives an example for ExecutorService. Is the only entry point ExecutorService? Or is there something you would do to directly instrument Executor, Runnable, and Callable?

Also, I'm wondering how these calls will be show up when looking at the trace. E.g. Parseq tracing does a really good job at showing you the line number and method where each span occurred. Does this package have any ability to appropriately name each span automatically or to allow the user to create their own name for each span? It would be really helpful to see what a trace using this package looks like

How to pass parent context with TracedExecutor Service

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.