fluent-logger-php icon indicating copy to clipboard operation
fluent-logger-php copied to clipboard

Added microsecond support and microtime default value

Open bcismariu opened this issue 7 years ago • 3 comments

fixes #56

bcismariu avatar Feb 01 '19 11:02 bcismariu

@bcismariu Did you succeed with this PR?

I got the error on fluentbit side, when testing this PR:

[ warn] [input:forward:forward.0] invalid data format, type=4

VSilantyev avatar Dec 03 '21 11:12 VSilantyev

We needed this for a project we were working on. As far as I remember, this change worked for us.

I am currently no longer working on that project unfortunately can't easily replicate the environment to support you with your question.

bcismariu avatar Dec 03 '21 11:12 bcismariu

Thank you. I believe this PR will work with fluentd, and will not work with fluentbit.

fluentbit expects nanoseconds as msgpack ext type https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v0#eventtime-ext-format Implemented it with https://github.com/rybakit/msgpack.php#custom-types

        $secs = $this->time->getTimestamp();
        $nanos = (int) $this->time->format('u') * 1000;
        $data = \pack('NN', (int) $secs, (int) $nanos);
        // https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v0#eventtime-ext-format
        return $packer->packExt(0xc7, $data);

VSilantyev avatar Dec 06 '21 07:12 VSilantyev