Coder Social home page Coder Social logo

Comments (9)

 avatar commented on July 19, 2024 1

I'm installing a fresh laravel 8 and using the Dockerfile below:

FROM phpswoole/swoole:4.6-php7.4

RUN apt-get update && apt-get install wget gnupg -y

RUN echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list

RUN wget https://download.newrelic.com/548C16BF.gpg

RUN apt-key add 548C16BF.gpg

RUN apt-get update && apt-get -y install newrelic-php5

RUN NR_INSTALL_SILENT=1 newrelic-install install

RUN sed -i -e "s/REPLACE_WITH_REAL_KEY/{MY_NEWRELIC_KEY}/" \
  -e "s/newrelic.appname[[:space:]]=[[:space:]].*/newrelic.appname=\"backend\"/" \
  -e '$anewrelic.distributed_tracing_enabled=true' \
  $(php -r "echo(PHP_CONFIG_FILE_SCAN_DIR);")/newrelic.ini

WORKDIR /var/www/html

ADD . .

RUN chmod -R 777 storage

ENV DISABLE_DEFAULT_SERVER 1

EXPOSE 9501

I also installed swooletw/laravel-swoole and upscalesoftware/swoole-newrelic, and put this to SwooleTW\Http\Commands\HttpServerCommand:

        $apm = new Apm(new Apm\TransactionFactory());
        $apm->instrument($server);

        $rum = new Browser(new Browser\TransactionFactory());
        $rum->instrument($server);

When i run the same code outside a docker container it works perfectly...

from swoole-newrelic.

marinoborges avatar marinoborges commented on July 19, 2024 1

Hello @sshymko, I'm together with @olistpax. I tried your suggestion but it didn't work at all. Currently, our HttpServerCommand class is defined as follows, regarding New Relic instrumentation:

class HttpServerCommand extends Command {

[...]

protected function start() {

[...]

$manager = $this->laravel->make(Manager::class);
$server = $this->laravel->make(Server::class);

$rum = new Browser(new Browser\TransactionFactory());
$rum->instrument($server);

$apm = new Apm(new Apm\TransactionFactory());
$apm->instrument($server);

[...]

$manager->run();
}

As stated by @olistpax, when running locally this laravel-swoole, we get the transactions printed at New Relic web page successfully, so I don't think this is an issue with Laravel architecture.

But when we run this same code in a docker container, we get every transaction printed at New Relic web page as 'artisan'. How could I debug this?

from swoole-newrelic.

marinoborges avatar marinoborges commented on July 19, 2024 1

Hi @sshymko. Actually our issue was with newrelic php agent which misses the first transactions as stated in the doc:

By default, the first transaction causes the agent to trigger a daemon start and an application connection initialization. However, for performance reasons, the agent does not wait for those operations to complete before it initializes the connection, which can result in the loss of the first few transactions after a container starts. To prevent this, set both newrelic.daemon.start_timeout and newrelic.daemon.app_connect_timeout entries in the newrelic.ini file to recommended values.

We solved this by setting these two parameters newrelic.daemon.start_timeout newrelic.daemon.app_connect_timeout entries in the newrelic.ini.

You may close the case! Thanks for all support!

from swoole-newrelic.

marinoborges avatar marinoborges commented on July 19, 2024 1

Parameters:
newrelic.daemon.start_timeout=5s
newrelic.daemon.dont_launch=3
newrelic.daemon.app_connect_timeout=10s
Then we need to start newrelic as a daemon outside PHP.

from swoole-newrelic.

sshymko avatar sshymko commented on July 19, 2024 1

@marinoborges Thank you so much for this information! It will definitely come useful for others! Closing.

from swoole-newrelic.

sshymko avatar sshymko commented on July 19, 2024

@olistpax
Please provide (ideally, minimal) steps to reproduce along with the expected/actual result.

from swoole-newrelic.

sshymko avatar sshymko commented on July 19, 2024

@olistpax
Sorry for the delayed reply, pretty busy with some personal stuff...

I think, the problem is that $server is a Laravel Facade, not a native \Swoole\Http\Server instance.
Don't have much experience with Laravel which makes it challenging to investigate the issue further.
Could you please try the following and let me know whether it works?

$swooleServer = Server::getFacadeRoot();

$apm = new Apm(new Apm\TransactionFactory());
$apm->instrument($swooleServer);

$rum = new Browser(new Browser\TransactionFactory());
$rum->instrument($swooleServer);

Another potential reason is that the New Relic instrumentation must be done after $swooleServer->on('request') binding. With the amount of magic in the Laravel architecture I cannot even follow when that's happening to check this hypothesis.

from swoole-newrelic.

sshymko avatar sshymko commented on July 19, 2024

Thanks for the clarification @marinoborges!

If it's the case that the issue is only reproducible within the Docker container, then it must be running a different codebase.
New Relic would report artisan CLI command without the aforementioned RUM/APM instrumentation changes.

Please check the application codebase the Docker container is running, it must be different from your local.

from swoole-newrelic.

sshymko avatar sshymko commented on July 19, 2024

@marinoborges Great to hear you've been able to resolve the issue!
Would you mind sharing the exact values for the New Relic timeout settings that worked for you?

from swoole-newrelic.

Related Issues (4)

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.