Giter Site home page Giter Site logo

Comments (9)

arkaitzgarro avatar arkaitzgarro commented on July 20, 2024

It was introduced by @cykirsch some time ago, because at that point we were missing transactions for jobs. But now that you mentioned it, it might be the case that we don't need it anymore. @cykirsch thoughts? Can it be removed, or are we missing something?

from elastic-apm-laravel.

cykirsch avatar cykirsch commented on July 20, 2024

It's only to record a span closer to the actual processing of the job, really the only benefit (if any) is that closeness. I agree it could be pulled out, and now would be the time while bumping the major version.

If someone wants that behavior, it's easily reproducible manually via the facade.

from elastic-apm-laravel.

arkaitzgarro avatar arkaitzgarro commented on July 20, 2024

I see it now. There's an extra span in the transaction but only if the jobs are synchronous of course. It might be worth keeping it then, it shows at which point the job was executed in the context of the transaction.

Screenshot 2020-10-14 at 09 27 13

from elastic-apm-laravel.

dstepe avatar dstepe commented on July 20, 2024

At a minimum, the documentation should be updated to make the use case clear.

However, I'm running into trouble reproducing your results in a reference app I've built for functional testing. When I use the dispatchNow() method of a job, the job middleware is not called at all. The middleware is only used when run with the queue worker. How are you creating the sync job? I'm using Laravel 7.28.x at the moment.

from elastic-apm-laravel.

cykirsch avatar cykirsch commented on July 20, 2024

from elastic-apm-laravel.

dstepe avatar dstepe commented on July 20, 2024

That makes sense, but is a very different use case. I know I have one real-world situation in which we make a runtime decision between dispatch() and dispatchNow() based on a condition. But this helps explain the behavior. I'll confirm it shortly. If this is the case, we can update the docs and provide some suggestions on how to handle these cases.

from elastic-apm-laravel.

dstepe avatar dstepe commented on July 20, 2024

A quick test supports this hypothesis. The middleware is called if the queue connection is sync, which implies the middleware is always called for jobs created with dispatch(). The middleware is not called for jobs created with dispatchNow().

As an application author, I'm not sure I would expect that difference in behavior related to APM. We can document it, but we can't provide a solution. The only way to get APM data for a job created with dispatchNow() would be to use the facade and do it yourself.

Suggestions on how to proceed?

from elastic-apm-laravel.

cykirsch avatar cykirsch commented on July 20, 2024

from elastic-apm-laravel.

dstepe avatar dstepe commented on July 20, 2024

Understood. I'm leaning toward simply updating the documentation state that jobs created with dispatchNow() will not have the middleware run, though any explicitly created measures with the job will still be recorded. Then app developers can decide how they want to proceed.

from elastic-apm-laravel.

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.