Giter Site home page Giter Site logo

monolog-logtail's People

Contributors

curusarn avatar gyfis avatar jendatovarys avatar jindraregal avatar jurajmasar avatar okneloper avatar petrheinz avatar rogervila avatar simonrozsival avatar simosimo2 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

monolog-logtail's Issues

Question?. Strange behavior using Logtail in Queues with Laravel.

I am using Laravel 10 and for logs delivery I am using queues. The log system works fine, for example if I run it from a command, or a controller:

$logger = new Logger('mychannel);
$logger->pushHandler(new LogtailHandler('xxxx'));
$logger->info('message', $array_data);

To improve the user experience, I decided to use queues for log management:

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

use Monolog\Logger;
use Logtail\Monolog\LogtailHandler;

class LogJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     */
    public function __construct(
        public string $channel,
        public string $level,
        public string $message,
        public array $data
    ) {
    }

    /**
     * Execute the job.
     */
    public function handle(): void
    {

        if ($this->channel == 'ychannel') {
            $logger = new Logger($this->channel);
            $logger->pushHandler(new LogtailHandler('dddd'));
        }

        if ($this->channel == 'xchanel') {
            $logger = new Logger($this->channel);
            $logger->pushHandler(new LogtailHandler('zxy'));
        }

        if ($this->level == 'INFO') {
            $logger->info($this->message, $this->data);
        }

        if ($this->level == 'ERROR') {
            $logger->error($this->message, $this->data);
        }

        if ($this->level == 'WARNING') {
            $logger->warning($this->message, $this->data);
        }

    }
}


// dispatch a log on los queue
 LogJob::dispatch('ychannel', 'INFO', 'User Added now',
             ['data' => ['email' => '[email protected]', 'country_id' => 456], ])->onQueue('log_queue');

The queue runs correctly, but the logs do not be delivered to the logtail server.
Looking at how the queue works, it seems that the queue finishes the job first, before monolog finishes sending the log.

monolog-logtail 3.0 
php 8.2
Laravel 10.x

Any tips on how to handle this situation?

Betterstack didn't receive part of logs from Jobs

Logs from Jobs mostly didn't achieve betterstack
logtail/monolog-logtail v2.1.0
laravel 9

Simple example below

...
  'logtail' => [
            'driver' => 'monolog',
            'level' => env('LOG_LEVEL', 'debug'),
            'handler' => LogtailHandler::class,
            'with' => [
                'sourceToken' => env('LOG_SECURE_TOKEN', 'debug'),
            ],
        ],
...

class TesJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Log::debug("test");
    }
}

...

        for ($i = 0; $i < 100; $i++) {
            TesJob::dispatch();
        }
...

Long response time

Hello,
we experienced long processing (response) time while sending logs to Logtail few days ago. That issue caused long response time of our API as we are sending data to your API with every request.

To prevent this to happen again I suggested adding timeouts parameters to cURL instance in the pull request #15.

May I ask you to look into?

Thank you.

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.