Giter Site home page Giter Site logo

Comments (5)

dstepe avatar dstepe commented on July 20, 2024

This is really a concern for the APM Agent package which is used to send the events. I did look into making the send to APM an async call, but that's not a straightforward as I had thought it would be. See this old PR and the link to discussion on the Guzzle project about the need to implement an event loop for that to work.

My hope is that the official APM PHP Agent will bring some major improvements.

In the meantime, this package defers sending the collected event data to APM until after the response has been sent to the client. This at least prevents connection issues from impacting the application's response. Running from the CLI is different, of course.

You can mange the http client used by the agent, though, which would give you the ability to set a shorter timeout. For example, in your AppServiceProvider::register() method:

$this->app->bind(\AG\ElasticApmLaravelAgentBuilder::class, function () {
    $builder = new \AG\ElasticApmLaravelAgentBuilder();

    $builder->withHttpClient(new \Http\Adapter\Guzzle6\Client(new Client(['timeout' => 3.0])));

    return $builder;
});

from elastic-apm-laravel.

arkaitzgarro avatar arkaitzgarro commented on July 20, 2024

Even if we send requests after the response is sent to the client, indeed the request to APM is sync and blocking. We had an issue today were APM server was not responding properly, making our application unstable. @rogercbe did you try the solution proposed by @dstepe to override the http client?

from elastic-apm-laravel.

countless-integers avatar countless-integers commented on July 20, 2024

\AG\ElasticApmLaravelAgentBuilder

You meant \AG\ElasticApmLaravel\AgentBuilder, right @dstepe?

Ok, for completeness we came up with this:

$this->app->bind(\AG\ElasticApmLaravel\AgentBuilder::class, function () {
    return (new \AG\ElasticApmLaravel\AgentBuilder())
        ->withHttpClient(\Http\Adapter\Guzzle6\Client::createWithConfig(['timeout' => 3.0]));
});

from elastic-apm-laravel.

dstepe avatar dstepe commented on July 20, 2024

@countless-integers Yes, I'm sure that's what I meant. I can't explain where that \ went. Apologies.

from elastic-apm-laravel.

arkaitzgarro avatar arkaitzgarro commented on July 20, 2024

@rogercbe please try the solution above, it worked for us. I'm closing the issue since it is not related to this package and we have a workaround for it.

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.