Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase resolution of log timestamps #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brbrowning21
Copy link

@brbrowning21 brbrowning21 commented Apr 8, 2022

The 'c' format does not include milliseconds. This causes logs sent within the same second to sometimes appear out of order.

Change to use the \DateTimeInterface::RFC3339_EXTENDED constant which includes milliseconds.

After testing, I found that Logz.io truncates timestamps containing microseconds. There is no need to be that fine-grained.

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Adds milliseconds to the @timestamp field sent to Logz.io.

What is the current behavior? (You can also link to an open issue here)
The @timestamp field only goes down to the seconds resolution.

What is the new behavior (if this is a feature change)?
Logs sent to Logz.io now have milliseconds, making them higher resolution and less likely to be out of order.

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
No breaking change. This only works on PHP 7.2.0+, but that is already embedded in the composer.json.

Other information:

The 'c' format does not include milliseconds. This causes logs sent within the same second to sometimes appear out of order.

Change to use the `\DateTimeInterface::RFC3339_EXTENDED` constant which includes milliseconds.

After testing, I found that Logz.io truncates timestamps containing microseconds. There is no need to be that fine-grained.
Copy link
Member

@Chrico Chrico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good morning ☕ and sorry for the late response. This kind of got lost in my inbox 🤔

It looks like that the format of RFC3339_EXTENDED is different to c (ISO 8601). So i'm wondering if this will not cause any errors. By looking into other implementation like logzio-nodejs i can see they are also using the ISO format: https://github.com/logzio/logzio-nodejs/blob/master/lib/logzio-nodejs.js#L184

Can you provide any more context (maybe from official documentation) if RFC3339 format is accepted? Couldn't find any information in their docs about that 🤔


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants